Don't .lower() nicknames in Database.py, it doesn't know about IRC casemapping

This commit is contained in:
jesopo 2019-02-06 11:25:20 +00:00
parent 3e54542b6a
commit 2f7937adc5
2 changed files with 5 additions and 4 deletions

View file

@ -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):

View file

@ -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: