bankex.py 文件源码

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

项目:bankex-bot 作者: BankEx 项目源码 文件源码
def _show_item(self, **kwargs):
        if self.user.offset < 0:
            self.send(self.t('NO_PREV'))
            return False

        condition = Q(bc_hash__ne=None) & \
                    Q(type=self.user.filter_buy_type)
        # Q(price__lte=self.user.filter_price)

        offers = Offer.objects(condition) \
            .skip(self.user.offset) \
            .limit(1)

        offer = None
        for item in offers:
            offer = item
            break

        if offer is None:
            self.send(self.t('NO_MORE'))
            return False

        try:
            path = offer.get_image_path(self.user.lang)
            if not path:
                raise Exception
            with open(path, 'rb') as f:
                inline_keyboard = InlineKeyboard(keyboard=[
                    [InlineKeyboardButton(text=self.t('BUY_CONTRACT'), callback_data=offer.get_id())]
                ])
                self.send_photo(
                    files=(('photo', path, f.read()),),
                    reply_markup=inline_keyboard
                )
        except Exception:
            if options.debug:
                traceback.print_exc()
            self.logger.error(offer.get_id())
            self.send(self.t('IMAGE_NOT_FOUND'))

        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号