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
评论列表
文章目录