diff --git a/slack/im.py b/slack/im.py index 271f1a9..9c12faa 100644 --- a/slack/im.py +++ b/slack/im.py @@ -10,10 +10,11 @@ class IM(threads.Thread): def __init__(self, json): threads.Thread.__init__(self, json) self.api_history = "im.history" - self.api_info = { "call" : "im.open", "ret" : "channel" } + self.api_info = { "call" : "im.info", "ret" : "im" } self.api_mark = "im.mark" self.__uid = json.get("user") self.__user = users.info(self.__uid) + self.__im_open = None def name(self): return "Chat With %s" % self.__user.name() @@ -22,8 +23,15 @@ class IM(threads.Thread): return "%s/messages/@%s/" % (base, self.__user.user()) def call_fetch_info(self): - return api.call(self.api_info["call"], token = auth.token(), - user = self.__uid, return_im = True) + ret = threads.Thread.call_fetch_info(self) + if ret["ok"] == True: + self.__im_open = ret[self.api_info["ret"]]["is_open"] + return ret + + def is_member(self): + if self.__im_open == None: + self.fetch_info() + return self.__im_open def list(): diff --git a/slack/threads.py b/slack/threads.py index cfc15ef..8212748 100644 --- a/slack/threads.py +++ b/slack/threads.py @@ -37,7 +37,6 @@ class Thread: if json["ok"] == True: self.__unread = json[self.api_info["ret"]].get("unread_count", None) self.__last_ts = json[self.api_info["ret"]].get("last_read", None) - self.__id = json[self.api_info["ret"]].get("id", 0) def fetch_messages(self): json = api.call(self.api_history, token = auth.token(),