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 14:44:59 -04:00
|
|
|
import slack
|
2015-05-26 16:48:22 -04:00
|
|
|
import smtplib
|
|
|
|
from email.mime.text import MIMEText
|
2015-05-28 14:05:27 -04:00
|
|
|
import textwrap
|
2015-05-26 16:48:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
s = smtplib.SMTP("localhost")
|
2015-05-28 14:05:27 -04:00
|
|
|
repl = "--- Reply above this line ---".ljust(40)
|
|
|
|
|
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:42:12 -04:00
|
|
|
|
2015-05-28 14:05:27 -04:00
|
|
|
chan = ("channel=%s" % channel.id()).rjust(40)
|
2015-05-29 08:46:07 -04:00
|
|
|
text = [ "%s%s" % (repl, chan), ""]
|
2015-05-28 14:05:27 -04:00
|
|
|
text += [ str(channel) ] + [ "" ]
|
2015-05-26 16:22:05 -04:00
|
|
|
for message in channel.read():
|
2015-05-26 16:42:12 -04:00
|
|
|
text += [ str(message) ]
|
2015-05-26 16:00:11 -04:00
|
|
|
|
2015-05-26 16:42:12 -04:00
|
|
|
print("\n".join(text))
|
|
|
|
print()
|
2015-05-26 16:48:22 -04:00
|
|
|
|
|
|
|
msg = MIMEText("\n".join(text))
|
|
|
|
msg["Subject"] = "[%s] %s" % (slack.team(), channel.name())
|
2015-05-26 17:00:20 -04:00
|
|
|
msg["From"] = "SlackMail@OcarinaProject.net"
|
2015-05-27 09:12:43 -04:00
|
|
|
msg["To"] = slack.user().email()
|
|
|
|
s.sendmail(slack.team(), slack.user().email(), msg.as_string())
|
2015-05-26 16:48:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
s.quit()
|