on_kick.py 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #from common.networkservices import ChanServ
  2. from common import log, queries, language, userstatus, font#, do_everything_to
  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 event.arguments[0] == connection.get_nickname(): # Bot kicked from channel.
  14. log.notice('I just got kicked from: %s' % event.target)
  15. 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))
  16. 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.')
  17. temp_key = queries.create_tempchannelkey(self, channel.id)
  18. 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))
  19. connection.privmsg(event.source.nick, 'Good bye. 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))
  20. return
  21. if self.channels[event.target].has_user(event.arguments[0]): # User resides in homechannel.
  22. if userstatus.is_owner(self, event.arguments[0], event.target) or queries.is_owner(self, hostmask) or event.arguments[0] == conntection.get_nickname(): # Owner or bot kicked.
  23. log.info('Kicking %s from %s for kicking %s.' % (event.sourcenick, event.target, event.arguments[0]))
  24. if reason:
  25. do_everything_to.kick(connection, event.target, event.source.nick, 'Revenge: %s' % reason)
  26. else:
  27. do_everything_to.kick(connection, event.target, event.source.nick, 'Revenge')
  28. # Mock home channel users in home channel.
  29. kicks = queries.get_user_channel_kicks(self, kicked.id, channel.id)
  30. if reason:
  31. reson_fill = ' for %s%s%s'
  32. else:
  33. reason_fill = ''
  34. message = language.add_adjective_a('mocks %s%s%s for getting kicked out of %s%s%s%s, which makes ' % (font.red, event.arguments[0], font.reset, font.red, event.target, font.reset, reason_fill), ' %s times.' % kicks)
  35. connection.action(self.network.home_channel, message)
  36. # # React.
  37. # print("Reacting to kick")
  38. # behaviour = self.db.one("SELECT aggressiveness FROM channels WHERE name='" + channel + "' AND network='" + self.network + "'")
  39. # if behaviour == "passive": # Passive behaviour.
  40. # if kicked == connection.get_nickname() and channel == self.homechannel: # Bot was kicked from it's home channel.
  41. # ChanServ.unban(connection, channel, kicked)
  42. # ChanServ.akick_del(connection, channel, kicked)
  43. # connection.privmsg("ChanServ", "UNBAN " + channel)
  44. # do_everything_to.join(self, connection, self.homechannel)
  45. # elif behaviour == "defense_only": # Defensive behaviour.
  46. # ChanServ.unban(connection, channel, kicked)
  47. # ChanServ.akick_del(connection, channel, kicked)
  48. # if kicked == connection.get_nickname(): # Bot was kicked.
  49. # connection.privmsg("ChanServ", "UNBAN " + channel)
  50. # do_everything_to.join(self, connection, channel)
  51. # elif behaviour == "equal_retalliation": # Equal retalitory behaviour.
  52. # ChanServ.akick_del(connection, channel, kicked)
  53. #
  54. # # Rejoin if bot was kicked.
  55. # if kicked == connection.get_nickname():
  56. # connection.privmsg("ChanServ", "UNBAN " + channel)
  57. # do_everything_to.join(self, connection, self.homechannel)
  58. #
  59. # if event.source.nick == connection.get_nickname() or self.channels[self.homechannel].is_owner(kicker):
  60. # return # Stop if offender is bot or owner.
  61. # if not userstatus.atleast_halfop(self, kicked, self.homechannel) or not kicked == connection.get_nickname():
  62. # return # Stop if offended is not atleast halfop and is not the bot itself.
  63. # if userstatus.atleast_halfop(self, kicker, self.homechannel) and not self.channels[self.homechannel].is_owner(kicked):
  64. # return # Stop if offender is at least halfop in the home channel and the offended is not owner.
  65. #
  66. # # Kick.
  67. # do_everything_to.kick(connection, channel, kicker, Aggressiveness.retalliation_reason(self, connection, kicked, behaviour))
  68. #
  69. # # Battlebot behaviour.
  70. # elif behaviour == "battlebot":
  71. # ChanServ.akick_del(connection, channel, kicked)
  72. #
  73. # # Rejoin if bot was kicked.
  74. # if kicked == connection.get_nickname():
  75. # print("Rejoining " + channel)
  76. # do_everything_to.join(self, connection, channel)
  77. #
  78. # if event.source.nick == connection.get_nickname() or self.channels[self.homechannel].is_owner(kicker):
  79. # print("Stop if offender is bot or owner")
  80. # return # Stop if offender is bot or owner.
  81. # if not userstatus.atleast_halfop(self, kicked, self.homechannel) or not kicked == connection.get_nickname():
  82. # print("Stop if offended is not atleast halfop and is not the bot itself")
  83. # return # Stop if offended is not atleast halfop and is not the bot itself.
  84. # if userstatus.atleast_halfop(self, kicker, self.homechannel) and not self.channels[self.homechannel].is_owner(kicked):
  85. # print("Stop if offender is at least halfop in the home channel and the offended is not owner")
  86. # return # Stop if offender is at least halfop in the home channel and the offended is not owner.
  87. # print("Kickbanning")
  88. #
  89. # ChanServ.tempban(connection, channel, kicker, "1h", "Aggression channel function = equal_retalliation: " + kicked)
  90. # connection.mode(channel, "+e " + kicked) # Excempt operator.
  91. # ChanServ.akick_add(connection, channel, kicker) # Add kicker to ChanServs autokick.
  92. # do_everything_to.bankick(connection, channel, kicker, event.source, "Aggression channel function = equal_retalliation: " + kicked)