blob: 4df5996a58bb8efa242696cbaece6541cbe18745 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
INITALIZED = 'Initalized'
CONNECTED = 'Connected'
class Connection(object):
def connect(self, *args, **kwargs):
"""
This is called by the main start method. It should prepare your
Connection and connect.
"""
raise NotImplementedError('{} must implement `connect` method'.format(
self.__class__.__name__))
def read(self):
"""
Dictionary of data in the following format:
{
'sender': 'username/id',
'channel': 'channel name' or None,
'message': 'actual message',
}
Returns:
dict: Data from the connection that the bot should consider.
"""
raise NotImplementedError('{} must implement `read` method'.format(
self.__class__.__name__))
def get_users_by_channel(self, channel):
"""
Return a list of users who are in the provided channel
"""
raise NotImplementedError('{} must implement `get_users_by_channel` '
'method'.format(self.__class__.__name__))
def id(self):
"""
Unique ID for this connection. Since there can be more than one
connection it should be unique per actual connection to the server. For
example `bot nickname` + `server host:port`. This is used to store
settings and other information.
Returns:
str: Unique ID for this connection object
"""
raise NotImplementedError('{} must implement `id` method'.format(
self.__class__.__name__))
|