common.py 6.1 KB

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