Exemplo n.º 1
0
def main():
    config = ConfigParser()
    config.read("config.ini")

    # Enable logging
    logging.basicConfig(filename='app.log',
                        filemode='w',
                        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
                        level=logging.INFO)

    spotify_remote = SpotifyRemote(
        config.get("SPOTIFY", "CLIENT_ID"),
        config.get("SPOTIFY", "CLIENT_SECRET"),
        config.get("SPOTIFY", "USERNAME"),
    )

    personal_message_handler = PersonalMessageHandler()
    locations_handler = LocationsHandler()

    bot = TelegramBot(config.get("TELEGRAM", "TOKEN"),
                      spotify_remote, personal_message_handler, locations_handler)
    bot.start_bot()
    try:
        while not sleep(1):
            pass
    except KeyboardInterrupt:
        pass
    bot.stop_bot()
def main():
    config = configparser.ConfigParser()
    config.read("config.ini")

    DIR = config.get("LOCAL_STORAGE", "dir")
    if not os.path.exists(DIR):
        os.makedirs(DIR)

    chatbot = TelegramBot()
    chatbot.start_bot()
    procs = [
        Process(target=p, args=[chatbot])
        for p in [weekly_results_process, live_updates_process]
    ]
    [p.start() for p in procs]

    try:
        while not sleep(1):
            pass
    except KeyboardInterrupt:
        [p.kill() for p in procs]
        chatbot.stop_bot()
        raise SystemExit