support threaded groups
This commit is contained in:
6
bot.py
6
bot.py
@@ -4,7 +4,11 @@ import syms as _bot_syms
|
|||||||
|
|
||||||
async def bot_start(update, context):
|
async def bot_start(update, context):
|
||||||
chat_id = update.effective_chat.id
|
chat_id = update.effective_chat.id
|
||||||
await update.message.reply_text(f'wb_alert bot: <code>{chat_id}</code>', parse_mode='HTML')
|
try: thread_id= update.message.message_thread_id
|
||||||
|
except: thread_id= None
|
||||||
|
txt= f'wb_alert bot: <code>{chat_id}</code>'
|
||||||
|
if thread_id: txt= f'wb_alert bot: <code>{chat_id}</code> thread: <code>{thread_id}</code>'
|
||||||
|
await update.message.reply_text(txt, parse_mode='HTML')
|
||||||
print(f'alert_bot bot_start: {chat_id}')
|
print(f'alert_bot bot_start: {chat_id}')
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
@@ -6,12 +6,15 @@ def _wb_telegram_send_alert(message: str):
|
|||||||
users= _bot_syms.USERS
|
users= _bot_syms.USERS
|
||||||
|
|
||||||
for user in users:
|
for user in users:
|
||||||
|
u= user[0]
|
||||||
|
thread_id= user[1]
|
||||||
print(f"wb_alert_bot _wb_telegram_send_alert: sending message to {user}...")
|
print(f"wb_alert_bot _wb_telegram_send_alert: sending message to {user}...")
|
||||||
payload = {
|
payload = {
|
||||||
'chat_id': user,
|
'chat_id': u,
|
||||||
'text': message,
|
'text': message,
|
||||||
'parse_mode': 'Markdown'
|
'parse_mode': 'Markdown',
|
||||||
}
|
}
|
||||||
|
if thread_id: payload['message_thread_id']= thread_id
|
||||||
|
|
||||||
try:
|
try:
|
||||||
res = _rqsts.post(_bot_syms.TELEGRAM_API_URL, data=payload, timeout=3)
|
res = _rqsts.post(_bot_syms.TELEGRAM_API_URL, data=payload, timeout=3)
|
||||||
|
|||||||
Reference in New Issue
Block a user