fixes
This commit is contained in:
parent
7d4f8da59d
commit
b84537af0c
@ -18,17 +18,20 @@ def _get_vars(params: List[Tuple], kw: dict) -> List[AnyStr]:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def telegram_notify(text: str, parse_mode: str = 'html', **kwargs):
|
def telegram_notify(text: str, parse_mode: str = None, **kwargs):
|
||||||
token, chat_id = _get_vars([
|
chat_id, token = _get_vars([
|
||||||
('chat_id', 'TELEGRAM_NOTIFY_CHAT_ID'),
|
('chat_id', 'TELEGRAM_NOTIFY_CHAT_ID'),
|
||||||
('token', 'TELEGRAM_NOTIFY_TOKEN')
|
('token', 'TELEGRAM_NOTIFY_TOKEN')
|
||||||
], kwargs)
|
], kwargs)
|
||||||
|
|
||||||
r = requests.post('https://api.telegram.org/bot%s/sendMessage' % token, data={
|
data = {
|
||||||
'chat_id': chat_id,
|
'chat_id': chat_id,
|
||||||
'text': text,
|
'text': text
|
||||||
'parse_mode': parse_mode
|
}
|
||||||
})
|
if parse_mode is not None:
|
||||||
|
data['parse_mode'] = parse_mode
|
||||||
|
|
||||||
|
r = requests.post('https://api.telegram.org/bot%s/sendMessage' % token, data=data)
|
||||||
|
|
||||||
if r.status_code != 200:
|
if r.status_code != 200:
|
||||||
raise RuntimeError("telegram returned %d" % r.status_code)
|
raise RuntimeError("telegram returned %d" % r.status_code)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import os, json
|
import os, json
|
||||||
|
|
||||||
from functions import _get_vars
|
from .functions import _get_vars
|
||||||
|
|
||||||
|
|
||||||
class State:
|
class State:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user