现在如何获取在聊天中提及的用户ID?

时间:2018-08-13 21:13:07

标签: python slack slack-api

键入我的自定义松弛bot命令,将johndoe添加到组中

"/myslashcommand add @johndoe"

在打印request.form ['txt']时,将我的终端中的内容翻译为以下内容:

add @john.doe

如何从中获取johndoe的用户ID?还是当某人运行添加用户显示名称的命令时,如何获得某人的用户ID?

From this Slack post,看来格式应该是:

/myslashcommand add <@UAZERRANR|john.doe>

当有人在闲聊机器人的聊天中提及用户ID时,如何获取用户ID?

1 个答案:

答案 0 :(得分:0)

From the same blog post:调用users.list方法将用户显示名称映射到用户ID。您需要使用整个列表,因此需要将映射缓存在某个位置,以供您的应用读取和更新。