def unlink_all(self, bot, update):
"""
Unlink all chats linked to the telegram group.
Triggered by `/unlink_all`.
Args:
bot: Telegram Bot instance
update: Message update
"""
if update.message.chat.id == update.message.from_user.id:
return bot.send_message(update.message.chat.id, "Send `/unlink_all` to a group to unlink all remote chats "
"from it.",
parse_mode=telegram.ParseMode.MARKDOWN,
reply_to_message_id=update.message.message_id)
assocs = db.get_chat_assoc(master_uid="%s.%s" % (self.channel_id, update.message.chat.id))
if len(assocs) < 1:
return bot.send_message(update.message.chat.id, "No chat is linked to the group.",
reply_to_message_id=update.message.message_id)
else:
db.remove_chat_assoc(master_uid="%s.%s" % (self.channel_id, update.message.chat.id))
return bot.send_message(update.message.chat.id, "All chats has been unlinked from this group. (%s)" % len(assocs),
reply_to_message_id=update.message.message_id)
评论列表
文章目录