1
0

on_action.py 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. from common import queries, userstatus, font#, queries
  2. #from events.common import Replyto, Lastact, MessageStatistics
  3. def process_event(self, connection, event):
  4. # Let's not log all actions. log.info(event) # Log to console.
  5. # Get and update resources.
  6. slapper = queries.create_or_get_and_update_last_event(self, 'user', 'ca', channel_name=event.target, user_name=event.source.nick)
  7. slapped = queries.create_or_get_and_update_last_event(self, 'user', 'ca', channel_name=event.target, user_name=event.arguments[0].split(" ")[1])
  8. if event.target != connection.get_nickname(): # Channel action.
  9. channel = queries.create_or_get_and_update_last_event(self, 'channel', 'ca', channel_name=event.target, user_name=event.source.nick)
  10. queries.update_message_statistics(self, 'action', channel.id, slapper.id) # Update message statistics
  11. # Stop if chat setting is disabled.
  12. if not queries.get_channel_setting_chat(self, channel.id):
  13. return
  14. # Slaps
  15. if event.arguments[0].lower().startswith('slaps ') and not event.target == connection.get_nickname(): # Channel action that stats with "slaps ".
  16. takeitlikeaman = False
  17. takeoffense = False
  18. protect = False
  19. joinin = False
  20. if event.arguments[0].split(" ")[1].lower() == connection.get_nickname(): # Bot slapped
  21. if userstatus.atleast_voiced(self, event.source.nick, self.network.home_channel): # Slapper has atleast voice in home channel.
  22. takeitlikeaman = True
  23. else: # Bot slapped by a pleb.
  24. takeoffense = True
  25. elif userstatus.atleast_voiced(self, event.arguments[0].split(" ")[1], self.network.home_channel): # Only protect the worthy.
  26. if not userstatus.atleast_voiced(self, event.source.nick, self.network.home_channel): # But not from the worthy
  27. protect = True
  28. else: # Worthy slappning the worthy.
  29. pass
  30. elif userstatus.atleast_voiced(self, event.source.nick, self.network.home_channel): # Join the worthy.
  31. if not userstatus.atleast_voiced(self, event.arguments[0].split(" ")[1], self.network.home_channel): # But not against teh worthy.
  32. joinin = True
  33. if " with a " in event.arguments[0]: # Slapping with utensil.
  34. utensil = event.arguments[0].split(" with a ", maxsplit=1)[1]
  35. if takeitlikeaman == True:
  36. connection.action(event.target, "takes the " + utensil + " like a robot.")
  37. elif takeoffense == True:
  38. connection.action(event.target, "is covered in %s bruises and shame." % utensil)
  39. elif protect == True:
  40. connection.action(event.target, "swiftly jumps in front of " + font.red + event.arguments[0].split(" ")[1] + font.reset + " to block the " + utensil)
  41. elif joinin == True:
  42. connection.action(event.target, 'takes another %s and joins in slapping %s%s%s profusely.' % (utensil, font.red, event.arguments[0].split(" ")[1], font.reset))
  43. else: # Slapping without utensil.
  44. if takeitlikeaman == True:
  45. connection.action(event.target, "stands proud, presenting his cheek to %s%s" % (font.red, event.source.nick))
  46. elif takeoffense == True:
  47. connection.action(event.target, 'cries.')
  48. elif protect == True:
  49. connection.action(event.target, "swiftly jumps in front of " + font.red + event.arguments[0].split(" ")[1] + font.reset + " to block the slap.")
  50. elif joinin == True:
  51. connection.action(event.target, 'checks his hand and joins in slapping %s%s%s profusely.' % (font.red, event.arguments[0].split(" ")[1], font.reset))
  52. # # Respond to own name.
  53. # elif connection.get_nickname().lower() in event.arguments[0].lower() and event.source.nick is not connection.get_nickname(): # Bot's name was mentioned, not by the bot itself.
  54. # Replyto.name(connection, event)