1
0

on_action.py 3.8 KB

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