From ea0eeeb46c583e394a738c9cfbaba0a059760fe0 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Wed, 27 May 2015 09:11:28 -0400 Subject: [PATCH] Send email to the authenticated user's email address This is better than hardcoding in my address. Signed-off-by: Anna Schumaker --- slack/__init__.py | 5 +++++ slack/users.py | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/slack/__init__.py b/slack/__init__.py index f8305f3..7dd929b 100644 --- a/slack/__init__.py +++ b/slack/__init__.py @@ -11,6 +11,7 @@ os.chdir(os.path.dirname(path)) from . import api from . import auth from . import channels +from . import users # @@ -25,7 +26,11 @@ __auth = auth.test() if __auth == None: sys.exit(1) __TEAM = __auth["team"] +__USER = users.info(__auth["user_id"]) def team(): return __TEAM + +def user(): + return __USER diff --git a/slack/users.py b/slack/users.py index 285d80e..12389ea 100644 --- a/slack/users.py +++ b/slack/users.py @@ -12,12 +12,16 @@ class User: self.__user = json.get("name", "") self.__first = json["profile"].get("first_name", "") self.__last = json["profile"].get("last_name", "") + self.__email = json["profile"].get("email", "") def name(self): if self.__first == "" and self.__last == "": return self.__user return ("%s %s" % (self.__first, self.__last)).strip() + def email(self): + return self.__email + def info(user):