mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-16 04:35:49 +00:00
修改 RestrictsCalls
能够只删除群组发出的命令 并限制其他命令
This commit is contained in:
parent
62445ab1dc
commit
9ced9a7b28
@ -6,7 +6,7 @@ from telegram.helpers import escape_markdown
|
||||
|
||||
from logger import Log
|
||||
from model.apihelper.artifact import ArtifactOcrRate, get_comment, get_format_sub_item
|
||||
from plugins.base import BasePlugins
|
||||
from plugins.base import BasePlugins, RestrictsCalls
|
||||
from plugins.errorhandler import conversation_error_handler
|
||||
from service import BaseService
|
||||
|
||||
@ -64,6 +64,7 @@ class ArtifactRate(BasePlugins):
|
||||
"_评分、识图均来自 genshin\\.pub_"
|
||||
|
||||
@conversation_error_handler
|
||||
@RestrictsCalls(filters_chat=filters.ALL, return_data=ConversationHandler.END, try_delete_message=True)
|
||||
async def command_start(self, update: Update, context: CallbackContext) -> int:
|
||||
message = update.message
|
||||
user = update.effective_user
|
||||
|
@ -129,7 +129,8 @@ class RestrictsCalls:
|
||||
if time.time() - command_time <= 20:
|
||||
if _try_delete_message:
|
||||
try:
|
||||
await message.delete()
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
await message.delete()
|
||||
except BadRequest as error:
|
||||
Log.warning("删除消息失败", error)
|
||||
return _return_data
|
||||
|
@ -9,7 +9,7 @@ from telegram.helpers import escape_markdown
|
||||
|
||||
from logger import Log
|
||||
from model.base import ServiceEnum
|
||||
from plugins.base import BasePlugins
|
||||
from plugins.base import BasePlugins, RestrictsCalls
|
||||
from plugins.errorhandler import conversation_error_handler
|
||||
from service import BaseService
|
||||
from service.base import UserInfoData
|
||||
@ -65,6 +65,7 @@ class Cookies(BasePlugins):
|
||||
return self.CHECK_SERVER
|
||||
|
||||
@conversation_error_handler
|
||||
@RestrictsCalls(filters_chat=filters.ALL, return_data=ConversationHandler.END, try_delete_message=True)
|
||||
async def check_server(self, update: Update, context: CallbackContext) -> int:
|
||||
user = update.effective_user
|
||||
cookies_command_data: CookiesCommandData = context.chat_data.get("cookies_command_data")
|
||||
|
@ -10,7 +10,7 @@ from telegram.ext import CallbackContext, CommandHandler, MessageHandler, Conver
|
||||
|
||||
from logger import Log
|
||||
from model.base import ServiceEnum
|
||||
from plugins.base import BasePlugins
|
||||
from plugins.base import BasePlugins, RestrictsCalls
|
||||
from plugins.errorhandler import conversation_error_handler
|
||||
from service import BaseService
|
||||
from service.base import UserInfoData
|
||||
@ -102,6 +102,7 @@ class DailyNote(BasePlugins):
|
||||
return png_data
|
||||
|
||||
@conversation_error_handler
|
||||
@RestrictsCalls(filters_chat=filters.ALL, return_data=ConversationHandler.END, try_delete_message=True)
|
||||
async def command_start(self, update: Update, context: CallbackContext) -> int:
|
||||
user = update.effective_user
|
||||
message = update.message
|
||||
|
@ -27,7 +27,7 @@ class Gacha(BasePlugins):
|
||||
|
||||
CHECK_SERVER, COMMAND_RESULT = range(10600, 10602)
|
||||
|
||||
@RestrictsCalls(return_data=ConversationHandler.END, try_delete_message=True)
|
||||
@RestrictsCalls(filters_chat=filters.ALL, return_data=ConversationHandler.END, try_delete_message=True)
|
||||
@conversation_error_handler
|
||||
async def command_start(self, update: Update, context: CallbackContext) -> None:
|
||||
message = update.message
|
||||
|
@ -10,7 +10,7 @@ from telegram.ext import CallbackContext, CommandHandler, MessageHandler, Conver
|
||||
|
||||
from logger import Log
|
||||
from model.base import ServiceEnum
|
||||
from plugins.base import BasePlugins
|
||||
from plugins.base import BasePlugins, RestrictsCalls
|
||||
from plugins.errorhandler import conversation_error_handler
|
||||
from service import BaseService
|
||||
from service.base import UserInfoData
|
||||
@ -123,6 +123,7 @@ class Ledger(BasePlugins):
|
||||
return png_data
|
||||
|
||||
@conversation_error_handler
|
||||
@RestrictsCalls(filters_chat=filters.ALL, return_data=ConversationHandler.END, try_delete_message=True)
|
||||
async def command_start(self, update: Update, context: CallbackContext) -> int:
|
||||
user = update.effective_user
|
||||
message = update.message
|
||||
|
@ -10,7 +10,7 @@ from telegram.ext import CallbackContext, CommandHandler, MessageHandler, Conver
|
||||
|
||||
from logger import Log
|
||||
from model.base import ServiceEnum
|
||||
from plugins.base import BasePlugins
|
||||
from plugins.base import BasePlugins, RestrictsCalls
|
||||
from plugins.errorhandler import conversation_error_handler
|
||||
from service import BaseService
|
||||
from service.base import UserInfoData
|
||||
@ -90,6 +90,7 @@ class Sign(BasePlugins):
|
||||
return message
|
||||
|
||||
@conversation_error_handler
|
||||
@RestrictsCalls(filters_chat=filters.ALL, return_data=ConversationHandler.END, try_delete_message=True)
|
||||
async def command_start(self, update: Update, context: CallbackContext) -> int:
|
||||
user = update.effective_user
|
||||
message = update.message
|
||||
|
@ -2,12 +2,12 @@ import re
|
||||
|
||||
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
|
||||
from telegram.constants import ChatAction, ParseMode
|
||||
from telegram.ext import CallbackContext, filters
|
||||
from telegram.ext import CallbackContext, filters, ConversationHandler
|
||||
|
||||
from logger import Log
|
||||
from metadata.shortname import roleToName
|
||||
from model.helpers import url_to_file
|
||||
from plugins.base import BasePlugins
|
||||
from plugins.base import BasePlugins, RestrictsCalls
|
||||
from plugins.errorhandler import conversation_error_handler
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@ class Strategy(BasePlugins):
|
||||
"""
|
||||
|
||||
@conversation_error_handler
|
||||
@RestrictsCalls(filters_chat=filters.ALL, try_delete_message=True)
|
||||
async def command_start(self, update: Update, context: CallbackContext) -> None:
|
||||
message = update.message
|
||||
user = update.effective_user
|
||||
|
@ -11,7 +11,7 @@ from telegram.ext import CallbackContext, CommandHandler, MessageHandler, Conver
|
||||
from logger import Log
|
||||
from model.base import ServiceEnum
|
||||
from model.helpers import url_to_file
|
||||
from plugins.base import BasePlugins
|
||||
from plugins.base import BasePlugins, RestrictsCalls
|
||||
from plugins.errorhandler import conversation_error_handler
|
||||
from service import BaseService
|
||||
from service.base import UserInfoData
|
||||
@ -139,6 +139,7 @@ class Uid(BasePlugins):
|
||||
return png_data
|
||||
|
||||
@conversation_error_handler
|
||||
@RestrictsCalls(filters_chat=filters.ALL, return_data=ConversationHandler.END, try_delete_message=True)
|
||||
async def command_start(self, update: Update, context: CallbackContext) -> int:
|
||||
user = update.effective_user
|
||||
message = update.message
|
||||
|
@ -2,12 +2,12 @@ import re
|
||||
|
||||
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
|
||||
from telegram.constants import ChatAction
|
||||
from telegram.ext import CallbackContext, filters
|
||||
from telegram.ext import CallbackContext, filters, ConversationHandler
|
||||
|
||||
from logger import Log
|
||||
from metadata.shortname import weaponToName
|
||||
from model.helpers import url_to_file
|
||||
from plugins.base import BasePlugins
|
||||
from plugins.base import BasePlugins, RestrictsCalls
|
||||
from plugins.errorhandler import conversation_error_handler
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@ class Weapon(BasePlugins):
|
||||
"""
|
||||
|
||||
@conversation_error_handler
|
||||
@RestrictsCalls(filters_chat=filters.ALL, try_delete_message=True)
|
||||
async def command_start(self, update: Update, context: CallbackContext) -> None:
|
||||
message = update.message
|
||||
user = update.effective_user
|
||||
|
Loading…
Reference in New Issue
Block a user