diff --git a/src/demo/event_handler_main.py b/src/demo/event_handler_main.py index 6cb9c8a..69d2fd8 100644 --- a/src/demo/event_handler_main.py +++ b/src/demo/event_handler_main.py @@ -4,14 +4,21 @@ from tfw.components.source_code_event_handler import SourceCodeEventHandler from tfw.components.terminado_event_handler import TerminadoEventHandler from tfw.components.process_managing_event_handler import ProcessManagingEventHandler from tfw.config import tfwenv +from tfw.message_sender import MessageSender from tfw.config.logs import logging log = logging.getLogger(__name__) +def cenator(history): + message_sender = MessageSender() + log.debug('User executed command: "{}"'.format(history[-1])) + message_sender.send('JOHN CENA', 'You\'ve executed "{}"'.format(history[-1])) + + if __name__ == '__main__': ide = SourceCodeEventHandler(key='webide', directory=tfwenv.WEBIDE_WD, exclude=['__pycache__']) terminado = TerminadoEventHandler(key='shell') - terminado.historymonitor.subscribe_callback(callback=lambda hist: log.debug('User executed command: "{}"'.format(hist[-1]))) + terminado.historymonitor.subscribe_callback(cenator) processmanager = ProcessManagingEventHandler(key='processmanager', dirmonitor=ide.monitor) eventhandlers = {ide, terminado, processmanager}