diff options
| author | jason | 2016-08-11 13:20:19 -0600 |
|---|---|---|
| committer | jason | 2016-08-11 13:35:41 -0600 |
| commit | 1c123d6f199e1d0b88019d56a4bb1da082bdc79f (patch) | |
| tree | 34aa66de8726d52c3793859c89a237e8d9da1a64 | |
| parent | 0869a7f4d57b592058ca907b7d92cc5d4b7e77e3 (diff) | |
| download | warmachine-ng-1c123d6f199e1d0b88019d56a4bb1da082bdc79f.tar.gz warmachine-ng-1c123d6f199e1d0b88019d56a4bb1da082bdc79f.zip | |
read me updates
| -rw-r--r-- | README.org | 39 |
1 files changed, 39 insertions, 0 deletions
| @@ -21,3 +21,42 @@ Simply run the command: | |||
| 21 | #+END_SRC | 21 | #+END_SRC |
| 22 | 22 | ||
| 23 | * Writing a Plugin | 23 | * Writing a Plugin |
| 24 | * Writing a Connection | ||
| 25 | To write a new connection protocol you must inherit from | ||
| 26 | ~warmachine.connections.base.Connection~. This class defines an interface you | ||
| 27 | must implement to support the plugins plugins. | ||
| 28 | ** ~__config_prefix__~ | ||
| 29 | This global is used to decide which connection to use when it is found in the | ||
| 30 | config file. E.g. IRC uses ~'irc'~ and Slack uses ~'slack'~. It should be | ||
| 31 | defined somewhere near the top of your file. | ||
| 32 | ** ~connect()~ | ||
| 33 | D'bolla uses python 3's asyncio to manage multiple connections concurrently thus | ||
| 34 | you should use ~asyncio.open_connection~ to create your connection. Once you | ||
| 35 | have successfully connected you must set ~self.status~ to | ||
| 36 | ~warmachine.connections.base.CONNECTED~. This indicates the connection is ready | ||
| 37 | to use. | ||
| 38 | ** ~read()~ | ||
| 39 | This method is constantly checked in a loop by the ~Bot~ class. When a message | ||
| 40 | is returned it is passed into the ~recv_msg~ method in all loaded plugins. This | ||
| 41 | return value should be formatted in the following format: | ||
| 42 | |||
| 43 | #+BEGIN_SRC python | ||
| 44 | { | ||
| 45 | 'sender': 'sender nickname', | ||
| 46 | 'channel': '#channel_name or None for private messages', | ||
| 47 | 'message': 'The message that was received', | ||
| 48 | } | ||
| 49 | #+END_SRC | ||
| 50 | ** ~id~ | ||
| 51 | This should return a unique id used to identify this particular connection. As | ||
| 52 | an example, the IRC connection uses something like this: | ||
| 53 | |||
| 54 | #+BEGIN_SRC python | ||
| 55 | @property | ||
| 56 | @warmachine.utils.decorators.memoize | ||
| 57 | def id(self): | ||
| 58 | from hashlib import md5 | ||
| 59 | |||
| 60 | value = '{}-{}'.format(self.host, self.nick) | ||
| 61 | return md5(value.encode()).hexdigest() | ||
| 62 | #+END_SRC | ||