如何在打包机器人中将消息转发给特定用户?

时间:2018-12-06 19:37:27

标签: python bale-messenger balebot

我该如何转发user_a将漫游器发送给user_b的消息? 换句话说,我该如何使用user_peer发送消息?

def new_message(bot, update):
     user_message_obj = update.get_effective_message()
     a = user_message_obj.text
     name_text = TextMessage(a)
     print("CheckPoint_1")
     peer = Peer(peer_type="User", peer_id="1621113162", access_hash="4481094213533037592")
     bot.send_message(name_text, peer, success_callback=success, failure_callback=failure)
     print("CheckPoint_2")
     message = TextMessage("پیام شما ثبت شد")
     user_peer = update.get_effective_user()
     bot.send_message(message, user_peer, success_callback=success, failure_callback=failure)

1 个答案:

答案 0 :(得分:1)

首先,您需要获取有效的消息。之后,您便可以使用该有效消息将消息发送给其他人。

def new_message(bot, update):
    user_message_obj = update.get_effective_message()
    print("CheckPoint_1")
    peer = Peer(peer_type="User", peer_id="1621113162", access_hash="4481094213533037592")
    bot.send_message(user_message_obj, peer, success_callback=success, failure_callback=failure)
    print("CheckPoint_2")
    message = TextMessage("پیام شما ثبت شد")
    user_peer = update.get_effective_user()
    bot.send_message(message, user_peer, success_callback=success, failure_callback=failure)