__init__.py 文件源码

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

项目:ehForwarderBot 作者: blueset 项目源码 文件源码
def msg(self, bot, update):
        """
        Process, wrap and deliver messages from user.

        Args:
            bot: Telegram Bot instance
            update: Message update
        """
        self.logger.debug("----\nMsg from tg user:\n%s", update.message.to_dict())
        multi_slaves = False

        if update.message.chat.id != update.message.from_user.id:  # from group
            assocs = db.get_chat_assoc(master_uid="%s.%s" % (self.channel_id, update.message.chat.id))
            if len(assocs) > 1:
                multi_slaves = True

        reply_to = bool(getattr(update.message, "reply_to_message", None))
        private_chat = update.message.chat.id == update.message.from_user.id

        if (private_chat or multi_slaves) and not reply_to:
            candidates = db.get_recent_slave_chats(update.message.chat.id) or\
                         db.get_chat_assoc(master_uid="%s.%s" % (self.channel_id, update.message.chat.id))[:5]
            if candidates:
                tg_err_msg = update.message.reply_text("Error: No recipient specified.\n"
                                                       "Please reply to a previous message.", quote=True)
                storage_id = "%s.%s" % (update.message.chat.id, tg_err_msg.message_id)
                legends, buttons = self.slave_chats_pagination(storage_id, 0, fchats=candidates)
                tg_err_msg.edit_text("Error: No recipient specified.\n"
                                     "Please reply to a previous message, "
                                     "or choose a recipient:\n\nLegend:\n" + "\n".join(legends),
                                     reply_markup=telegram.InlineKeyboardMarkup(buttons))
                self.msg_status[storage_id] = Flags.SUGGEST_RECIPIENT
                self.msg_storage[storage_id]["update"] = update.to_dict()
            else:
                update.message.reply_text("Error: No recipient specified.\n"
                                          "Please reply to a previous message.", quote=True)
        else:
            return self.process_telegram_message(bot, update)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号