forgot to commit kwargs for get_user()

This commit is contained in:
jesopo 2019-09-27 15:52:25 +01:00
parent 2493cfa487
commit 16ba52f5dc

View file

@ -164,16 +164,26 @@ class Server(IRCObject.Object):
def has_user(self, nickname: str) -> bool: def has_user(self, nickname: str) -> bool:
return self.irc_lower(nickname) in self.users return self.irc_lower(nickname) in self.users
def get_user(self, nickname: str, create: bool=True def get_user(self, nickname: str, username: str=None, hostname: str=None,
) -> typing.Optional[IRCUser.User]: create: bool=True) -> typing.Optional[IRCUser.User]:
new = False
if not self.has_user(nickname) and create: if not self.has_user(nickname) and create:
new = True
user_id = self.get_user_id(nickname) user_id = self.get_user_id(nickname)
new_user = IRCUser.User(nickname, user_id, self, self.bot) new_user = IRCUser.User(nickname, user_id, self, self.bot)
self.events.on("new.user").call(user=new_user, server=self)
self.users[new_user.nickname_lower] = new_user self.users[new_user.nickname_lower] = new_user
self.new_users.add(new_user) self.new_users.add(new_user)
return self.users.get(self.irc_lower(nickname),
None) user = self.users.get(self.irc_lower(nickname), None)
if user:
if not username == None:
user.username = username
if not hostname == None:
user.hostname = hostname
if new:
self.events.on("new.user").call(user=new_user, server=self)
return user
def get_user_id(self, nickname: str) -> int: def get_user_id(self, nickname: str) -> int:
nickname_lower = self.irc_lower(nickname) nickname_lower = self.irc_lower(nickname)
self.bot.database.users.add(self.id, nickname_lower) self.bot.database.users.add(self.id, nickname_lower)