2015-05-26 09:21:44 -04:00
|
|
|
#!/usr/bin/python
|
|
|
|
# Copyright 2015 (c) Anna Schumaker.
|
2015-05-26 09:44:17 -04:00
|
|
|
|
2015-05-26 12:41:34 -04:00
|
|
|
import os
|
2015-05-26 14:44:59 -04:00
|
|
|
import slack
|
2015-05-26 12:26:31 -04:00
|
|
|
from datetime import datetime
|
2015-05-26 09:21:44 -04:00
|
|
|
|
2015-05-26 09:44:17 -04:00
|
|
|
|
2015-05-26 09:21:44 -04:00
|
|
|
|
|
|
|
|
2015-05-26 15:20:12 -04:00
|
|
|
for channel in slack.channels.list():
|
|
|
|
if not channel.is_member():
|
|
|
|
continue
|
2015-05-26 15:38:47 -04:00
|
|
|
if channel.unread_count() == 0 or channel.unread_count() == None:
|
|
|
|
continue
|
2015-05-26 16:22:05 -04:00
|
|
|
print(channel)
|
|
|
|
for message in channel.read():
|
|
|
|
print(message)
|
|
|
|
print()
|
2015-05-26 16:00:11 -04:00
|
|
|
|
|
|
|
#def _write_message(fout, user, message):
|
|
|
|
# dt = datetime.fromtimestamp(float(message["ts"]))
|
|
|
|
# text = message["text"].encode("utf-8").decode("latin-1")
|
|
|
|
# fout.write("%s %s: %s\n" % (str(dt), user, text))
|
|
|
|
#
|
|
|
|
#def write_message(fout, message):
|
|
|
|
# call = call_method_auth("users.info", {"user" : message["user"]})
|
|
|
|
# if call["ok"] == False:
|
|
|
|
# name = message["user"]
|
|
|
|
# else:
|
|
|
|
# first = call["user"]["profile"].get("first_name", "")
|
|
|
|
# last = call["user"]["profile"].get("last_name", "")
|
|
|
|
# name = "%s %s" % (first, last)
|
|
|
|
# if first == "" and last == "":
|
|
|
|
# name = call["user"]["name"]
|
|
|
|
# _write_message(fout, name, message)
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#tmp_dir = "/tmp/%s" % team
|
|
|
|
#if not os.path.exists(tmp_dir):
|
|
|
|
# os.mkdir(tmp_dir)
|
|
|
|
#
|
|
|
|
#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("%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"]):
|
|
|
|
# write_message(fout, message)
|
|
|
|
# fout.close()
|