2015-12-02 45 views

回答

1

我正在使用一種解決方法來獲取此,可能有更好的方法,但我找不到一個。

您可以使用用戶標識(不是用戶名,但可以很容易地檢索到)對im.open進行API調用,響應會返回DM信道標識。

這是一個快速的嘗試我在Python做的:從doc

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 

更多信息。