From daa43b74fef955ba93f39e0ffade9995a43de105 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Fri, 28 Jan 2022 00:51:01 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20cannot=20parse=20@username?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci.py | 3 ++- plugins/process.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ci.py b/ci.py index 6374ba7..ac5b288 100644 --- a/ci.py +++ b/ci.py @@ -1,7 +1,7 @@ from configparser import RawConfigParser from pyrogram import Client from apscheduler.schedulers.asyncio import AsyncIOScheduler -from httpx import AsyncClient +from httpx import AsyncClient, get # 读取配置文件 config = RawConfigParser() config.read("config.ini") @@ -15,6 +15,7 @@ headers = { "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36" } client = AsyncClient(timeout=10.0, headers=headers) +me = get(f"https://api.telegram.org/bot{bot_token}/getme").json() # 初始化客户端 scheduler = AsyncIOScheduler() if not scheduler.running: diff --git a/plugins/process.py b/plugins/process.py index 7146e84..c5f04bf 100644 --- a/plugins/process.py +++ b/plugins/process.py @@ -6,6 +6,7 @@ from pyrogram import Client, emoji from pyrogram.types import Message, InlineQuery, CallbackQuery from pyrogram import filters as Filters +from ci import me from plugins.enemies import enemies_msg from plugins.mys2 import mys2_msg, mys2_qun_msg from plugins.start import welcome_command, ping_command, help_command, leave_command, help_callback @@ -118,7 +119,7 @@ async def process_group_msg(client: Client, message: Message): text = message.text msg_list = text.split(' ') # 帮助消息 - if msg_list[0] == '/help': + if msg_list[0] == '/help' or msg_list[0] == f'/help@{me["result"]["username"]}': await help_command(client, message) # # 武器查询 if text.startswith('武器查询') or text.startswith('武器资料'):