This commit is contained in:
bakatrouble 2020-05-06 18:51:19 +03:00
parent 4f5be9320a
commit 34851d219d

View File

@ -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):