get chat_id and thread_id from caller
This commit is contained in:
@@ -2,15 +2,10 @@ import requests as _rqsts
|
|||||||
import syms as _bot_syms
|
import syms as _bot_syms
|
||||||
|
|
||||||
|
|
||||||
def _wb_telegram_send_alert(message: str):
|
def _wb_telegram_send_alert(message, chat_id, thread_id= None):
|
||||||
users= _bot_syms.USERS
|
print(f"wb_alert_bot _wb_telegram_send_alert: sending message to {chat_id}, {thread_id}...")
|
||||||
|
|
||||||
for user in users:
|
|
||||||
u= user[0]
|
|
||||||
thread_id= user[1]
|
|
||||||
print(f"wb_alert_bot _wb_telegram_send_alert: sending message to {user}...")
|
|
||||||
payload = {
|
payload = {
|
||||||
'chat_id': u,
|
'chat_id': chat_id,
|
||||||
'text': message,
|
'text': message,
|
||||||
'parse_mode': 'Markdown',
|
'parse_mode': 'Markdown',
|
||||||
}
|
}
|
||||||
@@ -22,12 +17,21 @@ def _wb_telegram_send_alert(message: str):
|
|||||||
|
|
||||||
jres = res.json()
|
jres = res.json()
|
||||||
if jres.get('ok'):
|
if jres.get('ok'):
|
||||||
print(f"wb_alert_bot _wb_telegram_send_alert: message sent to {user}!")
|
print(f"wb_alert_bot _wb_telegram_send_alert: message sent to {chat_id}, {thread_id}!")
|
||||||
else:
|
else:
|
||||||
print(f"wb_alert_bot _wb_telegram_send_alert: Message not sent to {user}: {jres}")
|
print(f"wb_alert_bot _wb_telegram_send_alert: Message not sent to {chat_id}, {thread_id}: {jres}")
|
||||||
|
|
||||||
except _rqsts.exceptions.RequestException as e:
|
except _rqsts.exceptions.RequestException as e:
|
||||||
print(f"wb_alert_bot _wb_telegram_send_alert: Connection error: {e}")
|
print(f"wb_alert_bot _wb_telegram_send_alert: Connection error {chat_id}, {thread_id}: {e}")
|
||||||
|
|
||||||
def wb_telegram_send_alert(msg):
|
|
||||||
_wb_telegram_send_alert(msg)
|
def wb_telegram_send_alert(msg, chat_id, thread_id= None):
|
||||||
|
_wb_telegram_send_alert(msg, chat_id, thread_id)
|
||||||
|
|
||||||
|
|
||||||
|
def wb_telegram_send_alert_debug(msg):
|
||||||
|
users= _bot_syms.USERS
|
||||||
|
for user in users:
|
||||||
|
chat_id= user[0]
|
||||||
|
thread_id= user[1]
|
||||||
|
_wb_telegram_send_alert(msg, chat_id, thread_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user