Made Botty Case Insensitive

This commit is contained in:
BaerbelBox
2024-02-09 19:58:11 +01:00
parent 0c8ff9179b
commit 290bda4fce
6 changed files with 13 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
import _thread import _thread
import copy
from FaustBot.Communication.Observable import Observable from FaustBot.Communication.Observable import Observable
from FaustBot import Modules from FaustBot import Modules
from FaustBot.Model.BlockedUsers import BlockProvider from FaustBot.Model.BlockedUsers import BlockProvider
@@ -16,6 +16,8 @@ class PrivmsgObservable(Observable):
'raw_nick': raw_data.split(' PRIVMSG')[0][1:]} 'raw_nick': raw_data.split(' PRIVMSG')[0][1:]}
# 12 = :<raw_nick> PRIVMSG <channel> :<message> # 12 = :<raw_nick> PRIVMSG <channel> :<message>
data['message'] = raw_data[data['raw_nick'].__len__() + data['channel'].__len__() + 12:] data['message'] = raw_data[data['raw_nick'].__len__() + data['channel'].__len__() + 12:]
data['messageCaseSensitive'] = copy.copy(data['message'])
data['message'] = data['message'].lower()
data['command'] = 'irgendwas, das mit . oder .. anfängt oder so... oder das sollen module checken?' data['command'] = 'irgendwas, das mit . oder .. anfängt oder so... oder das sollen module checken?'
if self.user_list is None: if self.user_list is None:
return return

View File

@@ -24,7 +24,7 @@ class GlossaryModule(PrivMsgObserverPrototype):
self._config = config self._config = config
def update_on_priv_msg(self, data, connection: Connection): def update_on_priv_msg(self, data, connection: Connection):
msg = data['message'] msg = data['messageCaseSensitive']
if msg.startswith(GlossaryModule._REMOVE_EXPLANATION): if msg.startswith(GlossaryModule._REMOVE_EXPLANATION):
self._remove_query(data, connection) self._remove_query(data, connection)
elif msg.startswith(GlossaryModule._ADD_EXPLANATION): elif msg.startswith(GlossaryModule._ADD_EXPLANATION):
@@ -84,7 +84,7 @@ class GlossaryModule(PrivMsgObserverPrototype):
connection.send_back("Dir fehlen leider die Rechte zum Hinzufügen von Einträgen, " + data['nick'] + ".", connection.send_back("Dir fehlen leider die Rechte zum Hinzufügen von Einträgen, " + data['nick'] + ".",
data) data)
return return
msg = data['message'].split(GlossaryModule._ADD_EXPLANATION)[1].strip() msg = data['messageCaseSensitive'].split(GlossaryModule._ADD_EXPLANATION)[1].strip()
split = msg.split(' ', 1) split = msg.split(' ', 1)
glossary_provider = GlossaryProvider() glossary_provider = GlossaryProvider()
glossary_provider.save_or_replace(split[0], split[1]) glossary_provider.save_or_replace(split[0], split[1])

View File

@@ -18,7 +18,7 @@ class IntroductionObserver(PrivMsgObserverPrototype):
return ".me - kann von registrierten Nutzern verwendet werden um eine Vorstellung zu speichern" return ".me - kann von registrierten Nutzern verwendet werden um eine Vorstellung zu speichern"
def update_on_priv_msg(self, data, connection: Connection): def update_on_priv_msg(self, data, connection: Connection):
msg = data["message"] msg = data['messageCaseSensitive']
nick = data["nick"] nick = data["nick"]
if not msg.startswith(".me") and not msg.startswith(".me-"): if not msg.startswith(".me") and not msg.startswith(".me-"):
return return

View File

@@ -15,6 +15,6 @@ class TellObserver(PrivMsgObserverPrototype):
def update_on_priv_msg(self, data, connection: Connection): def update_on_priv_msg(self, data, connection: Connection):
if data['message'].find('.tell') != -1 and self._is_idented_mod(data, connection): if data['message'].find('.tell') != -1 and self._is_idented_mod(data, connection):
connection.send_channel(data['message'][6:]) connection.send_channel(data['messageCaseSensitive'][6:])
def _is_idented_mod(self, data: dict, connection: Connection): def _is_idented_mod(self, data: dict, connection: Connection):
return data['nick'] in self._config.mods and connection.is_idented(data['nick']) return data['nick'] in self._config.mods and connection.is_idented(data['nick'])

View File

@@ -18,7 +18,7 @@ class TitleObserver(PrivMsgObserverPrototype):
def update_on_priv_msg(self, data, connection: Connection): def update_on_priv_msg(self, data, connection: Connection):
regex = "(?P<url>https?://[^\s]+)" regex = "(?P<url>https?://[^\s]+)"
url = re.search(regex, data['message']) url = re.search(regex, data['messageCaseSensitive'])
if url is not None: if url is not None:
url = url.group() url = url.group()
print(url) print(url)

View File

@@ -33,3 +33,8 @@ baerbel ; GITTERPOMMES
baerbel ; NASE baerbel ; NASE
TommyRainbow ; TEST TommyRainbow ; TEST
TommyRainbow ; LALALALALALA TommyRainbow ; LALALALALALA
Elira ; TEST
Elira ; SUPERTOLLESWORT
Elira ; SUPERTOLL
Elira ; FRAGIL
Elira ; LITHIUM