我正在使用一个聊天机器人在lita ruby gem上使用lita-hipchat操作。在使用hipchat向lita做出响应之后,lita将能够通过the reply method向创建响应的用户返回消息。我想要改变这种模式,并能够发送hipchat给第二个用户,本质上是能够将相同的响应抄送或转发给多个用户。是否可以只使用Lita gem?
我知道通过http或hipchat gem发送消息是向二级用户发送消息的另一种选择,但我更喜欢通过lita这样做。
发布于 2019-04-03 20:52:48
您可以使用Robot#send_messages来完成此操作。例如:
def my_handler_route(response)
user2 = Lita::User.find_by_id("user2")
target = Lita::Source(user: user2)
robot.send_message(target, "This message will go to User2!")
end这基本上就是Response#reply正在做的事情--但有了自动定位原始源的便利性。
https://stackoverflow.com/questions/54933424
复制相似问题