1
0

on_kick.py 5.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #from common.networkservices import ChanServ
  2. from common import log, queries #userstatus, do_everything_to, log, font, queries
  3. #from events.common import Aggressiveness, Lastact
  4. def process_event(self, connection, event):
  5. log.info(event) # Log to console
  6. # Get and update resources.
  7. reason = event.arguments[1]
  8. kicker = queries.create_or_get_and_update_last_event(self, 'user', 'ck', channel_name=event.target, user_name=event.source.nick, event_content=reason, event_subject_name=event.arguments[0])
  9. channel = queries.create_or_get_and_update_last_event(self, 'channel', 'ck', channel_name=event.target, user_name=event.source.nick, event_content=reason, event_subject_name=event.arguments[0])
  10. kicked = queries.create_or_get_and_update_last_event(self, 'user','ck', channel_name=event.target, user_name=event.arguments[0], event_content=reason, event_subject_name=event.source.nick)
  11. # Record kick event in database.
  12. queries.increment_join(self, channel.id, user.id)
  13. # # Update protectees if needed.
  14. # if channel == self.homechannel: # Kicked from home channel
  15. # if event.source.nick in self.protectees: # Protectee kicked.
  16. # del self.protectees[event.source.nick] # Remove old nick from list.
  17. #
  18. # # Do nothing more when user is not protected.
  19. # if not userstatus.atleast_halfop(self, kicked, self.homechannel) and not kicked == connection.get_nickname():
  20. # return
  21. #
  22. # # Report.
  23. # if not channel == self.homechannel: # Not kicked from homechannel.
  24. # if reason:
  25. # connection.privmsg(self.homechannel, red + kicked + reset + " has been kicked from " + red + channel + reset + " by " + red + kicker + reset + ": " + green + reason)
  26. # else:
  27. # connection.privmsg(self.homechannel, red + kicked + reset + " has been kicked from " + red + channel + reset + " by " + red + kicker + reset + ".")
  28. #
  29. # # React.
  30. # print("Reacting to kick")
  31. # behaviour = self.db.one("SELECT aggressiveness FROM channels WHERE name='" + channel + "' AND network='" + self.network + "'")
  32. # if behaviour == "passive": # Passive behaviour.
  33. # if kicked == connection.get_nickname() and channel == self.homechannel: # Bot was kicked from it's home channel.
  34. # ChanServ.unban(connection, channel, kicked)
  35. # ChanServ.akick_del(connection, channel, kicked)
  36. # connection.privmsg("ChanServ", "UNBAN " + channel)
  37. # do_everything_to.join(self, connection, self.homechannel)
  38. # elif behaviour == "defense_only": # Defensive behaviour.
  39. # ChanServ.unban(connection, channel, kicked)
  40. # ChanServ.akick_del(connection, channel, kicked)
  41. # if kicked == connection.get_nickname(): # Bot was kicked.
  42. # connection.privmsg("ChanServ", "UNBAN " + channel)
  43. # do_everything_to.join(self, connection, channel)
  44. # elif behaviour == "equal_retalliation": # Equal retalitory behaviour.
  45. # ChanServ.akick_del(connection, channel, kicked)
  46. #
  47. # # Rejoin if bot was kicked.
  48. # if kicked == connection.get_nickname():
  49. # connection.privmsg("ChanServ", "UNBAN " + channel)
  50. # do_everything_to.join(self, connection, self.homechannel)
  51. #
  52. # if event.source.nick == connection.get_nickname() or self.channels[self.homechannel].is_owner(kicker):
  53. # return # Stop if offender is bot or owner.
  54. # if not userstatus.atleast_halfop(self, kicked, self.homechannel) or not kicked == connection.get_nickname():
  55. # return # Stop if offended is not atleast halfop and is not the bot itself.
  56. # if userstatus.atleast_halfop(self, kicker, self.homechannel) and not self.channels[self.homechannel].is_owner(kicked):
  57. # return # Stop if offender is at least halfop in the home channel and the offended is not owner.
  58. #
  59. # # Kick.
  60. # do_everything_to.kick(connection, channel, kicker, Aggressiveness.retalliation_reason(self, connection, kicked, behaviour))
  61. #
  62. # # Battlebot behaviour.
  63. # elif behaviour == "battlebot":
  64. # ChanServ.akick_del(connection, channel, kicked)
  65. #
  66. # # Rejoin if bot was kicked.
  67. # if kicked == connection.get_nickname():
  68. # print("Rejoining " + channel)
  69. # do_everything_to.join(self, connection, channel)
  70. #
  71. # if event.source.nick == connection.get_nickname() or self.channels[self.homechannel].is_owner(kicker):
  72. # print("Stop if offender is bot or owner")
  73. # return # Stop if offender is bot or owner.
  74. # if not userstatus.atleast_halfop(self, kicked, self.homechannel) or not kicked == connection.get_nickname():
  75. # print("Stop if offended is not atleast halfop and is not the bot itself")
  76. # return # Stop if offended is not atleast halfop and is not the bot itself.
  77. # if userstatus.atleast_halfop(self, kicker, self.homechannel) and not self.channels[self.homechannel].is_owner(kicked):
  78. # print("Stop if offender is at least halfop in the home channel and the offended is not owner")
  79. # return # Stop if offender is at least halfop in the home channel and the offended is not owner.
  80. # print("Kickbanning")
  81. #
  82. # ChanServ.tempban(connection, channel, kicker, "1h", "Aggression channel function = equal_retalliation: " + kicked)
  83. # connection.mode(channel, "+e " + kicked) # Excempt operator.
  84. # ChanServ.akick_add(connection, channel, kicker) # Add kicker to ChanServs autokick.
  85. # do_everything_to.bankick(connection, channel, kicker, event.source, "Aggression channel function = equal_retalliation: " + kicked)