aboutsummaryrefslogtreecommitdiffstats
path: root/warmachine/connections/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'warmachine/connections/base.py')
-rw-r--r--warmachine/connections/base.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/warmachine/connections/base.py b/warmachine/connections/base.py
new file mode 100644
index 0000000..e68e9b9
--- /dev/null
+++ b/warmachine/connections/base.py
@@ -0,0 +1,40 @@
1INITALIZED = 'Initalized'
2CONNECTED = 'Connected'
3
4
5class Connection(object):
6 def connect(self, *args, **kwargs):
7 """
8 This is called by the main start method. It should prepare your
9 Connection and connect.
10 """
11 raise NotImplementedError('{} must implement `connect` method'.format(
12 self.__class__.__name__))
13
14 def read(self):
15 """
16 Dictionary of data in the following format:
17 {
18 'sender': 'username/id',
19 'channel': 'channel name' or None,
20 'message': 'actual message',
21 }
22
23 Returns:
24 dict: Data from the connection that the bot should consider.
25 """
26 raise NotImplementedError('{} must implement `read` method'.format(
27 self.__class__.__name__))
28
29 def id(self):
30 """
31 Unique ID for this connection. Since there can be more than one
32 connection it should be unique per actual connection to the server. For
33 example `bot nickname` + `server host:port`. This is used to store
34 settings and other information.
35
36 Returns:
37 str: Unique ID for this connection object
38 """
39 raise NotImplementedError('{} must implement `id` method'.format(
40 self.__class__.__name__))