common.py 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import random
  2. from datetime import datetime
  3. from common import queries, userstatus, log
  4. class Inform():
  5. def owners(self, connection, message):
  6. log.notice('Message: %s' % (message))
  7. if self.network.home_channel in self.channels:
  8. for owner in self.channels[self.network.home_channel].owners():
  9. connection.privmsg(owner, message)
  10. def notice_owners(self, connection, message):
  11. log.notice('Message: %s' % (message))
  12. if self.network.home_channel in self.channels:
  13. for owner in self.channels[self.network.home_channel].owners():
  14. connection.notice(owner, message)
  15. def operators(self, connection, message):
  16. if self.homechannel in self.channels:
  17. for user in self.channels[self.homechannel].owners():
  18. connection.privmsg(user, message)
  19. for user in self.channels[self.homechannel].admins():
  20. connection.privmsg(user, message)
  21. for user in self.channels[self.homechannel].opers():
  22. connection.privmsg(user, message)
  23. def home_channel(self, connection, message):
  24. connection.privmsg(self.network.home_channel, message)
  25. # class Protectees():
  26. # def update(self, nick, user, host):
  27. # if nick in self.protectees: # On record.
  28. # if userstatus.atleast_halfop(self, user, self.homechannel) or nick == self.connection.get_nickname(): # Update. Is atleast halfop or bot itself.
  29. # self.protectees[nick].update({'ident': nick + "!" + user + "@" + host})
  30. # else: # Delete.
  31. # del self.protectees[nick]
  32. # else: # Append.
  33. # if userstatus.atleast_halfop(self, user, self.homechannel) or nick == self.connection.get_nickname(): # Update. Is atleast halfop or bot itself.
  34. # self.protectees[nick] = {'ident': nick + "!" + user + "@" + host}
  35. # class Replyto():
  36. # def name(connection, event):
  37. # messages = [
  38. # "Hello " + event.source.nick + ".",
  39. # "How are you today " + event.source.nick + "?",
  40. # "Piss off " + event.source.nick + "!",
  41. # event.source.nick + ", what are you botherring me for?",
  42. # "Go bother someone else...",
  43. # "Is life treating you fair?",
  44. # "What's up?",
  45. # "Why are you talking to me?",
  46. # "I'm not talking to you!",
  47. # "What have you been up to?",
  48. # "How is life?",
  49. # "What do you want from me?",
  50. # event.source.nick + ", why are you bothering me?",
  51. # event.source.nick + ", when will you stop talking about me?",
  52. # event.source.nick + " I hate you!",
  53. # "Get bent!",
  54. # "Go and cut yourself.",
  55. # "Do you think i care about you?",
  56. # "Stop nickalerting me " + event.source.nick + ", you wanker!",
  57. # ]
  58. # actions = [
  59. # "hides!",
  60. # "dies.",
  61. # "runs away.",
  62. # "is ignoring that.",
  63. # "is not feeling like caring.",
  64. # "is away",
  65. # "will be ignoring that.",
  66. # "is faggaliciouz!! <333",
  67. # "likes you! <3",
  68. # "looks the other way...",
  69. # "does a little dance with " + event.source.nick + ".",
  70. # "makes a little love.",
  71. # "get's down tonight.",
  72. # "thinks SAM Broadcaster sucks raw cocks in hell!",
  73. # "is secretly in love with " + event.source.nick + ".",
  74. # "tosses " + event.source.nick + "'s salad.",
  75. # "tortures " + event.source.nick + " horribly!",
  76. # "is smelling like tuna when looking at " + event.source.nick + ".",
  77. # "sniffing armpits.. Eew! Smells like " + event.source.nick + ".",
  78. # "rapes " + event.source.nick + ".",
  79. # "pets " + event.source.nick + ", and sais: Why what a nice little human you are, and such plentifull organs!"
  80. # ]
  81. #
  82. # # Reply with a random message or action.
  83. # if random.randint(0, 1) == 0:
  84. # connection.privmsg(event.target, random.choice(messages))
  85. # else:
  86. # connection.action(event.target, random.choice(actions))
  87. # class Aggressiveness():
  88. # def retalliation_reason(self, connection, protectee, behaviour):
  89. # if protectee == connection.get_nickname(): # Bot itself.
  90. # return "Aggression channel function = " + behaviour + ": Self defense."
  91. # else:
  92. # return "Aggression channel function = " + behaviour + ": " + protectee + " is atlast halfop in " + self.homechannel + "."
  93. #
  94. # class Lastact():
  95. # def update(self, name, type, channel=False, lastact=False, auxiliary=False):
  96. #
  97. # # Create records if not present.
  98. # if channel:
  99. # queries.create_ifnot_onrecord(self, "channels", channel)
  100. # queries.create_ifnot_onrecord(self, "users", name)
  101. #
  102. # # Update record.
  103. # self.db.run("UPDATE users SET last_act_type=%s, last_act_datetime=%s, last_act_channel=%s, last_act=%s, last_act_auxiliary=%s WHERE name=%s AND network=%s", (type, str(datetime.now()), channel, lastact, auxiliary, name, self.network))
  104. #
  105. # # Set user back from away, if user is active.
  106. # if type not in ["nick", "kick", "part", "quit"]:
  107. # self.db.run("UPDATE users SET away=FALSE WHERE name=%s AND network=%s", (name, self.network, ))
  108. #
  109. # class MessageStatistics():
  110. # def update(self, event, type):
  111. # if not self.db.one('SELECT id FROM rotbot_' + type + ' WHERE network_id=%(network_id)s AND channel_id=%(channel_id)s AND user_id=%(user_id)s', network_id=self.network.id, channel_id=channel.id ,user_id=user.id): # Not on record.
  112. # self.db.run('INSERT INTO rotbot_' + type + ' (network_id, channel_id, user_id, amount) VALUES (%(network_id)s, %(channel_id)s, %(user_id)s, 1)', network_id=self.network.id, channel_id=channel.id ,user_id=user.id) # Create record.
  113. # else: # On record.
  114. # self.db.run('UPDATE rotbot_' + type + ' SET amount = amount +1 WHERE network_id=%(network_id)s AND channel_id=%(channel_id)s AND user_id=%(user_id)s', network_id=self.network.id, channel_id=channel.id ,user_id=user.id) # Increment record.