on_kick.py 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 %sby %s%s' % (font.red, event.target, font.reset, font.red, event.source.nick))
  15. connection.privmsg(event.source.nick, 'Sorry you needed to kick me. Bot\'s should serve those who enjoy it, without annoying anyone. Any channelOP can use the !settings command to change my settings.')
  16. temp_key = queries.create_tempchannelkey(self, channel.id)
  17. connection.privmsg(event.source.nick, 'Here is a temp 10 minute link for %s%s%s:%s %schannelsettings/%s' % (event.target, font.red, event.target, font.reset, self.webgui['base_ur'], temp_key))
  18. connection.privmsg(event.source.nick, 'If you have any complaints, suggestions or want me back in %s%s%s contact an operator of: %s%s' % (font.red, event.target, font.reset, font.red, self.network.home_channel))
  19. # # Update protectees if needed.
  20. # if channel == self.homechannel: # Kicked from home channel
  21. # if event.source.nick in self.protectees: # Protectee kicked.
  22. # del self.protectees[event.source.nick] # Remove old nick from list.
  23. #
  24. # # Do nothing more when user is not protected.
  25. # if not userstatus.atleast_halfop(self, kicked, self.homechannel) and not kicked == connection.get_nickname():
  26. # return
  27. #
  28. # # Report.
  29. # if not channel == self.homechannel: # Not kicked from homechannel.
  30. # if reason:
  31. # connection.privmsg(self.homechannel, red + kicked + reset + " has been kicked from " + red + channel + reset + " by " + red + kicker + reset + ": " + green + reason)
  32. # else:
  33. # connection.privmsg(self.homechannel, red + kicked + reset + " has been kicked from " + red + channel + reset + " by " + red + kicker + reset + ".")
  34. #
  35. # # React.
  36. # print("Reacting to kick")
  37. # behaviour = self.db.one("SELECT aggressiveness FROM channels WHERE name='" + channel + "' AND network='" + self.network + "'")
  38. # if behaviour == "passive": # Passive behaviour.
  39. # if kicked == connection.get_nickname() and channel == self.homechannel: # Bot was kicked from it's home channel.
  40. # ChanServ.unban(connection, channel, kicked)
  41. # ChanServ.akick_del(connection, channel, kicked)
  42. # connection.privmsg("ChanServ", "UNBAN " + channel)
  43. # do_everything_to.join(self, connection, self.homechannel)
  44. # elif behaviour == "defense_only": # Defensive behaviour.
  45. # ChanServ.unban(connection, channel, kicked)
  46. # ChanServ.akick_del(connection, channel, kicked)
  47. # if kicked == connection.get_nickname(): # Bot was kicked.
  48. # connection.privmsg("ChanServ", "UNBAN " + channel)
  49. # do_everything_to.join(self, connection, channel)
  50. # elif behaviour == "equal_retalliation": # Equal retalitory behaviour.
  51. # ChanServ.akick_del(connection, channel, kicked)
  52. #
  53. # # Rejoin if bot was kicked.
  54. # if kicked == connection.get_nickname():
  55. # connection.privmsg("ChanServ", "UNBAN " + channel)
  56. # do_everything_to.join(self, connection, self.homechannel)
  57. #
  58. # if event.source.nick == connection.get_nickname() or self.channels[self.homechannel].is_owner(kicker):
  59. # return # Stop if offender is bot or owner.
  60. # if not userstatus.atleast_halfop(self, kicked, self.homechannel) or not kicked == connection.get_nickname():
  61. # return # Stop if offended is not atleast halfop and is not the bot itself.
  62. # if userstatus.atleast_halfop(self, kicker, self.homechannel) and not self.channels[self.homechannel].is_owner(kicked):
  63. # return # Stop if offender is at least halfop in the home channel and the offended is not owner.
  64. #
  65. # # Kick.
  66. # do_everything_to.kick(connection, channel, kicker, Aggressiveness.retalliation_reason(self, connection, kicked, behaviour))
  67. #
  68. # # Battlebot behaviour.
  69. # elif behaviour == "battlebot":
  70. # ChanServ.akick_del(connection, channel, kicked)
  71. #
  72. # # Rejoin if bot was kicked.
  73. # if kicked == connection.get_nickname():
  74. # print("Rejoining " + channel)
  75. # do_everything_to.join(self, connection, channel)
  76. #
  77. # if event.source.nick == connection.get_nickname() or self.channels[self.homechannel].is_owner(kicker):
  78. # print("Stop if offender is bot or owner")
  79. # return # Stop if offender is bot or owner.
  80. # if not userstatus.atleast_halfop(self, kicked, self.homechannel) or not kicked == connection.get_nickname():
  81. # print("Stop if offended is not atleast halfop and is not the bot itself")
  82. # return # Stop if offended is not atleast halfop and is not the bot itself.
  83. # if userstatus.atleast_halfop(self, kicker, self.homechannel) and not self.channels[self.homechannel].is_owner(kicked):
  84. # print("Stop if offender is at least halfop in the home channel and the offended is not owner")
  85. # return # Stop if offender is at least halfop in the home channel and the offended is not owner.
  86. # print("Kickbanning")
  87. #
  88. # ChanServ.tempban(connection, channel, kicker, "1h", "Aggression channel function = equal_retalliation: " + kicked)
  89. # connection.mode(channel, "+e " + kicked) # Excempt operator.
  90. # ChanServ.akick_add(connection, channel, kicker) # Add kicker to ChanServs autokick.
  91. # do_everything_to.bankick(connection, channel, kicker, event.source, "Aggression channel function = equal_retalliation: " + kicked)