diff options
| author | jason | 2016-07-29 11:58:33 -0600 |
|---|---|---|
| committer | jason | 2016-07-29 12:02:46 -0600 |
| commit | 6c36d2c2f8e8a58e9db8fe1d29a53a95c89c6879 (patch) | |
| tree | 05ed5d6681726bbd4a962a028d2fea53aa564ed8 /warmachine/connections/base.py | |
| download | warmachine-ng-6c36d2c2f8e8a58e9db8fe1d29a53a95c89c6879.tar.gz warmachine-ng-6c36d2c2f8e8a58e9db8fe1d29a53a95c89c6879.zip | |
Initial commit
Diffstat (limited to 'warmachine/connections/base.py')
| -rw-r--r-- | warmachine/connections/base.py | 40 |
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 @@ | |||
| 1 | INITALIZED = 'Initalized' | ||
| 2 | CONNECTED = 'Connected' | ||
| 3 | |||
| 4 | |||
| 5 | class 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__)) | ||