def botupdated_message(bot, job):
"""
Defining a command to notify the user and tell them what updates have been released
It is called at every execution ONLY if there are documents in a specific db collection
"""
messages = list(DATABASE.messages.find())
DATABASE.messages.remove()
invalid_chatid = []
for message in messages:
for chat_id in USERS['telegramID']:
try:
bot.sendMessage(chat_id, parse_mode='HTML',
text=message['text'])
except TelegramError:
invalid_chatid.append(chat_id)
for chat_id in invalid_chatid:
USERS['telegramID'].remove(chat_id)
unsubscribe_user(chat_id, 'telegramID')
评论列表
文章目录