Remove Cenator :'( sorry to see you go

This commit is contained in:
Kristóf Tóth 2018-03-14 09:25:42 +01:00
parent 3caf170c7d
commit 3e0592c176

View File

@ -1,18 +1,7 @@
from itertools import cycle
from tfw.networking.serialization import deserialize_all from tfw.networking.serialization import deserialize_all
from tfw.networking.event_handlers.server_connector import ServerConnector from tfw.networking.event_handlers.server_connector import ServerConnector
def cenator():
yield from [
'**Your time is up**',
'`My time is now`',
'_You can\'t see me_',
'My time is now'
]
class EventHandlerBase: class EventHandlerBase:
def __init__(self, key): def __init__(self, key):
self.server_connector = ServerConnector() self.server_connector = ServerConnector()
@ -21,13 +10,9 @@ class EventHandlerBase:
self.subscribe(self.key) self.subscribe(self.key)
self.subscribe('reset') self.subscribe('reset')
self.server_connector.register_callback(self.event_handler_callback) self.server_connector.register_callback(self.event_handler_callback)
self.cenerator = cycle(cenator())
def event_handler_callback(self, msg_parts): def event_handler_callback(self, msg_parts):
key, message = deserialize_all(*msg_parts) key, message = deserialize_all(*msg_parts)
from .message_sender import MessageSender
ms = MessageSender()
ms.send('avataobot', next(self.cenerator))
response = self.dispatch_handling(key, message) response = self.dispatch_handling(key, message)
if response is None: return if response is None: return
self.server_connector.send(key, response) self.server_connector.send(key, response)