slackmail/slack/channels.py
Anna Schumaker 1e767dbfe9 Implement a single fetch_info() function
This already existed, so I just had to define the api calls to use.
Unfortunately, groups return a similar group object so I also have to
define what return object needs to be looked up.  Additionally, IMs have
an extra "return_im" object that needs to be passed to get the full
channel info.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-11-22 10:18:16 -05:00

30 lines
714 B
Python

#
# Copyright 2015 (c) Anna Schumaker.
#
from . import api
from . import auth
from . import threads
class Channel(threads.Thread):
def __init__(self, json):
threads.Thread.__init__(self, json)
self.api_history = "channels.history"
self.api_info = { "call" : "channels.info", "ret" : "channel" }
self.api_mark = "channels.mark"
self.__member = json.get("is_member", False)
def is_member(self):
return self.__member
def list():
ret = api.call("channels.list", token = auth.token())
if ret["ok"] == False:
return None
ch_list = []
for channel in ret["channels"]:
ch_list += [ Channel(channel) ]
return ch_list