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

Better structure for commands #18

Open
amadeous opened this issue Feb 25, 2024 · 1 comment
Open

Better structure for commands #18

amadeous opened this issue Feb 25, 2024 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@amadeous
Copy link
Contributor

amadeous commented Feb 25, 2024

All the commands are currently defined in a single file (bot.ts), which is not modular and makes it hard to keep up. The definition of the commands should be splitted in multiple files in the commands folder. Commands should exhibit a similar interface.
Common mother class should specify

  • name, description, usage
  • if command is private only or not
  • have a method to check the validity of the request
  • have a method to process the request

Ideally, a mother class should define additional pre-operations and post-operations to be performed before and after the processing of the command (to allow to filter users or validate parameters).

@amadeous amadeous added enhancement New feature or request help wanted Extra attention is needed labels Feb 25, 2024
@amadeous
Copy link
Contributor Author

Could use Inversify and extract each command behaviour in a dedicated Command class.
The Telegram bot would only register commands and provides it a way to communicate with the outside.

This way, it makes it easier to add a new command (simply add the related Command class and register it as a command for the bot) or to add a new platform (other than Telegram), since the separation between the commands and the bots is more clear. It would simply require to define a new service (as for Telegram) and register the commands on it (of course, a dedicated user class should be done, linked to the existing wallets).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant