Initial commit
This commit is contained in:
parent
2f970d8799
commit
b2e2f54d09
@ -61,7 +61,6 @@ def read_yaml(name, secrets_file='secrets.yaml'):
|
|||||||
conf = {}
|
conf = {}
|
||||||
with open(name, 'r', encoding='utf-8') as f:
|
with open(name, 'r', encoding='utf-8') as f:
|
||||||
y_conf = yaml.safe_load(f)
|
y_conf = yaml.safe_load(f)
|
||||||
print(f'{[y_conf]}')
|
|
||||||
if y_conf:
|
if y_conf:
|
||||||
for key, value in y_conf.items():
|
for key, value in y_conf.items():
|
||||||
conf[key] = value
|
conf[key] = value
|
||||||
|
|||||||
18
get_eo.py
18
get_eo.py
@ -21,17 +21,18 @@ STATUS_ERROR_PO_RESPONSE = 30
|
|||||||
STATUS_EMPTY_CONFIG = 5
|
STATUS_EMPTY_CONFIG = 5
|
||||||
|
|
||||||
SCRIPT_PATH = os.path.dirname(__file__)
|
SCRIPT_PATH = os.path.dirname(__file__)
|
||||||
CONFIG_FILE_NAME = SCRIPT_PATH + '/get_eo_config.yaml'
|
#CONFIG_FILE_NAME = SCRIPT_PATH + '/get_eo_config.yaml'
|
||||||
#CONFIG_FILE_NAME = SCRIPT_PATH + '/eo_config.json'
|
CONFIG_FILE_NAME = SCRIPT_PATH + '/eo_config.json'
|
||||||
LAST_DATAS_FILE_NAME_GPV = SCRIPT_PATH + '/get_eo.last_info'
|
LAST_DATAS_FILE_NAME_GPV = SCRIPT_PATH + '/get_eo.last_info'
|
||||||
LAST_DATAS_FILE_NAME_PO = SCRIPT_PATH + '/get_po.last_info'
|
LAST_DATAS_FILE_NAME_PO = SCRIPT_PATH + '/get_po.last_info'
|
||||||
LAST_DATAS_FORMAT_GPV = '{array} {date} {day}'
|
LAST_DATAS_FORMAT_GPV = '{array} {date} {day}'
|
||||||
LAST_DATAS_FORMAT_PO = '{placed} {star_dt} {start_tm} {stop_dt} {stop_tm} {current_date}'
|
LAST_DATAS_FORMAT_PO = '{placed} {star_dt} {start_tm} {stop_dt} {stop_tm} {current_date}'
|
||||||
|
|
||||||
IS_DEBUG = False
|
IS_DEBUG = False
|
||||||
MENTIONED_USERS = '@Kirden0'
|
MENTIONS = ""
|
||||||
|
|
||||||
def read_config():
|
def read_config():
|
||||||
|
global MENTIONS
|
||||||
j = read_cfg(CONFIG_FILE_NAME)
|
j = read_cfg(CONFIG_FILE_NAME)
|
||||||
tg_token = j['token']
|
tg_token = j['token']
|
||||||
tg_chat = j['chat_id']
|
tg_chat = j['chat_id']
|
||||||
@ -42,11 +43,18 @@ def read_config():
|
|||||||
house = j['house']
|
house = j['house']
|
||||||
building_part_number = j['building_part_number']
|
building_part_number = j['building_part_number']
|
||||||
apartment = j['apartment']
|
apartment = j['apartment']
|
||||||
|
for m in j['mentions']:
|
||||||
|
MENTIONS += m + '\n'
|
||||||
return tg_token, tg_chat, oe_account_number, is_debug, settlement, street, house, building_part_number, apartment
|
return tg_token, tg_chat, oe_account_number, is_debug, settlement, street, house, building_part_number, apartment
|
||||||
|
|
||||||
def send_message_to_tg(msg, token, chat):
|
def send_message_to_tg(msg, token, chat):
|
||||||
url = f"https://api.telegram.org/bot{token}/sendMessage?chat_id={chat}&parse_mode=html&text={msg}"
|
url = f"https://api.telegram.org/bot{token}/sendMessage?chat_id={chat}&parse_mode=html&text={msg}"
|
||||||
return requests.get(url)
|
return requests.get(url)
|
||||||
|
# return requests.post(
|
||||||
|
# url='https://api.telegram.org/bot{0}/{1}'.format(token, 'sendMessage'),
|
||||||
|
# data={'chat_id': {chat}, 'text': {msg}, 'parse_mode': 'html'}
|
||||||
|
# )
|
||||||
|
|
||||||
|
|
||||||
def get_GPV_response_from_oe(account):
|
def get_GPV_response_from_oe(account):
|
||||||
url = 'https://be-svitlo.oe.if.ua/schedule-by-search'
|
url = 'https://be-svitlo.oe.if.ua/schedule-by-search'
|
||||||
@ -167,7 +175,7 @@ def get_GPV_message(approved_from, event_date, hours_off, hours_on, outage_queue
|
|||||||
msg = get_digit_message(arr, True)
|
msg = get_digit_message(arr, True)
|
||||||
message += '\n' + msg
|
message += '\n' + msg
|
||||||
|
|
||||||
message += (f'\n{MENTIONED_USERS}')
|
message += (f'\n{MENTIONS}')
|
||||||
else:
|
else:
|
||||||
message += '\nВимкнень немає \U0001F44C \U0001F483'
|
message += '\nВимкнень немає \U0001F44C \U0001F483'
|
||||||
message += (f'\n<b><i>{approved_from}</i></b>')
|
message += (f'\n<b><i>{approved_from}</i></b>')
|
||||||
@ -199,7 +207,7 @@ def get_message_with_PO(root, html): #city, street, house, placement_date, PO_ty
|
|||||||
f'Причина відключення: {reason}\n'
|
f'Причина відключення: {reason}\n'
|
||||||
f'Початок вимкнення <b>{start_date} об {start_time}</b>\n'
|
f'Початок вимкнення <b>{start_date} об {start_time}</b>\n'
|
||||||
f'Кінець вимкнення <b>{stop_date} об {stop_time}</b>\n'
|
f'Кінець вимкнення <b>{stop_date} об {stop_time}</b>\n'
|
||||||
f'{MENTIONED_USERS}')
|
f'{MENTIONS}')
|
||||||
|
|
||||||
need_to_send = (not is_old_and_new_datas_equals_PO(placed=placement_date, star_dt=start_date,
|
need_to_send = (not is_old_and_new_datas_equals_PO(placed=placement_date, star_dt=start_date,
|
||||||
start_tm=start_time, stop_dt=stop_date, stop_tm=stop_time))
|
start_tm=start_time, stop_dt=stop_date, stop_tm=stop_time))
|
||||||
|
|||||||
@ -7,3 +7,4 @@ street: !secret street
|
|||||||
house: "9"
|
house: "9"
|
||||||
building_part_number: ""
|
building_part_number: ""
|
||||||
apartment: ""
|
apartment: ""
|
||||||
|
mentions: !secret mentions
|
||||||
Loading…
x
Reference in New Issue
Block a user