33 lines
741 B
Python
33 lines
741 B
Python
#!/usr/bin/python
|
|
# Copyright 2015 (c) Anna Schumaker.
|
|
|
|
import slack
|
|
import smtplib
|
|
from email.mime.text import MIMEText
|
|
|
|
|
|
s = smtplib.SMTP("localhost")
|
|
|
|
|
|
for channel in slack.channels.list():
|
|
if not channel.is_member():
|
|
continue
|
|
if channel.unread_count() == 0 or channel.unread_count() == None:
|
|
continue
|
|
|
|
text = [ str(channel) ] + [ "" ]
|
|
for message in channel.read():
|
|
text += [ str(message) ]
|
|
|
|
print("\n".join(text))
|
|
print()
|
|
|
|
msg = MIMEText("\n".join(text))
|
|
msg["Subject"] = "[%s] %s" % (slack.team(), channel.name())
|
|
msg["From"] = "SlackMail@OcarinaProject.net"
|
|
msg["To"] = slack.user().email()
|
|
s.sendmail(slack.team(), slack.user().email(), msg.as_string())
|
|
|
|
|
|
s.quit()
|