FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: refresh platform commands after command changes by casama233 · Pull Request #9685 · AstrBotDevs/AstrBot · GitHub

fix: refresh platform commands after command changes - #9685

Open
casama233 wants to merge 1 commit into
AstrBotDevs:masterfrom
casama233:agent/refresh-platform-commands
Open

fix: refresh platform commands after command changes#9685
casama233 wants to merge 1 commit into
AstrBotDevs:masterfrom
casama233:agent/refresh-platform-commands

Conversation

casama233 commented Aug 14, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Follow-up to #4485.

#4485 correctly made Telegram and Discord skip disabled handlers when platform commands are collected, but runtime changes from Dashboard → Plugins → Manage Behaviors do not currently trigger a platform command re-sync. As a result, disabling or renaming commands updates AstrBot's runtime state while already-registered native commands can remain stale on the platform. This is especially problematic near platform command-count limits because disabling commands does not promptly free those native command slots.

Modifications / 改动点

  • Add a default no-op Platform.refresh_registered_commands() hook so adapters that expose native commands can opt into runtime refresh without platform-specific conditionals in the dashboard service.
  • Refresh platform-native command registrations after a command is successfully enabled/disabled or renamed.
  • Discord:
    • replace only AstrBot-managed application commands before syncing;
    • serialize command refreshes with a lock;
    • roll back the managed local registry if synchronization fails;
    • pass the configured debug guild through check_guilds so stale guild commands can also be removed when the desired command set becomes empty;
    • preserve the existing daily application-command quota handling (30034).
  • Telegram:
    • refresh native commands for a running application after command-management changes;
    • delete stale platform commands when the desired command set becomes empty;
    • update the command hash only after the platform update succeeds so failed updates remain retryable.
  • Add regression coverage for command toggle/rename refresh, Discord disable/removal and rollback behavior, debug-guild empty-set synchronization, and Telegram empty-command cleanup/runtime refresh.

This is intentionally limited to the adapters that currently expose AstrBot-managed native command registration (Discord and Telegram). Other adapters inherit the no-op hook.

This is not a duplicate of #4485:

Screenshots or Test Results / 运行截图或测试结果

Verification on the final PR commit:

  • Code Format Check ✅
  • Unit Tests ✅
  • Smoke Test ✅
  • AstrBot Dashboard CI ✅
  • CodeQL ✅

The regression tests added in this PR cover:

  • command toggle and rename refreshing platform commands;
  • Discord removing a command after its handler is disabled;
  • Discord debug-guild empty-set synchronization;
  • Discord local-registry rollback on synchronization failure;
  • Telegram deleting stale commands when the desired set becomes empty;
  • Telegram refresh only running for a started, command-registration-enabled adapter.

Checklist / 检查清单

casama233 force-pushed the agent/refresh-platform-commands branch from 21ecf35 to 60880dc Compare August 14, 2026 12:40
casama233 marked this pull request as ready for review August 14, 2026 12:44
dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. area:platform The bug / feature is about IM platform adapter, such as QQ, Lark, Telegram, WebChat and so on. labels Aug 14, 2026

sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨ Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

casama233 force-pushed the agent/refresh-platform-commands branch from e2a7ebc to 67a6d70 Compare August 14, 2026 13:14
casama233 force-pushed the agent/refresh-platform-commands branch from 67a6d70 to bbe3ffc Compare August 14, 2026 13:16
casama233 changed the title fix(command-management): refresh platform commands after command changes fix: refresh platform commands after command changes Aug 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:platform The bug / feature is about IM platform adapter, such as QQ, Lark, Telegram, WebChat and so on. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL