aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2021-04-25 23:17:45 +0300
committerEvgeny Zinoviev <me@ch1p.io>2021-04-25 23:17:47 +0300
commitb84537af0c547fa058ed1c5af25475dce4821f0d (patch)
tree221cd263162ad4eefa6acf034f29492c79160a4a
parent7d4f8da59d60156c2d45dc4a44891eea48082315 (diff)
fixes
-rw-r--r--ch1p/functions.py15
-rw-r--r--ch1p/state.py2
-rw-r--r--setup.cfg2
3 files changed, 11 insertions, 8 deletions
diff --git a/ch1p/functions.py b/ch1p/functions.py
index c4f9c99..cf75221 100644
--- a/ch1p/functions.py
+++ b/ch1p/functions.py
@@ -18,17 +18,20 @@ def _get_vars(params: List[Tuple], kw: dict) -> List[AnyStr]:
return result
-def telegram_notify(text: str, parse_mode: str = 'html', **kwargs):
- token, chat_id = _get_vars([
+def telegram_notify(text: str, parse_mode: str = None, **kwargs):
+ chat_id, token = _get_vars([
('chat_id', 'TELEGRAM_NOTIFY_CHAT_ID'),
('token', 'TELEGRAM_NOTIFY_TOKEN')
], kwargs)
- r = requests.post('https://api.telegram.org/bot%s/sendMessage' % token, data={
+ data = {
'chat_id': chat_id,
- 'text': text,
- 'parse_mode': parse_mode
- })
+ 'text': text
+ }
+ 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:
raise RuntimeError("telegram returned %d" % r.status_code)
diff --git a/ch1p/state.py b/ch1p/state.py
index f677f59..e7fe050 100644
--- a/ch1p/state.py
+++ b/ch1p/state.py
@@ -1,6 +1,6 @@
import os, json
-from functions import _get_vars
+from .functions import _get_vars
class State:
diff --git a/setup.cfg b/setup.cfg
index 427563c..160213f 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = ch1p
-version = 0.0.1
+version = 0.0.3
author = Evgeny Zinoviev
author_email = me@ch1p.io
description =