Skip to content

Commit 11a8421

Browse files
committed
fix: command_tree is not defined
1 parent 65d9d86 commit 11a8421

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

telegram_chat/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ async def on_load(server: PluginServerInterface, old):
3333
"""
3434
插件加载操作
3535
"""
36+
global command_tree
37+
command_tree = register_commands()
3638

3739
ConfigManager.load_data(server)
3840

@@ -48,7 +50,7 @@ async def action(event: Update, context: ContextTypes.DEFAULT_TYPE):
4850
ConfigManager.bot.start(True)
4951

5052
ConfigManager.logger = server.logger
51-
register_commands()
53+
5254

5355
server.register_help_message("!!tg", "向 Telegram 群聊发送聊天信息")
5456
server.register_command(

telegram_chat/commands/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ def register_commands():
1111
"""
1212
注册命令树
1313
"""
14-
global command_tree
15-
1614
def run_command(command, need_admin: bool = False):
1715
async def _run(server, event, context, _, type):
1816
if not need_admin or type == MessageType.ADMIN:
@@ -68,4 +66,6 @@ async def _run(server, event, context, _, type):
6866

6967
# /bot-
7068
command_tree.add_command(re.compile(r'/bot-ban (\d*)'), [int], user.bot_ban)
71-
command_tree.add_command(re.compile(r'/bot-pardon (\d*)'), [int], user.bot_pardon)
69+
command_tree.add_command(re.compile(r'/bot-pardon (\d*)'), [int], user.bot_pardon)
70+
71+
return command_tree

0 commit comments

Comments
 (0)