1
0

on_kick.py 5.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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_kick(self, channel.id, kicker.id, kicked.id)
  13. if kicked.name == connection.get_nickname() or kicked.name == self.network.nickname:
  14. connection.action(self.network.home_channel, 'just got kicked from: %s%s' % (font.red, event.target))
  15. # # Update protectees if needed.
  16. # if channel == self.homechannel: # Kicked from home channel
  17. # if event.source.nick in self.protectees: # Protectee kicked.
  18. # del self.protectees[event.source.nick] # Remove old nick from list.
  19. #
  20. # # Do nothing more when user is not protected.
  21. # if not userstatus.atleast_halfop(self, kicked, self.homechannel) and not kicked == connection.get_nickname():
  22. # return
  23. #
  24. # # Report.
  25. # if not channel == self.homechannel: # Not kicked from homechannel.
  26. # if reason:
  27. # connection.privmsg(self.homechannel, red + kicked + reset + " has been kicked from " + red + channel + reset + " by " + red + kicker + reset + ": " + green + reason)
  28. # else:
  29. # connection.privmsg(self.homechannel, red + kicked + reset + " has been kicked from " + red + channel + reset + " by " + red + kicker + reset + ".")
  30. #
  31. # # React.
  32. # print("Reacting to kick")
  33. # behaviour = self.db.one("SELECT aggressiveness FROM channels WHERE name='" + channel + "' AND network='" + self.network + "'")
  34. # if behaviour == "passive": # Passive behaviour.
  35. # if kicked == connection.get_nickname() and channel == self.homechannel: # Bot was kicked from it's home channel.
  36. # ChanServ.unban(connection, channel, kicked)
  37. # ChanServ.akick_del(connection, channel, kicked)
  38. # connection.privmsg("ChanServ", "UNBAN " + channel)
  39. # do_everything_to.join(self, connection, self.homechannel)
  40. # elif behaviour == "defense_only": # Defensive behaviour.
  41. # ChanServ.unban(connection, channel, kicked)
  42. # ChanServ.akick_del(connection, channel, kicked)
  43. # if kicked == connection.get_nickname(): # Bot was kicked.
  44. # connection.privmsg("ChanServ", "UNBAN " + channel)
  45. # do_everything_to.join(self, connection, channel)
  46. # elif behaviour == "equal_retalliation": # Equal retalitory behaviour.
  47. # ChanServ.akick_del(connection, channel, kicked)
  48. #
  49. # # Rejoin if bot was kicked.
  50. # if kicked == connection.get_nickname():
  51. # connection.privmsg("ChanServ", "UNBAN " + channel)
  52. # do_everything_to.join(self, connection, self.homechannel)
  53. #
  54. # if event.source.nick == connection.get_nickname() or self.channels[self.homechannel].is_owner(kicker):
  55. # return # Stop if offender is bot or owner.
  56. # if not userstatus.atleast_halfop(self, kicked, self.homechannel) or not kicked == connection.get_nickname():
  57. # return # Stop if offended is not atleast halfop and is not the bot itself.
  58. # if userstatus.atleast_halfop(self, kicker, self.homechannel) and not self.channels[self.homechannel].is_owner(kicked):
  59. # return # Stop if offender is at least halfop in the home channel and the offended is not owner.
  60. #
  61. # # Kick.
  62. # do_everything_to.kick(connection, channel, kicker, Aggressiveness.retalliation_reason(self, connection, kicked, behaviour))
  63. #
  64. # # Battlebot behaviour.
  65. # elif behaviour == "battlebot":
  66. # ChanServ.akick_del(connection, channel, kicked)
  67. #
  68. # # Rejoin if bot was kicked.
  69. # if kicked == connection.get_nickname():
  70. # print("Rejoining " + channel)
  71. # do_everything_to.join(self, connection, channel)
  72. #
  73. # if event.source.nick == connection.get_nickname() or self.channels[self.homechannel].is_owner(kicker):
  74. # print("Stop if offender is bot or owner")
  75. # return # Stop if offender is bot or owner.
  76. # if not userstatus.atleast_halfop(self, kicked, self.homechannel) or not kicked == connection.get_nickname():
  77. # print("Stop if offended is not atleast halfop and is not the bot itself")
  78. # return # Stop if offended is not atleast halfop and is not the bot itself.
  79. # if userstatus.atleast_halfop(self, kicker, self.homechannel) and not self.channels[self.homechannel].is_owner(kicked):
  80. # print("Stop if offender is at least halfop in the home channel and the offended is not owner")
  81. # return # Stop if offender is at least halfop in the home channel and the offended is not owner.
  82. # print("Kickbanning")
  83. #
  84. # ChanServ.tempban(connection, channel, kicker, "1h", "Aggression channel function = equal_retalliation: " + kicked)
  85. # connection.mode(channel, "+e " + kicked) # Excempt operator.
  86. # ChanServ.akick_add(connection, channel, kicker) # Add kicker to ChanServs autokick.
  87. # do_everything_to.bankick(connection, channel, kicker, event.source, "Aggression channel function = equal_retalliation: " + kicked)