# # 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) def do_fetch_info(self): return info(self.id()) def do_fetch_messages(self, ts): return history(self.id(), ts) def do_mark_messages(self, ts): mark(self.id(), ts) def history(group, timestamp): ret = api.call("groups.history", token = auth.token(), channel = group, oldest = timestamp) if ret["ok"] == False: return None return ret["messages"] 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 def mark(group, timestamp): api.call("groups.mark", token = auth.token(), channel = group, ts = timestamp)