|
|
@@ -1,4 +1,5 @@
|
|
|
from common.networkservices import ChanServ
|
|
|
+from common import userstatus
|
|
|
bold = "\x02"
|
|
|
italic = "\x1D"
|
|
|
underline = "\x1F"
|
|
|
@@ -10,6 +11,7 @@ red = "\x0304"
|
|
|
grey = "\x0314"
|
|
|
|
|
|
def process_event(self, connection, event):
|
|
|
+ print(event)
|
|
|
kicker = event.source.nick
|
|
|
channel = event.target
|
|
|
kicked = event.arguments[0]
|
|
|
@@ -31,17 +33,68 @@ def process_event(self, connection, event):
|
|
|
self.db.run("UPDATE kicks SET given = given + 1 WHERE channel='" + channel + "'AND channel_network='" + self.network + "' AND \"user\"='" + kicker + "' AND user_network='" + self.network + "'")
|
|
|
self.db.run("UPDATE kicks SET received = received + 1 WHERE channel='" + channel + "'AND channel_network='" + self.network + "' AND \"user\"='" + kicked + "' AND user_network='" + self.network + "'")
|
|
|
|
|
|
+ if not userstatus.atleast_halfop(self, kicked, self.homechannel) and not kicked == connection.get_nickname(): # Insufficient rights.
|
|
|
+ return
|
|
|
+
|
|
|
+ # Report to home channel.
|
|
|
+ if not channel == self.homechannel: # Not from it's homechannel.
|
|
|
+ if reason:
|
|
|
+ connection.action(self.homechannel, "has been kicked from " + red + channel + reset + " by " + red + kicker + reset + ": " + green + reason)
|
|
|
+ else:
|
|
|
+ connection.action(self.homechannel, "has been kicked from " + red + channel + reset + " by " + red + kicker + reset + ".")
|
|
|
+
|
|
|
# React.
|
|
|
- if kicked == connection.get_nickname(): # Bot was kicked.
|
|
|
- if self.db.one("SELECT aggressiveness FROM channels WHERE name='" + channel + "' AND network='" + self.network + "'") == "passive": # Passive behaviour.
|
|
|
- if channel == self.homechannel: # From it's homechannel.
|
|
|
- ChanServ.unban(connection, channel, kicked)
|
|
|
- connection.privmsg("ChanServ", "UNBAN " + channel)
|
|
|
- connection.join(self.homechannel)
|
|
|
-
|
|
|
- # Report to home channel.
|
|
|
- if not channel == self.homechannel: # Not from it's homechannel.
|
|
|
- if reason:
|
|
|
- connection.action(self.homechannel, "has been kicked from " + red + channel + reset + " by " + red + kicker + reset + ": " + green + reason)
|
|
|
- else:
|
|
|
- connection.action(self.homechannel, "has been kicked from " + red + channel + reset + " by " + red + kicker + reset + ".")
|
|
|
+ behaviour = self.db.one("SELECT aggressiveness FROM channels WHERE name='" + channel + "' AND network='" + self.network + "'")
|
|
|
+ if behaviour == "passive": # Passive behaviour.
|
|
|
+ if kicked == connection.get_nickname() and channel == self.homechannel: # Bot was kicked from it's home channel.
|
|
|
+ ChanServ.unban(connection, channel, kicked)
|
|
|
+ ChanServ.akick_del(connection, channel, kicked)
|
|
|
+ connection.privmsg("ChanServ", "UNBAN " + channel)
|
|
|
+ connection.join(self.homechannel)
|
|
|
+ elif behaviour == "defense_only": # Defensive behaviour.
|
|
|
+ ChanServ.unban(connection, channel, kicked)
|
|
|
+ ChanServ.akick_del(connection, channel, kicked)
|
|
|
+ if kicked == connection.get_nickname() and channel == self.homechannel: # Bot was kicked from it's home channel.
|
|
|
+ connection.privmsg("ChanServ", "UNBAN " + channel)
|
|
|
+ connection.join(self.homechannel)
|
|
|
+ elif behaviour == "equal_retalliation": # Equal retalitory behaviour.
|
|
|
+ ChanServ.unban(connection, channel, kicked)
|
|
|
+ ChanServ.akick_del(connection, channel, kicked)
|
|
|
+
|
|
|
+ # Rejoin if bot was kicked from it's home channel.
|
|
|
+ if kicked == connection.get_nickname() and channel == self.homechannel:
|
|
|
+ connection.privmsg("ChanServ", "UNBAN " + channel)
|
|
|
+ connection.join(self.homechannel)
|
|
|
+
|
|
|
+ # Stop if the offender is a bot operator and the offended is not the bot owner or if the 2 parties are both bot owner.
|
|
|
+ if userstatus.atleast_halfop(self, kicker, self.homechannel) and not self.channels[self.homechannel].isowner(kicked) or self.channels[self.homechannel].isowner(kicked) == self.channels[self.homechannel].isowner(kicker):
|
|
|
+ return
|
|
|
+
|
|
|
+ # Kick.
|
|
|
+ ChanServ.kick(connection, channel, kicker, "Aggression channel function = equal_retalliation: " + kicked + " is an operator of " + connection.get_nickname() + ".")
|
|
|
+ connection.kick(channel, kicker, "Aggression channel function = equal_retalliation: " + kicked + " is an operator of " + connection.get_nickname() + ".")
|
|
|
+ elif behaviour == "battlebot": # Battlebot behaviour.
|
|
|
+ ChanServ.unban(connection, channel, kicked)
|
|
|
+ ChanServ.akick_del(connection, channel, kicked)
|
|
|
+
|
|
|
+ # Rejoin if bot was kicked from it's home channel.
|
|
|
+ if kicked == connection.get_nickname() and channel == self.homechannel:
|
|
|
+ connection.privmsg("ChanServ", "UNBAN " + channel)
|
|
|
+ connection.join(self.homechannel)
|
|
|
+
|
|
|
+ # Stop if the offender is a bot operator and the offended is not the bot owner or if the 2 parties are both bot owner.
|
|
|
+ if userstatus.atleast_halfop(self, kicker, self.homechannel) and not self.channels[self.homechannel].isowner(kicked) or self.channels[self.homechannel].isowner(kicked) == self.channels[self.homechannel].isowner(kicker):
|
|
|
+ return
|
|
|
+
|
|
|
+ # Ban.
|
|
|
+ ChanServ.tempban(connection, channel, kicker, "Aggression channel function = equal_retalliation: " + kicked + " is an operator of " + connection.get_nickname() + ".")
|
|
|
+ print(event.source)
|
|
|
+ print(event.target)
|
|
|
+ connection.mode(channel, "+b " + event.source)
|
|
|
+
|
|
|
+ #connection.mode(channel, "+e " + event.source) # Protect operator.
|
|
|
+ ChanServ.akick_add(connection, channel, kicker) # Add kicker to ChanServs autokick.
|
|
|
+
|
|
|
+ # Kick.
|
|
|
+ ChanServ.kick(connection, channel, kicker, "Aggression channel function = equal_retalliation: " + kicked + " is an operator of " + connection.get_nickname() + ".")
|
|
|
+ connection.kick(channel, kicker, "Aggression channel function = equal_retalliation: " + kicked + " is an operator of " + connection.get_nickname() + ".")
|