Send email with X-Slack-Header to specify channel

This is slightly more accurate than using channel names to lookup where
to post.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-05-27 16:37:05 -04:00
parent d43f0e52d8
commit 5fe26ca0e5
3 changed files with 6 additions and 3 deletions

View File

@ -30,6 +30,9 @@ class Channel:
self.__unread = json.get("unread_count", None)
self.__last_ts = json.get("last_read", None)
def id(self):
return self.__id
def is_member(self):
return self.__member

View File

@ -23,6 +23,7 @@ for channel in slack.channels.list():
print()
msg = MIMEText("\n".join(text))
msg["X-Slack-Channel"] = channel.id()
msg["Subject"] = "[%s] %s" % (slack.team(), channel.name())
msg["From"] = "SlackMail@OcarinaProject.net"
msg["To"] = slack.user().email()

View File

@ -13,12 +13,11 @@ if headers['from'] != "Anna Schumaker <schumaker.anna@gmail.com>":
# Determine which channel to post to
chan_id = headers["X-Slack-Channel"]
channel = None
subject = headers['subject']
ch_name = subject.split("[%s]" % slack.team())[-1].strip()
for c in slack.channels.list():
if c.name() == ch_name:
if c.id() == chan_id:
channel = c
break