Initial structure and a simple handler
The structure of the module was described in the previous section. Now let's move on to its creation!
Last updated
The structure of the module was described in the previous section. Now let's move on to its creation!
Last updated
Check out the first, this only describes the specifics of writing for PBModular!
Following the example from the previous section, create the module directory. Now we need to write a command, let it be /hello
. Let the bot respond "Hello World" to this command.
Fine. However, the bot doesn't know that this command is declared, the function needs to be registered as a command handler. This is done by using one of 3 decorators that let the module class know that this method is a command handler: @command
, @callback_query
, @message
.
The @command
decorator takes as arguments a list or a single command to which the bot will respond, and an optional The @callback_query
is for handling button events, @message
is for handling any messages. The Pyrogram filter is accepted in the arguments, even though it is optional, it is highly recommended to install it!
So, we import the @command
decorator from base.module
, and use it!