From 760c9d8844b45bbd3f9d18a0552cbdee38549355 Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 3 Oct 2018 11:32:31 +0100 Subject: [PATCH] Add a way to not add a user automatically in IRCServer.get_user --- src/IRCServer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/IRCServer.py b/src/IRCServer.py index 55e1e3ca..282d4bc3 100644 --- a/src/IRCServer.py +++ b/src/IRCServer.py @@ -158,14 +158,14 @@ class Server(IRCObject.Object): def has_user(self, nickname): return Utils.irc_lower(self, nickname) in self.users - def get_user(self, nickname): - if not self.has_user(nickname): + def get_user(self, nickname, create=True): + if not self.has_user(nickname) and create: user_id = self.get_user_id(nickname) 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.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): self.bot.database.users.add(self.id, nickname) return self.bot.database.users.get_id(self.id, nickname)