From 34851d219d3d6aefd84e06a72d8b6f8d87ad873d Mon Sep 17 00:00:00 2001 From: bakatrouble Date: Wed, 6 May 2020 18:51:19 +0300 Subject: [PATCH] fix --- bots/modules/ping.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bots/modules/ping.py b/bots/modules/ping.py index b781c15..e6bc05b 100644 --- a/bots/modules/ping.py +++ b/bots/modules/ping.py @@ -1,6 +1,7 @@ from django.db import models from jsonfield import JSONField from telegram import Update +from telegram.error import BadRequest from telegram.ext import Dispatcher, CallbackContext, CommandHandler from telegram.utils.helpers import mention_html @@ -58,8 +59,11 @@ class PingBotModuleConfig(TelegramBotModuleConfig): return update.effective_message.reply_text(self.no_users_text) mentions = [] for uid in cat.user_ids: - member = ctx.bot.get_chat_member(update.effective_chat.id, uid) - mentions.append(mention_html(uid, '#{} [{}]'.format(uid, member.user.full_name))) + try: + member = ctx.bot.get_chat_member(update.effective_chat.id, uid) + mentions.append(mention_html(uid, '#{} [{}]'.format(uid, member.user.full_name))) + except BadRequest: + cat.remove_user(uid) update.effective_message.reply_html(self.message_template.format(mentions='; '.join(mentions))) def categories_handler(self, update: Update, ctx: CallbackContext):