我创建了一个带有按钮和 onClick 操作的卡片,该卡片成功向我的客户发送了类型为“CARD_CLICKED”的消息。
当我尝试使用“NEW_MESSAGE”或“UPDATE_MESSAGE”类型的消息响应此消息时,该消息将显示为新消息,而 API 会尝试 3 次将该 CARD_CLICKED 事件发送到我的机器人,直到它放弃视觉错误:“无法联系 [机器人]。稍后重试。”
我想这类似于
- 使用发布/订阅时交互按钮无法正常工作 https://stackoverflow.com/questions/49785504/interactive-button-doesnt-work-properly-when-using-pub-sub
- 互动卡环聊 Api https://stackoverflow.com/questions/51631989/interactive-cards-hangout-chat-api
但我正在使用 golang 客户端,这些问题的答案对我没有帮助......
我响应“CARD_CLICKED”消息的代码:
func handleClick(message *chat.DeprecatedEvent) *chat.Message {
log.Debugf("User %s instructed me to execute %s", message.User.DisplayName, message.Action.ActionMethodName)
response := &chat.Message{
ActionResponse: &chat.ActionResponse{Type: "UPDATE_MESSAGE"},
Thread: &chat.Thread{Name: message.Message.Thread.Name},
Space: &chat.Space{Name: message.Message.Space.Name, Type: message.Message.Space.Type},
Text: "CARD CLICKED!",
}
return response
}
我的代码基于这个项目:https://github.com/jforman/hangbot https://github.com/jforman/hangbot
找出主要问题是什么...我正在调用 .Create() 函数 - 它创建了一条新消息,因此 - 即使操作响应设置正确 - 这也没有被解释为对单击事件的响应:https://github.com/jforman/hangbot/blob/master/hangbot.go#L79 https://github.com/jforman/hangbot/blob/master/hangbot.go#L79
当我切换到调用 .Update() 后,聊天将不再显示有关我的机器人的“无法联系”消息。
剩下的就是点击事件了still发送给我三次,但我现在根据 eventTime 过滤事件,目前工作正常。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)