aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.org39
1 files changed, 39 insertions, 0 deletions
diff --git a/README.org b/README.org
index 18641d4..238e929 100644
--- a/README.org
+++ b/README.org
@@ -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
25To write a new connection protocol you must inherit from
26~warmachine.connections.base.Connection~. This class defines an interface you
27must implement to support the plugins plugins.
28** ~__config_prefix__~
29This global is used to decide which connection to use when it is found in the
30config file. E.g. IRC uses ~'irc'~ and Slack uses ~'slack'~. It should be
31defined somewhere near the top of your file.
32** ~connect()~
33D'bolla uses python 3's asyncio to manage multiple connections concurrently thus
34you should use ~asyncio.open_connection~ to create your connection. Once you
35have successfully connected you must set ~self.status~ to
36~warmachine.connections.base.CONNECTED~. This indicates the connection is ready
37to use.
38** ~read()~
39This method is constantly checked in a loop by the ~Bot~ class. When a message
40is returned it is passed into the ~recv_msg~ method in all loaded plugins. This
41return 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~
51This should return a unique id used to identify this particular connection. As
52an example, the IRC connection uses something like this:
53
54#+BEGIN_SRC python
55@property
56@warmachine.utils.decorators.memoize
57def id(self):
58 from hashlib import md5
59
60 value = '{}-{}'.format(self.host, self.nick)
61 return md5(value.encode()).hexdigest()
62#+END_SRC