mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-24 19:52:53 +01:00
writing-plugins: briefly mention log, world, irc.connected, and useful builtin modules
Closes #522.
This commit is contained in:
parent
e340f6e9a2
commit
420f523dfd
@ -80,3 +80,21 @@ The following functions can also be defined in the body of a plugin to hook onto
|
||||
|
||||
`main(irc=None)`: Called on plugin load. `irc` is only defined when the plugin is being reloaded from a network: otherwise, it means that PyLink has just been started.
|
||||
`die(irc=None)`: Called on plugin unload or daemon shutdown. `irc` is only defined when the shutdown or unload was called from an IRC network.
|
||||
|
||||
## Other tips
|
||||
|
||||
### Logging
|
||||
|
||||
Use PyLink's [global logger](https://docs.python.org/3/library/logging.html) (`from pylinkirc.log import log`) instead of print statements.
|
||||
|
||||
### Some useful attributes
|
||||
|
||||
- **`world.networkobjects`** provides a dict mapping network names (case sensitive) to their corresponding network objects/protocol module instances.
|
||||
- **`irc.connected` is a [`threading.Event()`](https://docs.python.org/3/library/threading.html#event-objects) object that is set when a network finishes bursting.
|
||||
- **`world.started` is a [`threading.Event()`](https://docs.python.org/3/library/threading.html#event-objects) object that is set when all networks have been initialized.
|
||||
- **`world.plugins` provides a dict mapping loaded plugins' names (case sensitive) to their module objects. This is the preferred way to call another plugins's methods if need be (while of course, forcing you to check whether the other plugin is already loaded).
|
||||
- **`world.services` provides a dict mapping service bot names to their `utils.ServiceBot` instances.
|
||||
|
||||
### Useful modules
|
||||
|
||||
`classes.py`, `utils.py` and `structures.py` all provide a ton of public methods which aren't documented here for conciseness. In `classes.py`, `PyLinkNetworkCore` and `PyLinkNetworkCoreUtils` (which all protocol modules inherit from) are where many utility and state-checking functions sit.
|
||||
|
Loading…
Reference in New Issue
Block a user