This commit is contained in:
Thomas Baruchel 2021-05-24 09:30:50 +02:00
parent e9d59bb1c2
commit 37bca69dbf
1 changed files with 1 additions and 1 deletions

View File

@ -29,7 +29,7 @@ At least one relevant client should be already installed on many systems or shel
## Writing the bot
A bot is a Python class which extends the `Bot` class defined at the top of the script. The key idea is that any method whose name starts with `on_` will be detected at run time and mapped to the very same hook at the client level. The `on_msg` will be dynamically mapped to the `^on msg` event in the client (see the example above). Epic5 provides about a hundred of such events; for that reason, names are not hardcoded in the script: again, when at run time a method with a `on_`name is detected, it is assumed the user is aware of the corresponding event in the client. The list of Epic5 events can be found [there](http://www.epicsol.org/help_root), and the list of ircII events can be found [there](http://ircii.warped.com/ircii-current/ircii/help/on/).
A bot is a Python class which extends the `Bot` class defined at the top of the script. The key idea is that any method whose name starts with `on_` will be detected at run time and mapped to the very same hook at the client level. For instance, the `on_msg` in the example above will be dynamically mapped to the `^on msg` event in the client. Epic5 provides about a hundred of such events; for that reason, names are not hardcoded in the script: again, when at run time a method with a `on_` name is detected, it is assumed the user is aware of the corresponding event in the client. The list of Epic5 events can be found [there](http://www.epicsol.org/help_root), and the list of ircII events can be found [there](http://ircii.warped.com/ircii-current/ircii/help/on/).
The number of arguments for each Python method is also dynamically detected at run time by self-inspection. In the example above, it can be seen the the `on_msg` method has two arguments (not counting the initial `self` one); then the low-level Irc string will automatically be splitted into two substrings for calling the method. The number of arguments should match the documentation of the corresponding `^on` events, but using fewer arguments is allowed: if the method has expects a single argument (not counting the `self` one), the full initial string will be used without being additionally splitted.