fix some bug

This commit is contained in:
xtaodada 2021-06-19 15:15:43 +08:00
parent 436eaac281
commit e38b747347
No known key found for this signature in database
GPG Key ID: EE4DC37B55E24736
7 changed files with 34 additions and 15 deletions

View File

@ -12,6 +12,7 @@ from os.path import exists
from asyncio import sleep from asyncio import sleep
from random import randint from random import randint
import yaml import yaml
from telethon.errors.rpcerrorlist import StickersetInvalidError
from telethon.tl.custom.message import Message from telethon.tl.custom.message import Message
from telethon.tl.functions.messages import GetAllStickersRequest from telethon.tl.functions.messages import GetAllStickersRequest
from telethon.tl.functions.messages import GetStickerSetRequest from telethon.tl.functions.messages import GetStickerSetRequest
@ -239,10 +240,14 @@ async def process_message(context):
pass pass
if reply and reply_user_id == me.id: if reply and reply_user_id == me.id:
try:
stickers = await context.client( stickers = await context.client(
GetStickerSetRequest( GetStickerSetRequest(
stickerset=InputStickerSetID( stickerset=InputStickerSetID(
id=_sticker_id, access_hash=_sticker_hash))) id=_sticker_id, access_hash=_sticker_hash)))
except StickersetInvalidError:
await log('配置错误。')
return
try: try:
i = randint(0, len(_num) - 1) i = randint(0, len(_num) - 1)
sticker = await context.client.send_file( sticker = await context.client.send_file(

View File

@ -60,7 +60,11 @@ async def fuck(context):
if context.arguments == '': if context.arguments == '':
return return
else: else:
try:
userid = int(context.arguments) userid = int(context.arguments)
except ValueError:
await context.edit('输入值错误。')
return
admins = await context.client.get_participants(context.chat, filter=ChannelParticipantsAdmins) admins = await context.client.get_participants(context.chat, filter=ChannelParticipantsAdmins)
if context.sender in admins: if context.sender in admins:
try: try:

View File

@ -35,7 +35,7 @@ async def killallmembers(context):
await context.delete() await context.delete()
return False 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 context.edit('你又不是管理员,你在这儿干个屁?')
await sleep(10) await sleep(10)
await context.delete() await context.delete()

View File

@ -62,7 +62,7 @@
}, },
{ {
"name": "xtao-some", "name": "xtao-some",
"version": "1.201", "version": "1.202",
"section": "daily", "section": "daily",
"maintainer": "xtaodada", "maintainer": "xtaodada",
"size": "18.8 kb", "size": "18.8 kb",
@ -152,7 +152,7 @@
}, },
{ {
"name": "portball", "name": "portball",
"version": "1.43", "version": "1.44",
"section": "chat", "section": "chat",
"maintainer": "Pentacene", "maintainer": "Pentacene",
"size": "2.8 kb", "size": "2.8 kb",
@ -292,7 +292,7 @@
}, },
{ {
"name": "killallmembers", "name": "killallmembers",
"version": "1.11", "version": "1.12",
"section": "chat", "section": "chat",
"maintainer": "Pentacene", "maintainer": "Pentacene",
"size": "idk", "size": "idk",
@ -362,7 +362,7 @@
}, },
{ {
"name": "autoreplysticker", "name": "autoreplysticker",
"version": "1.22", "version": "1.23",
"section": "chat", "section": "chat",
"maintainer": "Pentacene", "maintainer": "Pentacene",
"size": "12 kb", "size": "12 kb",
@ -392,7 +392,7 @@
}, },
{ {
"name": "transfer", "name": "transfer",
"version": "1.01", "version": "1.02",
"section": "daily", "section": "daily",
"maintainer": "c3b2a", "maintainer": "c3b2a",
"size": "2.7 kb", "size": "2.7 kb",
@ -492,7 +492,7 @@
}, },
{ {
"name": "fuck", "name": "fuck",
"version": "1.01", "version": "1.02",
"section": "chat", "section": "chat",
"maintainer": "Pentacene", "maintainer": "Pentacene",
"size": "4.0 kb", "size": "4.0 kb",

View File

@ -14,7 +14,7 @@ async def portball(context):
reply = await context.get_reply_message() reply = await context.get_reply_message()
if reply: if reply:
action = context.arguments.split() action = context.arguments.split()
if reply.sender.last_name == None: if reply.sender.last_name is None:
last_name = '' last_name = ''
else: else:
last_name = reply.sender.last_name 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) notification = await bot.send_message(context.chat_id, '错误:我没有管理员权限或我的权限比被封禁的人要小', reply_to=context.id)
await sleep(10) await sleep(10)
await notification.delete() await notification.delete()
except OverflowError:
notification = await bot.send_message(context.chat_id, '错误:封禁值太大了', reply_to=context.id)
await sleep(10)
await notification.delete()
else: else:
notification = await bot.send_message(context.chat_id, '你好蠢诶,都没有回复人,我哪知道你要搞谁的事情……', reply_to=context.id) notification = await bot.send_message(context.chat_id, '你好蠢诶,都没有回复人,我哪知道你要搞谁的事情……', reply_to=context.id)
await sleep(10) await sleep(10)

View File

@ -57,7 +57,11 @@ async def transfer(context):
message = await context.get_reply_message() message = await context.get_reply_message()
if message and message.media: if message and message.media:
_file = BytesIO() _file = BytesIO()
try:
await bot.download_file(message.media.document, _file) await bot.download_file(message.media.document, _file)
except AttributeError:
await context.edit('无法下载此类型的文件。')
return
if not exists(file_list[0]): if not exists(file_list[0]):
with open(file_list[0], "wb") as f: with open(file_list[0], "wb") as f:
f.write(_file.getvalue()) f.write(_file.getvalue())

View File

@ -5,7 +5,7 @@ from pagermaid import bot, log
from pagermaid.listener import listener, config from pagermaid.listener import listener, config
from pagermaid.utils import clear_emojis, obtain_message, attach_log, alias_command from pagermaid.utils import clear_emojis, obtain_message, attach_log, alias_command
from telethon.errors import ChatAdminRequiredError 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 from telethon.tl.types import ChannelParticipantsAdmins, ChannelParticipantsBots, ChannelParticipantAdmin
@ -300,6 +300,8 @@ async def getdel(context):
except FloodWaitError: except FloodWaitError:
await context.edit('处理失败,您已受到 TG 服务器限制。') await context.edit('处理失败,您已受到 TG 服务器限制。')
return return
except UserAdminInvalidError:
pass
if need_kick and parameter: if need_kick and parameter:
await context.edit(f'此频道/群组的死号数:`{member_count}`,并且已经清理完毕。') await context.edit(f'此频道/群组的死号数:`{member_count}`,并且已经清理完毕。')
else: else: