3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 03:29:28 +01:00

writing-plugins.md: mention that IRCParser is a 1.2+ feature

This commit is contained in:
James Lu 2017-03-12 20:37:53 -07:00 committed by GitHub
parent 8c4a13fdf0
commit c8f945d40f

View File

@ -38,13 +38,10 @@ Each command function takes 3 arguments: `irc, source, args`.
- **source**: The numeric of the sender. This will usually be a UID (for users) or a SID (for server). - **source**: The numeric of the sender. This will usually be a UID (for users) or a SID (for server).
- **args**: A `list` of space-separated command arguments (excluding the command name) that the command was called with. For example, `/msg PyLink hello world 1234` would give an `args` list of `['world', '1234']` - **args**: A `list` of space-separated command arguments (excluding the command name) that the command was called with. For example, `/msg PyLink hello world 1234` would give an `args` list of `['world', '1234']`
With the inclusion of argparse. PyLink is able to parse arguments two ways. You can either use argparse and be really fancy with your argument parsing, or you can do your own parsing just by using the regular `args` list. As of PyLink 1.2, there are two ways for a plugin to parse arguments: as a raw list of strings, or with `utils.IRCParser` (an [argparse](https://docs.python.org/3/library/argparse.html) wrapper). More information on using `utils.IRCParser()` can be found in the page ["using IRCParser"](using-ircparser.md).
More information on using `utils.IRCParser()` can be found in
[using IRCParser](using-ircparser.md)
Command handlers do not return anything and can raise exceptions, which are caught by the core and automatically return an error message. Command handlers do not return anything and can raise exceptions, which are caught by the core and automatically return an error message.
## Sending data to IRC ## Sending data to IRC
Plugins receive data from the underlying protocol module, and communicate back using outgoing [command functions](pmodule-spec.md) implemented by the protocol module. They should *never* send raw data directly back to IRC, because that wouldn't be portable across different IRCds. Plugins receive data from the underlying protocol module, and communicate back using outgoing [command functions](pmodule-spec.md) implemented by the protocol module. They should *never* send raw data directly back to IRC, because that wouldn't be portable across different IRCds.