FeedbackBot.py 文件源码

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

项目:TelegramBots 作者: d-qoi 项目源码 文件源码
def updateChatList(bot, job):
    logger.debug("-----------------------updatedChatList--------------------")
    logger.info("Updating the chat list")
    results = MDB.groups.find()
    for doc in results:
        try:
            chat = bot.getChat(chat_id = doc['_id'])
            logger.info("Chat %s (%s) responded." % (chat.title, chat.id))
            admins = [chatmember.user.id for chatmember in bot.getChatAdministrators(chat_id=doc['_id'])]
            MDB.groups.find_one_and_update({'_id':doc['_id']},
                                           { '$set' : {'title':chat.title, "admins":admins}})
        except TelegramError as te:
            logger.warning("Removing %s (%s) from the database, it is not responding, re-add the bot if this is incorrect." % (doc['title'],doc['_id']))
            logger.debug("Error received: %s" % (str(te)))
            MDB.groups.remove({'_id':doc['_id']})

        except:
            logger.info("Other error when checking %s (%s), check networking" % (doc['title'],doc['_id']))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号