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