#!/usr/bin/env python3 import traceback from time import sleep from mycroft.util.log import LOG from mycroft.util.time import now_local from mycroft.messagebus import MessageBusClient def on_message(message): dt = str(now_local())[:19] print(f"{dt} >> {message}") def main(): sleep(0.5) # Connect to the default websocket used by mycroft-core # TODO arg parse client = MessageBusClient() client.on("message", on_message) client.run_forever() LOG.info('Client stopped.') if __name__ == '__main__': # Run loop trying to reconnect if there are any issues starting # the websocket while True: try: main() except KeyboardInterrupt: break except: traceback.print_exc()