.BANCHO. .FIX. Better support for username with spaces and underscores in IRC

This commit is contained in:
Nyo
2016-09-16 18:20:32 +02:00
parent 47ce794bfc
commit 6020f7cc47
2 changed files with 47 additions and 31 deletions

View File

@@ -297,6 +297,17 @@ def sendMessage(fro = "", to = "", message = "", token = None, toIRC = True):
""" IRC-Bancho Connect/Disconnect/Join/Part interfaces"""
def fixUsernameForBancho(username):
# If there are no spaces or underscores in the name
# return it
if " " not in username and "_" not in username:
return username
# Exact match first
result = glob.db.fetch("SELECT id FROM users WHERE username = %s LIMIT 1", [username])
if result is not None:
return username
# Username not found, replace _ with space
return username.replace("_", " ")
def fixUsernameForIRC(username):
@@ -335,4 +346,4 @@ def IRCPartChannel(username, channel):
if not userID:
log.warning("{} doesn't exist".format(username))
return
return partChannel(userID, channel)
return partChannel(userID, channel)