update tutorial

pull/1/head
Mallory Hancock 2017-10-10 08:56:41 -07:00
parent cc17b9ae72
commit 0c7cd1b918
1 changed files with 7 additions and 5 deletions

View File

@ -38,18 +38,20 @@ The function will need to be structured as such:
import pinhook.plugin import pinhook.plugin
@pinhook.plugin.register('!test') @pinhook.plugin.register('!test')
def test_plugin(**kwargs): def test_plugin(msg):
nick = kwargs['nick'] message = '{}: this is a test!'.format(msg.nick)
message = '{}: this is a test!'.format(nick)
return pinhook.plugin.message(message) return pinhook.plugin.message(message)
``` ```
The function will need to accept `**kwargs` in order to gather information from the bot. The function will need to accept a single argument in order to accept a `Message` object from the bot.
Keyword arguments currently passed to the plugin: The `Message` object has the following attributes:
* `cmd`: the command that triggered the function * `cmd`: the command that triggered the function
* `nick`: the user who triggered the command * `nick`: the user who triggered the command
* `arg`: all the trailing text after the command. This is what you will use to get optional information for the command * `arg`: all the trailing text after the command. This is what you will use to get optional information for the command
* `channel`: the channel where the command was initiated
* `ops`: the list of bot operators
* `botnick`: the nickname of the bot
The plugin function **must** return one of the following in order to give a response to the command: The plugin function **must** return one of the following in order to give a response to the command:
* `pinhook.plugin.message`: basic message in channel where command was triggered * `pinhook.plugin.message`: basic message in channel where command was triggered