From 64d843d98a854553dcf019f23826401e39d48d4f Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Tue, 17 Jul 2018 10:58:09 -0500 Subject: [PATCH] Added helper for getting user object by id #232 --- src/sessionmanager/session.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/sessionmanager/session.py b/src/sessionmanager/session.py index 8a3ad8c9..97429173 100644 --- a/src/sessionmanager/session.py +++ b/src/sessionmanager/session.py @@ -530,4 +530,12 @@ class Session(object): if "@%s" % (i["screen_name"]) not in tweet["message"] and i["screen_name"] != tweet["user"]["screen_name"]: if tweet.has_key("retweeted_status") and tweet["retweeted_status"]["user"]["screen_name"] == i["screen_name"]: continue - return tweet \ No newline at end of file + return tweet + + def get_user(self, id): + if self.db.has_key("users") == False or self.db["users"].has_key(id) == False: + user = self.twitter.twitter.show_user(id=id) + self.db["users"][user["id"]] = user + return user + else: + return self.db["users"][id] \ No newline at end of file