Prepare text as an email message

Right now it's hardcoded to send to me.  This should be made
configurable eventually ...

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-05-26 16:48:22 -04:00
parent 80706b18c9
commit b5d715096e
4 changed files with 23 additions and 2 deletions

View File

@ -22,3 +22,7 @@ __auth = auth.test()
if __auth == None:
sys.exit(1)
__TEAM = __auth["team"]
def team():
return __TEAM

View File

@ -10,7 +10,7 @@ from datetime import datetime
class Channel:
def __init__(self, json):
self.__id = json.get("id", "0")
self.__name = json.get("name", "")
self.__name = json.get("name", "").title()
self.__member = json.get("is_member", False)
self.__topic = json["topic"].get("value", "").encode("utf-8").decode("latin-1")
self.__purpose = json["purpose"].get("value", "").encode("utf-8").decode("latin-1")
@ -32,6 +32,9 @@ class Channel:
def is_member(self):
return self.__member
def name(self):
return self.__name
def unread_count(self):
if self.__unread == None:
self.fetch_info()

View File

@ -16,7 +16,7 @@ class User:
def name(self):
if self.__first == "" and self.__last == "":
return self.__user
return "%s %s" % (self.__first, self.__last)
return ("%s %s" % (self.__first, self.__last)).strip()

View File

@ -2,6 +2,11 @@
# 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():
@ -16,3 +21,12 @@ for channel in slack.channels.list():
print("\n".join(text))
print()
msg = MIMEText("\n".join(text))
msg["Subject"] = "[%s] %s" % (slack.team(), channel.name())
msg["From"] = "slack@OcarinaProject.net"
msg["To"] = "schumaker.anna@gmail.com"
s.sendmail("SlackMail", "schumaker.anna@gmail.com", msg.as_string())
s.quit()