mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-25 09:37:30 +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 import Update, Poll
|
||||||
from telegram.constants import ChatAction
|
from telegram.constants import ChatAction
|
||||||
|
from telegram.error import BadRequest
|
||||||
from telegram.ext import CallbackContext, CommandHandler, filters
|
from telegram.ext import CallbackContext, CommandHandler, filters
|
||||||
|
|
||||||
from core.admin import BotAdminService
|
from core.admin import BotAdminService
|
||||||
@ -50,7 +51,8 @@ class QuizPlugin(Plugin, BasePlugin):
|
|||||||
return None
|
return None
|
||||||
random.shuffle(_options)
|
random.shuffle(_options)
|
||||||
index = _options.index(correct_option)
|
index = _options.index(correct_option)
|
||||||
poll_message = await update.effective_message.reply_poll(
|
try:
|
||||||
|
poll_message = await message.reply_poll(
|
||||||
question.text,
|
question.text,
|
||||||
_options,
|
_options,
|
||||||
correct_option_id=index,
|
correct_option_id=index,
|
||||||
@ -58,6 +60,11 @@ class QuizPlugin(Plugin, BasePlugin):
|
|||||||
open_period=self.time_out,
|
open_period=self.time_out,
|
||||||
type=Poll.QUIZ,
|
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):
|
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, message.chat_id, message.message_id, 300)
|
||||||
self._add_delete_message_job(context, poll_message.chat_id, poll_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 = "气死我了!怎么有人喜欢发一个命令就秒删了!"
|
text = "气死我了!怎么有人喜欢发一个命令就秒删了!"
|
||||||
elif "Message is not modified" in exc.message:
|
elif "Message is not modified" in exc.message:
|
||||||
telegram_warning(update, exc.message)
|
telegram_warning(update, exc.message)
|
||||||
|
elif "Not enough rights" in exc.message:
|
||||||
|
telegram_warning(update, exc.message)
|
||||||
|
text = "出错了呜呜呜 ~ 权限不足,请检查对应权限是否开启"
|
||||||
else:
|
else:
|
||||||
logger.error("python-telegram-bot 请求错误")
|
logger.error("python-telegram-bot 请求错误")
|
||||||
logger.exception(exc)
|
logger.exception(exc)
|
||||||
|
Loading…
Reference in New Issue
Block a user