From 2f7937adc5c0147b5d3cbc975ddefe89a35419d8 Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 6 Feb 2019 11:25:20 +0000 Subject: [PATCH] Don't .lower() nicknames in Database.py, it doesn't know about IRC casemapping --- src/Database.py | 4 ++-- src/IRCServer.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Database.py b/src/Database.py index a7bb97d1..dd063226 100644 --- a/src/Database.py +++ b/src/Database.py @@ -56,14 +56,14 @@ class Users(Table): def add(self, server_id: int, nickname: str): self.database.execute("""INSERT OR IGNORE INTO users (server_id, nickname) VALUES (?, ?)""", - [server_id, nickname.lower()]) + [server_id, nickname]) def delete(self, user_id: int): self.database.execute("DELETE FROM users WHERE user_id=?", [user_id]) def get_id(self, server_id: int, nickname: str): value = self.database.execute_fetchone("""SELECT user_id FROM users WHERE server_id=? and nickname=?""", - [server_id, nickname.lower()]) + [server_id, nickname]) return value if value == None else value[0] class BotSettings(Table): diff --git a/src/IRCServer.py b/src/IRCServer.py index 60b05ee0..de0979dc 100644 --- a/src/IRCServer.py +++ b/src/IRCServer.py @@ -203,8 +203,9 @@ class Server(IRCObject.Object): return self.users.get(self.irc_lower(nickname), None) def get_user_id(self, nickname: str) -> int: - self.bot.database.users.add(self.id, nickname) - return self.bot.database.users.get_id(self.id, nickname) + nickname_lower = self.irc_lower(nickname) + self.bot.database.users.add(self.id, nickname_lower) + return self.bot.database.users.get_id(self.id, nickname_lower) def remove_user(self, user: IRCUser.User): del self.users[user.nickname_lower] for channel in user.channels: