echobot.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:TBot8-1 作者: Danzilla-cool 项目源码 文件源码
def main():
    global update_id
    # Telegram Bot Authorization Token
    f = open("../token.txt", "r")
    token = f.readline()
    f.close()
    bot = telegram.Bot(token=token)

    # get the first pending update_id, this is so we can skip over it in case
    # we get an "Unauthorized" exception.
    try:
        update_id = bot.getUpdates()[0].update_id
    except IndexError:
        update_id = None

    logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

    while True:
        try:
            echo(bot)
        except NetworkError:
            sleep(1)
        except Unauthorized:
            # The user has removed or blocked the bot.
            update_id += 1
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号