mirror of
https://github.com/nichkara/InfinitumBotty.git
synced 2026-06-10 22:26:23 +02:00
f-stringify blockObs and only act on startswith
This commit is contained in:
@@ -2,6 +2,7 @@ from FaustBot.Communication.Connection import Connection
|
||||
from FaustBot.Modules.PrivMsgObserverPrototype import PrivMsgObserverPrototype
|
||||
from FaustBot.Model.BlockedUsers import BlockProvider
|
||||
|
||||
|
||||
class BlockObserver(PrivMsgObserverPrototype):
|
||||
@staticmethod
|
||||
def cmd():
|
||||
@@ -14,32 +15,33 @@ class BlockObserver(PrivMsgObserverPrototype):
|
||||
def update_on_priv_msg(self, data, connection: Connection):
|
||||
if not self._is_idented_mod(data, connection):
|
||||
return
|
||||
if data['message'].find('.block ') != -1:
|
||||
if data["message"].startswith(".block "):
|
||||
self.block(data, connection)
|
||||
if data['message'].find ('.unblock')!=-1:
|
||||
if data["message"].startswith(".unblock"):
|
||||
self.unblock(data, connection)
|
||||
if data['message'].find('.isblocked') != -1:
|
||||
if data["message"].startswith(".isblocked"):
|
||||
self.isBlocked(data, connection)
|
||||
|
||||
def block(self,data,connection):
|
||||
def block(self, data, connection):
|
||||
blocklist = BlockProvider()
|
||||
blocklist.block(self.isolateTarget(data))
|
||||
connection.send_back("blocked: "+ self.isolateTarget(data), data)
|
||||
connection.send_back(f"blocked: {self.isolateTarget(data)}", data)
|
||||
|
||||
def unblock(self,data,connection):
|
||||
def unblock(self, data, connection):
|
||||
blocklist = BlockProvider()
|
||||
blocklist.delete_block(self.isolateTarget(data))
|
||||
connection.send_back("unblocked: "+ self.isolateTarget(data), data)
|
||||
connection.send_back(f"unblocked: {self.isolateTarget(data)}", data)
|
||||
|
||||
def isBlocked(self,data,connection):
|
||||
blocklist= BlockProvider()
|
||||
def isBlocked(self, data, connection):
|
||||
blocklist = BlockProvider()
|
||||
answ = blocklist.is_blocked(self.isolateTarget(data))
|
||||
if answ:
|
||||
connection.send_back(self.isolateTarget(data) + " ist geblocked", data)
|
||||
connection.send_back(f"{self.isolateTarget(data)} ist geblocked", data)
|
||||
return
|
||||
connection.send_back(self.isolateTarget(data)+" ist nicht geblocked", data)
|
||||
def isolateTarget(self,data):
|
||||
return data['message'].split(' ')[1]
|
||||
connection.send_back(f"{self.isolateTarget(data)} ist nicht geblocked", data)
|
||||
|
||||
def isolateTarget(self, data):
|
||||
return data["message"].split(" ")[1]
|
||||
|
||||
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"])
|
||||
|
||||
Reference in New Issue
Block a user