我在玩松弛rtm api,他们说“您可以用相同的方式向私有组或直接消息通道发送消息,但可以使用组ID (C024BE91L)或DM通道ID (D024BE91L)”。是否有任何方法从DM通道ID到您要发送直接消息的用户名?
发布于 2016-04-29 17:28:51
我正在用一种方法来解决这个问题,也许有更好的方法,但我找不到。
您可以使用用户ID (而不是用户名,尽管可以很容易地检索它)对im.open进行API调用,响应将返回DM通道id。
这是我在Python中所做的快速尝试:
def get_direct_channel(sc, user_id):
'''
Get direct channel id from userid
sc => slack client
'''
direct_message = sc.api_call("im.open", user=user_id)
channel = direct_message.get("channel")
if channel:
channel_id = channel.get("id")
if channel_id:
return channel_id
return None更多信息来自文档。
https://stackoverflow.com/questions/34054769
复制相似问题