fix some bugs

This commit is contained in:
xtaodada 2021-07-15 16:12:49 +08:00
parent 8271821071
commit 8619b795a7
No known key found for this signature in database
GPG Key ID: EE4DC37B55E24736
7 changed files with 44 additions and 18 deletions

View File

@ -41,6 +41,9 @@ async def private_autorespond(context):
@listener(incoming=True) @listener(incoming=True)
async def mention_autorespond(context): async def mention_autorespond(context):
if persistent_vars['autorespond']['enabled']: if persistent_vars['autorespond']['enabled']:
try:
if context.message.mentioned and not (await context.get_sender()).bot: if context.message.mentioned and not (await context.get_sender()).bot:
persistent_vars['autorespond']['amount'] += 1 persistent_vars['autorespond']['amount'] += 1
await context.reply(persistent_vars['autorespond']['message']) await context.reply(persistent_vars['autorespond']['message'])
except AttributeError:
return

6
bin.py
View File

@ -1,7 +1,9 @@
import json, requests import json, requests
from json.decoder import JSONDecodeError
from pagermaid.listener import listener from pagermaid.listener import listener
from pagermaid.utils import obtain_message, alias_command from pagermaid.utils import obtain_message, alias_command
@listener(is_plugin=True, outgoing=True, command=alias_command("bin"), @listener(is_plugin=True, outgoing=True, command=alias_command("bin"),
description="查询信用卡信息", description="查询信用卡信息",
parameters="<bin4到8位数字>") parameters="<bin4到8位数字>")
@ -24,7 +26,11 @@ async def card(context):
await context.edit("出错了呜呜呜 ~ 每分钟限额超过,请等待一分钟再试") await context.edit("出错了呜呜呜 ~ 每分钟限额超过,请等待一分钟再试")
return return
try:
bin_json = json.loads(r.content.decode("utf-8")) bin_json = json.loads(r.content.decode("utf-8"))
except JSONDecodeError:
await context.edit("出错了呜呜呜 ~ 无效的参数。")
return
msg_out = [] msg_out = []
msg_out.extend(["BIN" + card_bin]) msg_out.extend(["BIN" + card_bin])

View File

@ -1,8 +1,7 @@
from pagermaid.listener import listener from pagermaid.listener import listener
from pagermaid.utils import alias_command from pagermaid.utils import alias_command
from telethon.tl.types import ChannelParticipantsAdmins from telethon.tl.types import ChannelParticipantsAdmins
from telethon.errors.rpcerrorlist import UserAdminInvalidError from telethon.errors.rpcerrorlist import UserAdminInvalidError, ChatAdminRequiredError, FloodWaitError
from telethon.errors.rpcerrorlist import FloodWaitError
from asyncio import sleep from asyncio import sleep
from random import uniform from random import uniform
@ -71,6 +70,9 @@ async def fuck_member(context):
except UserAdminInvalidError: except UserAdminInvalidError:
await context.edit('无管理员权限,停止查询。') await context.edit('无管理员权限,停止查询。')
return return
except ChatAdminRequiredError:
await context.edit('无管理员权限,停止查询。')
return
if msg == 1: if msg == 1:
msg = 0 msg = 0
else: else:
@ -82,13 +84,16 @@ async def fuck_member(context):
# Wait flood secs # Wait flood secs
await context.edit(f'触发 Flood ,暂停 {e.seconds + uniform(0.5, 1.0)} 秒。') await context.edit(f'触发 Flood ,暂停 {e.seconds + uniform(0.5, 1.0)} 秒。')
try: try:
sleep(e.seconds + uniform(0.5, 1.0)) await sleep(e.seconds + uniform(0.5, 1.0))
except Exception as e: except Exception as e:
print(f"Wait flood error: {e}") print(f"Wait flood error: {e}")
return return
except UserAdminInvalidError: except UserAdminInvalidError:
await context.edit('无管理员权限,停止查询。') await context.edit('无管理员权限,停止查询。')
return return
except ChatAdminRequiredError:
await context.edit('无管理员权限,停止查询。')
return
# 每一百人修改一次 # 每一百人修改一次
if members == 100: if members == 100:
members_count += 1 members_count += 1

View File

@ -2,7 +2,7 @@
"list": [ "list": [
{ {
"name": "autorespond", "name": "autorespond",
"version": "0.21", "version": "0.211",
"section": "chat", "section": "chat",
"maintainer": "xtaodada", "maintainer": "xtaodada",
"size": "1.9 kb", "size": "1.9 kb",
@ -292,7 +292,7 @@
}, },
{ {
"name": "neteasedown", "name": "neteasedown",
"version": "1.12", "version": "1.121",
"section": "daily", "section": "daily",
"maintainer": "xtaodada", "maintainer": "xtaodada",
"size": "15.6 kb", "size": "15.6 kb",
@ -492,7 +492,7 @@
}, },
{ {
"name": "rape", "name": "rape",
"version": "1.03", "version": "1.031",
"section": "chat", "section": "chat",
"maintainer": "Pentacene", "maintainer": "Pentacene",
"size": "4.0 kb", "size": "4.0 kb",
@ -582,7 +582,7 @@
}, },
{ {
"name": "bin", "name": "bin",
"version": "1.0", "version": "1.01",
"section": "daily", "section": "daily",
"maintainer": "paulkm", "maintainer": "paulkm",
"size": "1.8 kb", "size": "1.8 kb",
@ -592,7 +592,7 @@
}, },
{ {
"name": "fuckmember", "name": "fuckmember",
"version": "1.03", "version": "1.031",
"section": "daily", "section": "daily",
"maintainer": "xtaodada", "maintainer": "xtaodada",
"size": "3.0 kb", "size": "3.0 kb",
@ -602,7 +602,7 @@
}, },
{ {
"name": "unbanby", "name": "unbanby",
"version": "1.0", "version": "1.01",
"section": "daily", "section": "daily",
"maintainer": "xtaodada", "maintainer": "xtaodada",
"size": "2.8 kb", "size": "2.8 kb",

View File

@ -236,7 +236,7 @@ async def ned(context):
await context.edit("**使用方法:** `-ned` `<关键词/id>`") await context.edit("**使用方法:** `-ned` `<关键词/id>`")
return return
else: else:
if not eyed3_imported and not cc_imported: if not eyed3_imported or not cc_imported:
try: try:
await context.edit("支持库 `eyed3` `PyCryptodome` 未安装...\n正在尝试自动安装...") await context.edit("支持库 `eyed3` `PyCryptodome` 未安装...\n正在尝试自动安装...")
await execute(f'{executable} -m pip install eyed3') await execute(f'{executable} -m pip install eyed3')
@ -254,6 +254,7 @@ async def ned(context):
return return
except: except:
return return
return
type = 'keyword' type = 'keyword'
id = context.parameter[0] id = context.parameter[0]
# 测试是否为 id # 测试是否为 id

View File

@ -9,6 +9,7 @@
from datetime import timedelta from datetime import timedelta
from telethon.tl.types import ChannelParticipantsAdmins from telethon.tl.types import ChannelParticipantsAdmins
from telethon.errors.rpcerrorlist import ChatAdminRequiredError
from pagermaid.listener import listener from pagermaid.listener import listener
from pagermaid.utils import alias_command from pagermaid.utils import alias_command
@ -29,7 +30,15 @@ async def rape(context):
context_last_name = context.sender.last_name context_last_name = context.sender.last_name
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:
user = admins[admins.index(context.sender)]
if not user.participant.admin_rights.ban_users:
await context.edit('无封禁用户权限。')
return
try:
await context.client.kick_participant(context.chat_id, reply.sender.id) await context.client.kick_participant(context.chat_id, reply.sender.id)
except ChatAdminRequiredError:
await context.edit('无管理员权限。')
return
await context.client.send_message( await context.client.send_message(
context.chat_id, context.chat_id,
f'[{reply.sender.first_name} {reply_last_name}](tg://user?id={reply.sender.id}) 已被移出群聊', f'[{reply.sender.first_name} {reply_last_name}](tg://user?id={reply.sender.id}) 已被移出群聊',

View File

@ -1,8 +1,7 @@
from pagermaid.listener import listener from pagermaid.listener import listener
from pagermaid.utils import alias_command from pagermaid.utils import alias_command
from telethon.tl.types import ChannelParticipantsKicked, ChannelParticipantsAdmins from telethon.tl.types import ChannelParticipantsKicked, ChannelParticipantsAdmins
from telethon.errors.rpcerrorlist import UserAdminInvalidError from telethon.errors.rpcerrorlist import UserAdminInvalidError, ChatAdminRequiredError, FloodWaitError
from telethon.errors.rpcerrorlist import FloodWaitError
from asyncio import sleep from asyncio import sleep
from random import uniform from random import uniform
@ -53,6 +52,9 @@ async def unban_by_bot(context):
except UserAdminInvalidError: except UserAdminInvalidError:
await context.edit('无管理员权限,停止查询。') await context.edit('无管理员权限,停止查询。')
return return
except ChatAdminRequiredError:
await context.edit('无管理员权限,停止查询。')
return
# 每一百人修改一次 # 每一百人修改一次
if members == 100: if members == 100:
members_count += 1 members_count += 1