[英]How can my Slack-using BotFramework bot ignore messages on all channels except direct?
I know this seems like it's been asked before - but I understand that you can figure out that someone's talking on a Slack channel by inspecting activity.Conversation.IsGroup
- I'm using this successfully. 我知道这似乎是以前被问过的-但我知道您可以通过检查
activity.Conversation.IsGroup
来确定有人在Slack频道上聊天-我正在成功使用它。
This is fine as long as the channel has more than two members! 只要该频道有两个以上的会员,就可以了! But there's an annoying edge case where newly-created channels, say, or channels just containing two members, have to experience the bot trying to respond to all messages there, until at least 3 members are added to the channel.
但是,在一个令人烦恼的极端情况下,例如,新创建的通道或仅包含两个成员的通道必须体验自动程序试图对那里的所有消息进行响应,直到将至少3个成员添加到该通道。
Has anyone figured out a handy way to detect this? 有没有人找到方便的方法来检测到这一点? I inspected the
Activity
JSON for both a message to the app/bot user directly and a message to a channel, but there's no obvious way of being able to distinguish a channel message from a direct-to-bot-user message. 我检查了
Activity
JSON中是否既有直接发送给应用程序/机器人用户的消息,也有针对通道的消息,但是没有明显的方法可以区分通道消息和直接向机器人用户的消息。
If I remember well, there is a difference in Slack in the naming between a channel and a direct messaging: this difference can be seen in the Conversation.Id
field: 如果我没记错的话,通道和直接消息传递之间的Slack命名方式有所不同:这种差异可以在
Conversation.Id
字段中看到:
Examples: 例子:
Bxxxxxxxx:Tyyyyyyyy:Czzzzzzzz
Bxxxxxxxx:Tyyyyyyyy:Czzzzzzzz
Bxxxxxxxx:Tyyyyyyyy:Daaaaaaaa
Bxxxxxxxx:Tyyyyyyyy:Daaaaaaaa
Bxxxxxxxx:Tyyyyyyyy:Gbbbbbbbb
Bxxxxxxxx:Tyyyyyyyy:Gbbbbbbbb
Where: 哪里:
Bxxxxxxxx
is your bot Slack's ID Bxxxxxxxx
是您的机器人Slack的ID Tyyyyyyyy
is your Slack's workspace ID Tyyyyyyyy
是您的Slack的工作区ID Czzzzzzzz
is the current channel Slack's ID (visible in the url when using web version of Slack) Czzzzzzzz
是当前频道的Slack的ID(使用Web版本的Slack在URL中可见) You will be able to detect your case by checking the conversation ID 您可以通过查看对话ID来发现您的情况
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.