You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Being able to manipulate the existing commands is something that has been requested quite a few times already.
The main question being: "How can I disable all integrated commands?".
Currently, the easiest solution is to create dummy commands that aren't enabled, and thus aren't available to the bot.
For this reason it would be very helpful to have a dedicated TelegramBotCommands class that handles all things commands (in the same way that TelegramBotLog handles all log related functionality).
This will allow a user to easily add/remove custom or internal commands to their bot.
Let's bring together some ideas how we could make this easy for the users to make use of!
Without delving too deep into how this can be implemented, something like this would be the idea:
// Like the Logger, the Commander is now a singleton with static methods.
TelegramBotCommander::addCustomPath('/path/to/custom/commands');
// Here we pass a callback that returns an array of the available commands.
TelegramBotCommander::filterCommands('command_filter_callback');
// In our callback we can easily choose which custom commands are enabled.// Example 1: remove 'whoami', 'echo' and 'weather' commands.functioncommand_filter_callback($commands)
{
foreach(['whoami', 'echo', 'weather'] as$command) {
unset($commands[$command]);
}
return$commands;
}
// Example 2: only enable 'help' and 'whoami' commands.functioncommand_filter_callback($commands)
{
return ['help', 'whoami'];
}
NOTE!: This is just a rough pseudo code example. It will become more complex than this, as we will also have to account for System and Admin commands in some way.
(Maybe we could also implement different user rights, but I think that's for some time in the future)
The text was updated successfully, but these errors were encountered:
Being able to manipulate the existing commands is something that has been requested quite a few times already.
The main question being: "How can I disable all integrated commands?".
Currently, the easiest solution is to create dummy commands that aren't enabled, and thus aren't available to the bot.
For this reason it would be very helpful to have a dedicated
TelegramBotCommands
class that handles all things commands (in the same way thatTelegramBotLog
handles all log related functionality).This will allow a user to easily add/remove custom or internal commands to their bot.
Let's bring together some ideas how we could make this easy for the users to make use of!
Without delving too deep into how this can be implemented, something like this would be the idea:
NOTE!: This is just a rough pseudo code example. It will become more complex than this, as we will also have to account for System and Admin commands in some way.
(Maybe we could also implement different user rights, but I think that's for some time in the future)
The text was updated successfully, but these errors were encountered: