Mark channels read when updated
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
b5d715096e
commit
253e0374f0
|
@ -49,7 +49,8 @@ class Channel:
|
||||||
|
|
||||||
class Message:
|
class Message:
|
||||||
def __init__(self, json):
|
def __init__(self, json):
|
||||||
self.__time = datetime.fromtimestamp(float(json["ts"]))
|
self.__ts = json["ts"]
|
||||||
|
self.__time = datetime.fromtimestamp(self.__ts))
|
||||||
self.__user = users.info(json["user"])
|
self.__user = users.info(json["user"])
|
||||||
self.__text = json["text"].encode("utf-8").decode("latin-1")
|
self.__text = json["text"].encode("utf-8").decode("latin-1")
|
||||||
|
|
||||||
|
@ -59,6 +60,9 @@ class Message:
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s %s: %s" % (self.__time.time(), self.__user.name(), self.__text)
|
return "%s %s: %s" % (self.__time.time(), self.__user.name(), self.__text)
|
||||||
|
|
||||||
|
def ts(self):
|
||||||
|
return self.__tsi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def history(channel, timestamp):
|
def history(channel, timestamp):
|
||||||
|
@ -70,6 +74,9 @@ def history(channel, timestamp):
|
||||||
for message in ret["messages"]:
|
for message in ret["messages"]:
|
||||||
m_list += [ Message(message) ]
|
m_list += [ Message(message) ]
|
||||||
m_list.sort()
|
m_list.sort()
|
||||||
|
|
||||||
|
if len(m_list) > 0:
|
||||||
|
mark(channel, m_list[-1].ts())
|
||||||
return m_list
|
return m_list
|
||||||
|
|
||||||
def info(channel):
|
def info(channel):
|
||||||
|
@ -87,3 +94,6 @@ def list():
|
||||||
for channel in ret["channels"]:
|
for channel in ret["channels"]:
|
||||||
ch_list += [ Channel(channel) ]
|
ch_list += [ Channel(channel) ]
|
||||||
return ch_list
|
return ch_list
|
||||||
|
|
||||||
|
def mark(channel, timestamp):
|
||||||
|
api.call("channels.mark", token = auth.token(), channel = channel, ts = timestamp)
|
||||||
|
|
|
@ -24,7 +24,7 @@ for channel in slack.channels.list():
|
||||||
|
|
||||||
msg = MIMEText("\n".join(text))
|
msg = MIMEText("\n".join(text))
|
||||||
msg["Subject"] = "[%s] %s" % (slack.team(), channel.name())
|
msg["Subject"] = "[%s] %s" % (slack.team(), channel.name())
|
||||||
msg["From"] = "slack@OcarinaProject.net"
|
msg["From"] = "SlackMail@OcarinaProject.net"
|
||||||
msg["To"] = "schumaker.anna@gmail.com"
|
msg["To"] = "schumaker.anna@gmail.com"
|
||||||
s.sendmail("SlackMail", "schumaker.anna@gmail.com", msg.as_string())
|
s.sendmail("SlackMail", "schumaker.anna@gmail.com", msg.as_string())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue