From e38b74734706e5f663c0d7aa82ae47e64975268b Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sat, 19 Jun 2021 15:15:43 +0800 Subject: [PATCH] fix some bug --- autoreplysticker.py | 13 +++++++++---- fuck.py | 6 +++++- killallmembers.py | 2 +- list.json | 12 ++++++------ portball.py | 6 +++++- transfer.py | 6 +++++- xtao-some.py | 4 +++- 7 files changed, 34 insertions(+), 15 deletions(-) diff --git a/autoreplysticker.py b/autoreplysticker.py index cb0f1fa..f7af5f7 100644 --- a/autoreplysticker.py +++ b/autoreplysticker.py @@ -12,6 +12,7 @@ from os.path import exists from asyncio import sleep from random import randint import yaml +from telethon.errors.rpcerrorlist import StickersetInvalidError from telethon.tl.custom.message import Message from telethon.tl.functions.messages import GetAllStickersRequest from telethon.tl.functions.messages import GetStickerSetRequest @@ -239,10 +240,14 @@ async def process_message(context): pass if reply and reply_user_id == me.id: - stickers = await context.client( - GetStickerSetRequest( - stickerset=InputStickerSetID( - id=_sticker_id, access_hash=_sticker_hash))) + try: + stickers = await context.client( + GetStickerSetRequest( + stickerset=InputStickerSetID( + id=_sticker_id, access_hash=_sticker_hash))) + except StickersetInvalidError: + await log('配置错误。') + return try: i = randint(0, len(_num) - 1) sticker = await context.client.send_file( diff --git a/fuck.py b/fuck.py index 120ad5f..5c34f30 100644 --- a/fuck.py +++ b/fuck.py @@ -60,7 +60,11 @@ async def fuck(context): if context.arguments == '': return else: - userid = int(context.arguments) + try: + userid = int(context.arguments) + except ValueError: + await context.edit('输入值错误。') + return admins = await context.client.get_participants(context.chat, filter=ChannelParticipantsAdmins) if context.sender in admins: try: diff --git a/killallmembers.py b/killallmembers.py index c59cef8..8ff634c 100644 --- a/killallmembers.py +++ b/killallmembers.py @@ -35,7 +35,7 @@ async def killallmembers(context): await context.delete() return False - if (not is_channel) and (context.sender.id not in admins_ids): + if (not is_channel) and (context.sender_id not in admins_ids): await context.edit('你又不是管理员,你在这儿干个屁?') await sleep(10) await context.delete() diff --git a/list.json b/list.json index e2ccf24..851479b 100644 --- a/list.json +++ b/list.json @@ -62,7 +62,7 @@ }, { "name": "xtao-some", - "version": "1.201", + "version": "1.202", "section": "daily", "maintainer": "xtaodada", "size": "18.8 kb", @@ -152,7 +152,7 @@ }, { "name": "portball", - "version": "1.43", + "version": "1.44", "section": "chat", "maintainer": "Pentacene", "size": "2.8 kb", @@ -292,7 +292,7 @@ }, { "name": "killallmembers", - "version": "1.11", + "version": "1.12", "section": "chat", "maintainer": "Pentacene", "size": "idk", @@ -362,7 +362,7 @@ }, { "name": "autoreplysticker", - "version": "1.22", + "version": "1.23", "section": "chat", "maintainer": "Pentacene", "size": "12 kb", @@ -392,7 +392,7 @@ }, { "name": "transfer", - "version": "1.01", + "version": "1.02", "section": "daily", "maintainer": "c3b2a", "size": "2.7 kb", @@ -492,7 +492,7 @@ }, { "name": "fuck", - "version": "1.01", + "version": "1.02", "section": "chat", "maintainer": "Pentacene", "size": "4.0 kb", diff --git a/portball.py b/portball.py index 4612b61..71b224d 100644 --- a/portball.py +++ b/portball.py @@ -14,7 +14,7 @@ async def portball(context): reply = await context.get_reply_message() if reply: action = context.arguments.split() - if reply.sender.last_name == None: + if reply.sender.last_name is None: last_name = '' else: last_name = reply.sender.last_name @@ -60,6 +60,10 @@ async def portball(context): notification = await bot.send_message(context.chat_id, '错误:我没有管理员权限或我的权限比被封禁的人要小', reply_to=context.id) await sleep(10) await notification.delete() + except OverflowError: + notification = await bot.send_message(context.chat_id, '错误:封禁值太大了', reply_to=context.id) + await sleep(10) + await notification.delete() else: notification = await bot.send_message(context.chat_id, '你好蠢诶,都没有回复人,我哪知道你要搞谁的事情……', reply_to=context.id) await sleep(10) diff --git a/transfer.py b/transfer.py index e9c836a..6311324 100644 --- a/transfer.py +++ b/transfer.py @@ -57,7 +57,11 @@ async def transfer(context): message = await context.get_reply_message() if message and message.media: _file = BytesIO() - await bot.download_file(message.media.document, _file) + try: + await bot.download_file(message.media.document, _file) + except AttributeError: + await context.edit('无法下载此类型的文件。') + return if not exists(file_list[0]): with open(file_list[0], "wb") as f: f.write(_file.getvalue()) diff --git a/xtao-some.py b/xtao-some.py index 7e94898..0030b1c 100644 --- a/xtao-some.py +++ b/xtao-some.py @@ -5,7 +5,7 @@ from pagermaid import bot, log from pagermaid.listener import listener, config from pagermaid.utils import clear_emojis, obtain_message, attach_log, alias_command from telethon.errors import ChatAdminRequiredError -from telethon.errors.rpcerrorlist import FloodWaitError +from telethon.errors.rpcerrorlist import FloodWaitError, UserAdminInvalidError from telethon.tl.types import ChannelParticipantsAdmins, ChannelParticipantsBots, ChannelParticipantAdmin @@ -300,6 +300,8 @@ async def getdel(context): except FloodWaitError: await context.edit('处理失败,您已受到 TG 服务器限制。') return + except UserAdminInvalidError: + pass if need_kick and parameter: await context.edit(f'此频道/群组的死号数:`{member_count}`,并且已经清理完毕。') else: