Add a way to not add a user automatically in IRCServer.get_user
This commit is contained in:
parent
489d508997
commit
760c9d8844
1 changed files with 3 additions and 3 deletions
|
@ -158,14 +158,14 @@ class Server(IRCObject.Object):
|
||||||
|
|
||||||
def has_user(self, nickname):
|
def has_user(self, nickname):
|
||||||
return Utils.irc_lower(self, nickname) in self.users
|
return Utils.irc_lower(self, nickname) in self.users
|
||||||
def get_user(self, nickname):
|
def get_user(self, nickname, create=True):
|
||||||
if not self.has_user(nickname):
|
if not self.has_user(nickname) and create:
|
||||||
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.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[Utils.irc_lower(self, nickname)]
|
return self.users.get(Utils.irc_lower(self, nickname), None)
|
||||||
def get_user_id(self, nickname):
|
def get_user_id(self, nickname):
|
||||||
self.bot.database.users.add(self.id, nickname)
|
self.bot.database.users.add(self.id, nickname)
|
||||||
return self.bot.database.users.get_id(self.id, nickname)
|
return self.bot.database.users.get_id(self.id, nickname)
|
||||||
|
|
Loading…
Reference in a new issue