diff --git a/slackmail.py b/slackmail.py index 1bc6909..3bb4244 100644 --- a/slackmail.py +++ b/slackmail.py @@ -37,8 +37,10 @@ def call_method_auth(method, args = dict()): # if call_method("api.test")["ok"] == False: sys.exit(1) -if call_method_auth("auth.test")["ok"] == False: +auth = call_method_auth("auth.test") +if auth["ok"] == False: sys.exit(1) +team = auth["team"] @@ -84,15 +86,18 @@ def write_message(fout, message): _write_message(fout, name, message) +tmp_dir = "/tmp/%s" % team +if not os.path.exists(tmp_dir): + os.mkdir(tmp_dir) -os.mkdir("/tmp/slackmail/") for id in list_channel_ids(): channel = find_channel_info(id) if not channel["is_member"]: continue if channel["unread_count"] == 0: continue - fout = open("/tmp/slackmail/%s" % channel["name"], 'w') + + fout = open("%s/%s" % (tmp_dir, channel["name"]), 'w') fout.write(channel["purpose"]["value"].encode("utf-8").decode("latin-1")) fout.write("\n") for message in read_channel(id, channel["last_read"]):