mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-23 03:38:08 -06:00
Check alias before returning any user object
This commit is contained in:
parent
07f9afb14e
commit
3688d7548c
@ -430,9 +430,25 @@ class Session(base.baseSession):
|
|||||||
users = self.db["users"]
|
users = self.db["users"]
|
||||||
users[user.id_str] = user
|
users[user.id_str] = user
|
||||||
self.db["users"] = users
|
self.db["users"] = users
|
||||||
|
user.name = self.get_user_alias(user)
|
||||||
return user
|
return user
|
||||||
else:
|
else:
|
||||||
return self.db["users"][str(id)]
|
user = self.db["users"][str(id)]
|
||||||
|
user.name = self.get_user_alias(user)
|
||||||
|
return user
|
||||||
|
|
||||||
|
def get_user_alias(self, user):
|
||||||
|
""" Retrieves an alias for the passed user model, if exists.
|
||||||
|
@ user Tweepy.models.user: An user object.
|
||||||
|
"""
|
||||||
|
aliases = self.settings.get("user-aliases")
|
||||||
|
if aliases == None:
|
||||||
|
log.error("Aliases are not defined for this config spec.")
|
||||||
|
return user.name
|
||||||
|
user_alias = aliases.get(user.id_str)
|
||||||
|
if user_alias != None:
|
||||||
|
return user_alias
|
||||||
|
return user.name
|
||||||
|
|
||||||
def get_user_by_screen_name(self, screen_name):
|
def get_user_by_screen_name(self, screen_name):
|
||||||
""" Returns an user identifier associated with a screen_name.
|
""" Returns an user identifier associated with a screen_name.
|
||||||
|
Loading…
Reference in New Issue
Block a user