Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default command handler overshadowing every other scope #49

Closed
carafelix opened this issue Nov 6, 2024 · 1 comment · Fixed by #50 or #51
Closed

Default command handler overshadowing every other scope #49

carafelix opened this issue Nov 6, 2024 · 1 comment · Fixed by #50 or #51

Comments

@carafelix
Copy link
Member

Creating and registering a command with a default handler will always overshadow any other scope. In the following snippet, even when conditions are met (e.g: being admin in a group chat), the response will always be "hello from default scope".

myCommands
  .command(
    "default",
    "Default command",
    (ctx) => ctx.reply("Hello from default scope"),
  )
  .addToScope(
    { type: "all_chat_administrators" },
    (ctx) => ctx.reply("Hello, admin!"),
  )
  .addToScope(
    { type: "all_group_chats" },
    (ctx) => ctx.reply("Hello, group chat!"),
  );

The order of .addToScope registration should affect indeed the handling priority, while the default handler should always be last.

@carafelix
Copy link
Member Author

carafelix commented Nov 8, 2024

marked as completed from merging #51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants