aboutsummaryrefslogtreecommitdiffstats
path: root/README.org
diff options
context:
space:
mode:
Diffstat (limited to 'README.org')
-rw-r--r--README.org17
1 files changed, 11 insertions, 6 deletions
diff --git a/README.org b/README.org
index 4d8bf43..b317e13 100644
--- a/README.org
+++ b/README.org
@@ -30,6 +30,8 @@ you must call ~super()~.
30** ~self._loop~ 30** ~self._loop~
31This is given to you access to the asyncio loop. This is useful for scheduling 31This is given to you access to the asyncio loop. This is useful for scheduling
32tasks to be run later. 32tasks to be run later.
33** ~self.config_dir~
34The directory to store any configuration files and other junk in.
33** ~self.log~ 35** ~self.log~
34This is a logger that you should use when logging messages. 36This is a logger that you should use when logging messages.
35** ~recv_msg(channel, message)~ 37** ~recv_msg(channel, message)~
@@ -76,18 +78,21 @@ you may want to do such as create configuration files that don't exist yet.
76* Writing a Connection 78* Writing a Connection
77To write a new connection protocol you must inherit from 79To write a new connection protocol you must inherit from
78~warmachine.connections.base.Connection~. This class defines an interface you 80~warmachine.connections.base.Connection~. This class defines an interface you
79must implement to support the plugins. 81must implement to support the plugins. If you override ~__init__~ you must call
82~super()~.
80** ~__config_prefix__~ 83** ~__config_prefix__~
81This global is used to decide which connection to use when it is found in the 84This global is used to decide which connection to use when it is found in the
82config file. E.g. IRC uses ~'irc'~ and Slack uses ~'slack'~. It should be 85config file. E.g. IRC uses ~'irc'~ and Slack uses ~'slack'~. It should be
83defined somewhere near the top of your file. 86defined somewhere near the top of your file.
84** ~connect()~ 87** ~self.config_dir~
88The directory to store any configuration files and other junk in.
89** ~self.connect()~
85D'bolla uses python 3's asyncio to manage multiple connections concurrently thus 90D'bolla uses python 3's asyncio to manage multiple connections concurrently thus
86you should use ~asyncio.open_connection~ to create your connection. Once you 91you should use ~asyncio.open_connection~ to create your connection. Once you
87have successfully connected you must set ~self.status~ to 92have successfully connected you must set ~self.status~ to
88~warmachine.connections.base.CONNECTED~. This indicates the connection is ready 93~warmachine.connections.base.CONNECTED~. This indicates the connection is ready
89to use. 94to use.
90** ~read()~ 95** ~self.read()~
91This method is constantly checked in a loop by the ~Bot~ class. When a message 96This method is constantly checked in a loop by the ~Bot~ class. When a message
92is returned it is passed into the ~recv_msg~ method in all loaded plugins. This 97is returned it is passed into the ~recv_msg~ method in all loaded plugins. This
93return value should be formatted in the following format: 98return value should be formatted in the following format:
@@ -99,9 +104,9 @@ return value should be formatted in the following format:
99 'message': 'The message that was received', 104 'message': 'The message that was received',
100} 105}
101#+END_SRC 106#+END_SRC
102** ~say(message, destination)~ 107** ~self.say(message, destination)~
103This method is used by plugins to send a message to a channel or user. 108This method is used by plugins to send a message to a channel or user.
104** ~id~ 109** ~self.id~
105This should return a unique id used to identify this particular connection. This 110This should return a unique id used to identify this particular connection. This
106is used by plugins when saving state. As an example, the IRC connection uses 111is used by plugins when saving state. As an example, the IRC connection uses
107something like this: 112something like this:
@@ -115,6 +120,6 @@ def id(self):
115 value = '{}-{}'.format(self.host, self.nick) 120 value = '{}-{}'.format(self.host, self.nick)
116 return md5(value.encode()).hexdigest() 121 return md5(value.encode()).hexdigest()
117#+END_SRC 122#+END_SRC
118** ~get_users_by_channel(channel)~ 123** ~self.get_users_by_channel(channel)~
119This method should return a list of all users (including the bot) for the 124This method should return a list of all users (including the bot) for the
120connection. 125connection.