Add regex that exclude non-valid char

This commit is contained in:
Eragon 2022-12-16 11:56:34 +01:00
parent e61ca3a10b
commit c9f5ef25b8
Signed by: Eragon
GPG Key ID: 087126EBFC725006
1 changed files with 2 additions and 1 deletions

View File

@ -3,6 +3,7 @@ import requests as r
import logging
import time
import datetime
import re
from functools import wraps
from threading import Thread
from irc import IRC
@ -73,7 +74,7 @@ class Shoutbox(object):
def normalize(pseudo):
if pseudo.lower() in [u[0].lower() for u in USERS]:
return [u[1] for u in USERS if u[0].lower() == pseudo.lower()][0]
return pseudo.replace(' ', '_')
return re.sub(r'[^.A-Za-z0-9_]', '_', pseudo)
def _handle(self):
while self.running: