mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-16 03:55:26 +00:00
🎨 Handle Not Enough Permissions Exception
This commit is contained in:
parent
c73fbaaf07
commit
807ae86e8a
@ -2,6 +2,7 @@ import random
|
||||
|
||||
from telegram import Update, Poll
|
||||
from telegram.constants import ChatAction
|
||||
from telegram.error import BadRequest
|
||||
from telegram.ext import CallbackContext, CommandHandler, filters
|
||||
|
||||
from core.admin import BotAdminService
|
||||
@ -50,14 +51,20 @@ class QuizPlugin(Plugin, BasePlugin):
|
||||
return None
|
||||
random.shuffle(_options)
|
||||
index = _options.index(correct_option)
|
||||
poll_message = await update.effective_message.reply_poll(
|
||||
question.text,
|
||||
_options,
|
||||
correct_option_id=index,
|
||||
is_anonymous=False,
|
||||
open_period=self.time_out,
|
||||
type=Poll.QUIZ,
|
||||
)
|
||||
try:
|
||||
poll_message = await message.reply_poll(
|
||||
question.text,
|
||||
_options,
|
||||
correct_option_id=index,
|
||||
is_anonymous=False,
|
||||
open_period=self.time_out,
|
||||
type=Poll.QUIZ,
|
||||
)
|
||||
except BadRequest as exc:
|
||||
if "Not enough rights" in exc.message:
|
||||
poll_message = await message.reply_text("出错了呜呜呜 ~ 权限不足,请请检查投票权限是否开启")
|
||||
else:
|
||||
raise exc
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 300)
|
||||
self._add_delete_message_job(context, poll_message.chat_id, poll_message.message_id, 300)
|
||||
|
@ -146,6 +146,9 @@ def error_callable(func: Callable) -> Callable:
|
||||
text = "气死我了!怎么有人喜欢发一个命令就秒删了!"
|
||||
elif "Message is not modified" in exc.message:
|
||||
telegram_warning(update, exc.message)
|
||||
elif "Not enough rights" in exc.message:
|
||||
telegram_warning(update, exc.message)
|
||||
text = "出错了呜呜呜 ~ 权限不足,请检查对应权限是否开启"
|
||||
else:
|
||||
logger.error("python-telegram-bot 请求错误")
|
||||
logger.exception(exc)
|
||||
|
Loading…
Reference in New Issue
Block a user