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 django.db import models
from jsonfield import JSONField from jsonfield import JSONField
from telegram import Update from telegram import Update
from telegram.error import BadRequest
from telegram.ext import Dispatcher, CallbackContext, CommandHandler from telegram.ext import Dispatcher, CallbackContext, CommandHandler
from telegram.utils.helpers import mention_html from telegram.utils.helpers import mention_html
@ -58,8 +59,11 @@ class PingBotModuleConfig(TelegramBotModuleConfig):
return update.effective_message.reply_text(self.no_users_text) return update.effective_message.reply_text(self.no_users_text)
mentions = [] mentions = []
for uid in cat.user_ids: for uid in cat.user_ids:
member = ctx.bot.get_chat_member(update.effective_chat.id, uid) try:
mentions.append(mention_html(uid, '#{} [{}]'.format(uid, member.user.full_name))) 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))) update.effective_message.reply_html(self.message_template.format(mentions='; '.join(mentions)))
def categories_handler(self, update: Update, ctx: CallbackContext): def categories_handler(self, update: Update, ctx: CallbackContext):