Python telepot 模块,loop() 实例源码

我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用telepot.loop()

项目:SmartSlam    作者:Oneiroe    | 项目源码 | 文件源码
def main():
    # LOG setup
    os.chdir(os.path.join(os.path.abspath(os.sep), 'home', OS_USER, 'SmartSlam', 'ManagementTelegramBOT'))
    log_dir = os.path.join(os.getcwd(), 'LOG')
    if not os.path.exists(log_dir):
        os.makedirs(log_dir)
    logging.basicConfig(filename=os.path.join(log_dir, 'INFO.log'),
                        level=logging.INFO,
                        format='%(asctime)-15s '
                               '%(levelname)s '
                               '--%(filename)s-- '
                               '%(message)s')

    # BOT
    logging.info('Setting up Bot...')

    wake_up_msg = wake_up()
    for client in data['known_clients']:
        bot.sendMessage(client, wake_up_msg)

    for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]:
        signal.signal(sig, signal_handler)

    # STARTING WAITING CYCLE
    logging.info('STARTING LISTENING loop')

    MessageLoop(bot, {'chat': handle,
                      'callback_query': on_callback}).run_as_thread()
    while 1:
        time.sleep(10)