我使用Bot用户创建了一个松散的应用程序,该用户使用Events API来收听机器人挂断的频道中的消息。
Oauth范围:bot,chat:write:bot
我订阅了以下Bot活动:
当我邀请我的机器人加入频道时,我收到一个POST请求,如下所示:
{
[...]
"event": {
"user": "U24BYHV19",
"inviter": "U03BN91GN",
"text": "<@U24BYHV19|my_bot> has joined the channel",
"type": "message",
"subtype": "channel_join",
"ts": "1472139425.000019",
"channel": "C24UWQE85",
"event_ts": "1472139425.000019"
},
"type": "event_callback",
[...]
}
当我在僵尸程序挂起的频道中发送消息时,我收到如下的POST请求:
{
[...]
"event": {
"type": "message",
"user": "U03BN91GN",
"text": "hello <@U24BYHV19>",
"ts": "1472139444.000021",
"channel": "C24UWQE85",
"event_ts": "1472139444.000021"
},
"type": "event_callback",
[...]
}
当我向我的机器人发送直接消息时,我收到如下的POST请求:
{
[...]
"event": {
"type": "message",
"user": "U03BN91GN",
"text": "hello pager",
"ts": "1472139450.000032",
"channel": "D24DC8UTG",
"event_ts": "1472139450.000032"
},
"type": "event_callback",
[...]
}
问题是,如何确定有人通过直接消息与我的机器人交谈? :)因为如果有人和我的机器人说话,我想回复。
答案 0 :(得分:3)
直接消息的频道以D而不是C开头。