|
|
@@ -1,6 +1,9 @@
|
|
|
import fnmatch
|
|
|
from irc.modes import parse_channel_modes
|
|
|
from common.networkservices import ChanServ
|
|
|
+from common import do_everything_to
|
|
|
+from events.common import Aggressiveness
|
|
|
+
|
|
|
bold = "\x02"
|
|
|
italic = "\x1D"
|
|
|
underline = "\x1F"
|
|
|
@@ -34,26 +37,28 @@ def process_event(self, connection, event):
|
|
|
self.db.run("UPDATE channels SET key='" + mode[2] + "' WHERE name='" + event.target + "' AND network='" + self.network + "'")
|
|
|
else: # Key removed.
|
|
|
self.db.run("UPDATE channels SET key=NULL WHERE name='" + event.target + "' AND network='" + self.network + "'")
|
|
|
-
|
|
|
- # Do not revert the actions of retalliate upon one self.
|
|
|
- if event.source.nick == connection.get_nickname():
|
|
|
- return
|
|
|
-
|
|
|
+
|
|
|
# React.
|
|
|
behaviour = self.db.one("SELECT aggressiveness FROM channels WHERE name='" + event.target + "' AND network='" + self.network + "'")
|
|
|
for mode in modes:
|
|
|
+
|
|
|
+ # Unban if bot is banned from home channel
|
|
|
+ if mode[1] == "b" and fnmatch.fnmatch(self.protectees[connection.get_nickname()]['ident'], mode[2]) and mode[0] == "+" and event.target == self.homechannel:
|
|
|
+ connection.privmsg("ChanServ", "UNBAN")
|
|
|
+ do_everything_to.unban(connection, event.target, connection.get_nickname(), mode[2])
|
|
|
+ connection.mode(event.target, "-b " + mode[2])
|
|
|
+
|
|
|
+ # Do not revert the actions of retalliate upon one self.
|
|
|
+ if event.source.nick == connection.get_nickname():
|
|
|
+ return
|
|
|
+
|
|
|
if behaviour == "passive": # Passive behaviour.
|
|
|
- if event.target == self.homechannel: # Home channel
|
|
|
- if mode[1] == "b" and fnmatch.fnmatch(self.protectees[connection.get_nickname()]['ident'], mode[2]) and mode[0] == "+": # Bot banned.
|
|
|
- ChanServ.unban(connection, event.target, connection.get_nickname())
|
|
|
- connection.privmsg("ChanServ", "UNBAN")
|
|
|
- connection.mode(event.target, "-b " + mode[2])
|
|
|
+ return
|
|
|
elif behaviour == "defense_only": # Defensive only behaviour.
|
|
|
if mode[1] == "b" and mode[0] == "+": # Ban.
|
|
|
for protectee in self.protectees:
|
|
|
if fnmatch.fnmatch(self.protectees[protectee]['ident'], mode[2]): # Protectee.
|
|
|
- ChanServ.unban(connection, event.target, protectee)
|
|
|
- connection.mode(event.target, "-b " + modes[1])
|
|
|
+ do_everything_to.unban(connection, event.target, protectee, mode[2])
|
|
|
elif mode[1] == "e" and mode[0] == "-": # Removed exception.
|
|
|
for protectee in self.protectees:
|
|
|
if fnmatch.fnmatch(self.protectees[protectee]['ident'], mode[2]): # Protectee.
|
|
|
@@ -62,8 +67,7 @@ def process_event(self, connection, event):
|
|
|
if modes[1] == "b" and mode[0] == "+": # Ban.
|
|
|
for protectee in self.protectees:
|
|
|
if fnmatch.fnmatch(self.protectees[protectee]['ident'], mode[2]): # Protectee.
|
|
|
- ChanServ.unban(connection, event.target, protectee)
|
|
|
- connection.mode(event.target, "-b " + mode[2])
|
|
|
+ do_everything_to.unban(connection, event.target, protectee, mode[2])
|
|
|
if protectee == connection.get_nickname(): # Bot banned.
|
|
|
ChanServ.ban(connection, event.target, event.source.nick, "Aggression channel function = equal_retalliation.")
|
|
|
else:
|
|
|
@@ -77,35 +81,15 @@ def process_event(self, connection, event):
|
|
|
if mode[1] == "b" and mode[0] == "+": # Ban.
|
|
|
for protectee in self.protectees:
|
|
|
if fnmatch.fnmatch(self.protectees[protectee]['ident'], mode[2]): # Protectee.
|
|
|
- ChanServ.unban(connection, event.target, protectee)
|
|
|
- connection.mode(event.target, "-b " + mode[2])
|
|
|
- if protectee == connection.get_nickname(): # Bot banned.
|
|
|
- ChanServ.ban(connection, event.target, event.source.nick, "Aggression channel function = battlebot.")
|
|
|
- else:
|
|
|
- ChanServ.ban(connection, event.target, event.source.nick, "Aggression channel function = battlebot: " + protectee + " is an operator of " + connection.get_nickname() + ".")
|
|
|
- connection.mode(event.target, "+b " + event.source)
|
|
|
+ do_everything_to.unban(connection, event.target, protectee, mode[2])
|
|
|
+ do_everything_to.ban(connection, event.target, event.source.nick, event.source, Aggressiveness.retalliation_reason(self, connection, protectee, behaviour))
|
|
|
connection.mode(event.target, "+e " + mode[2])
|
|
|
ChanServ.akick_add(connection, event.target, event.source.nick)
|
|
|
- if protectee == connection.get_nickname(): # Bot banned.
|
|
|
- ChanServ.kick(connection, event.target, event.source.nick, "Aggression channel function = battlebot.")
|
|
|
- connection.kick(event.target, event.source.nick, "Aggression channel function = battlebot.")
|
|
|
- else:
|
|
|
- ChanServ.kick(connection, event.target, event.source.nick, "Aggression channel function = battlebot: " + protectee + " is an operator of " + connection.get_nickname() + ".")
|
|
|
- connection.kick(event.target, event.source.nick, "Aggression channel function = battlebot: " + protectee + " is an operator of " + connection.get_nickname() + ".")
|
|
|
+ do_everything_to.kick(connection, event.target, event.source.nick, Aggressiveness.retalliation_reason(self, connection, protectee, behaviour))
|
|
|
elif mode[1] == "e" and mode[0] == "-": # Removed exception.
|
|
|
for protectee in self.protectees:
|
|
|
if fnmatch.fnmatch(self.protectees[protectee]['ident'], mode[2]): # Protectee.
|
|
|
- if protectee == connection.get_nickname(): # Bot.
|
|
|
- ChanServ.ban(connection, event.target, event.source.nick, "Aggression channel function = battlebot.")
|
|
|
- else:
|
|
|
- ChanServ.ban(connection, event.target, event.source.nick, "Aggression channel function = battlebot: " + protectee + " is an operator of " + connection.get_nickname() + ".")
|
|
|
- print(event.target, "+b " + event.source)
|
|
|
- connection.mode(event.target, "+b " + event.source)
|
|
|
+ do_everything_to.ban(connection, event.target, event.source.nick, event.source, Aggressiveness.retalliation_reason(self, connection, protectee, behaviour))
|
|
|
connection.mode(event.target, "+e " + modes[mode]['value'])
|
|
|
ChanServ.akick_add(connection, event.target, event.source.nick)
|
|
|
- if protectee == connection.get_nickname(): # Bot.
|
|
|
- ChanServ.kick(connection, event.target, event.source.nick, "Aggression channel function = battlebot..")
|
|
|
- connection.kick(event.target, event.source.nick, "Aggression channel function = battlebot.")
|
|
|
- else:
|
|
|
- ChanServ.kick(connection, event.target, event.source.nick, "Aggression channel function = battlebot: " + protectee + " is an operator of " + connection.get_nickname() + ".")
|
|
|
- connection.kick(event.target, event.source.nick, "Aggression channel function = battlebot: " + protectee + " is an operator of " + connection.get_nickname() + ".")
|
|
|
+ do_everything_to.kick(connection, event.target, event.source.nick, Aggressiveness.retalliation_reason(self, connection, protectee, behaviour))
|