slackmail/slack/groups.py

35 lines
736 B
Python

#
# Copyright 2015 (c) Anna Schumaker.
#
from . import api
from . import auth
from . import threads
class Group(threads.Thread):
def __init__(self, json):
threads.Thread.__init__(self, json)
self.api_history = "groups.history"
self.api_mark = "groups.mark"
def do_fetch_info(self):
return info(self.id())
def info(group):
ret = api.call("groups.info", token = auth.token(), channel = group)
if ret["ok"] == False:
return None
return ret["group"]
def list():
ret = api.call("groups.list", token = auth.token())
if ret["ok"] == False:
return None
gr_list = []
for group in ret["groups"]:
gr_list += [ Group(group) ]
return gr_list