我们需要一种解决方案来处理成功的购买消息的响应吗?
例如,当购买信息支付正常时,我们如何处理对话?
from balebot.filters.bank_message_filter import BankMessageFilter
class BankMessageFilter(Filter):
def match(self, message):
return isinstance(message, BankMessage)
和此处:BankMessageFilter
然后检查从交易机器人收到的消息以检查交易付款的正确性?
答案 0 :(得分:1)
这是经典的Python BankMessage处理程序。请考虑以下内容:
@dispatcher.message_handler(PhotoFilter())
def purchase_message(bot, update):
message = update.get_effective_message()
user_peer = update.get_effective_user()
first_purchase_message = PurchaseMessage(msg=message, account_number=6037991067471130, amount=100,
money_request_type=MoneyRequestType.normal)
bot.send_message(first_purchase_message, user_peer, success_callback=success, failure_callback=failure)
dispatcher.register_conversation_next_step_handler(update, [MessageHandler(BankMessageFilter(), payment),
MessageHandler(DefaultFilter(), default_handler)])
def payment(bot, update):
message = update.get_effective_message()
print("message:", message)
success_payment = TextMessage("Thanks, your payment was successful")
bot.reply(update, success_payment, success_callback=success, failure_callback=failure)
dispatcher.finish_conversation(update)
BankMessageFilter已在balebot python库中定义。