| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- import random
- from datetime import datetime
- from common import queries, userstatus, log
- class Protectees():
- def update(self, nick, user, host):
- if nick in self.protectees: # On record.
- if userstatus.atleast_halfop(self, user, self.homechannel) or nick == self.connection.get_nickname(): # Update. Is atleast halfop or bot itself.
- self.protectees[nick].update({'ident': nick + "!" + user + "@" + host})
- else: # Delete.
- del self.protectees[nick]
- else: # Append.
- if userstatus.atleast_halfop(self, user, self.homechannel) or nick == self.connection.get_nickname(): # Update. Is atleast halfop or bot itself.
- self.protectees[nick] = {'ident': nick + "!" + user + "@" + host}
- class Replyto():
- def name(connection, event):
- messages = [
- "Hello " + event.source.nick + ".",
- "How are you today " + event.source.nick + "?",
- "Piss off " + event.source.nick + "!",
- event.source.nick + ", what are you botherring me for?",
- "Go bother someone else...",
- "Is life treating you fair?",
- "What's up?",
- "Why are you talking to me?",
- "I'm not talking to you!",
- "What have you been up to?",
- "How is life?",
- "What do you want from me?",
- event.source.nick + ", why are you bothering me?",
- event.source.nick + ", when will you stop talking about me?",
- event.source.nick + " I hate you!",
- "Get bent!",
- "Go and cut yourself.",
- "Do you think i care about you?",
- "Stop nickalerting me " + event.source.nick + ", you wanker!",
- ]
- actions = [
- "hides!",
- "dies.",
- "runs away.",
- "is ignoring that.",
- "is not feeling like caring.",
- "is away",
- "will be ignoring that.",
- "is faggaliciouz!! <333",
- "likes you! <3",
- "looks the other way...",
- "does a little dance with " + event.source.nick + ".",
- "makes a little love.",
- "get's down tonight.",
- "thinks SAM Broadcaster sucks raw cocks in hell!",
- "is secretly in love with " + event.source.nick + ".",
- "tosses " + event.source.nick + "'s salad.",
- "tortures " + event.source.nick + " horribly!",
- "is smelling like tuna when looking at " + event.source.nick + ".",
- "sniffing armpits.. Eew! Smells like " + event.source.nick + ".",
- "rapes " + event.source.nick + ".",
- "pets " + event.source.nick + ", and sais: Why what a nice little human you are, and such plentifull organs!"
- ]
- # Reply with a random message or action.
- if random.randint(0, 1) == 0:
- connection.privmsg(event.target, random.choice(messages))
- else:
- connection.action(event.target, random.choice(actions))
- class Aggressiveness():
- def retalliation_reason(self, connection, protectee, behaviour):
- if protectee == connection.get_nickname(): # Bot itself.
- return "Aggression channel function = " + behaviour + ": Self defense."
- else:
- return "Aggression channel function = " + behaviour + ": " + protectee + " is atlast halfop in " + self.homechannel + "."
- class Lastact():
- def update(self, name, type, channel=False, lastact=False, auxiliary=False):
- # Create records if not present.
- if channel:
- queries.create_ifnot_onrecord(self, "channels", channel)
- queries.create_ifnot_onrecord(self, "users", name)
- # Update record.
- 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))
- # Set user back from away, if user is active.
- if type not in ["nick", "kick", "part", "quit"]:
- self.db.run("UPDATE users SET away=FALSE WHERE name=%s AND network=%s", (name, self.network, ))
- class MessageStatistics():
- def update(self, event, type):
- if type == 'message':
- type='m'
- elif type == 'action':
- type='a'
- elif type == 'notice':
- type='n'
- channel = queries.create_ifnot_onrecord(self, 'channel', event.target)
- user = queries.create_ifnot_onrecord(self, 'user', event.source.nick)
- if not self.db.one('SELECT id FROM rotbot_message WHERE network_id=%(network_id)s AND channel_id=%(channel_id)s AND user_id=%(user_id)s AND type=%(type)s', network_id=self.network.id, channel_id=channel.id ,user_id=user.id, type=type): # Not on record.
- self.db.run('INSERT INTO rotbot_message (network_id, channel_id, user_id, type, amount) VALUES (%(network_id)s, %(channel_id)s, %(user_id)s, %(type)s, 1)', network_id=self.network.id, channel_id=channel.id ,user_id=user.id, type=type) # Create record.
- else: # On record.
- self.db.run('UPDATE rotbot_message SET amount = amount +1 WHERE network_id=%(network_id)s AND channel_id=%(channel_id)s AND user_id=%(user_id)s AND type=%(type)s', network_id=self.network.id, channel_id=channel.id ,user_id=user.id, type=type) # Increment record.
- class Inform():
- def owners(self, connection, message):
- log.notice('Message: %s' % (message))
- if self.network.home_channel in self.channels:
- for owner in self.channels[self.network.home_channel].owners():
- connection.privmsg(owner, message)
- def notice_owners(self, connection, message):
- log.notice('Message: %s' % (message))
- if self.network.home_channel in self.channels:
- for owner in self.channels[self.network.home_channel].owners():
- connection.notice(owner, message)
- def operators(self, connection, message):
- if self.homechannel in self.channels:
- for user in self.channels[self.homechannel].owners():
- connection.privmsg(user, message)
- for user in self.channels[self.homechannel].admins():
- connection.privmsg(user, message)
- for user in self.channels[self.homechannel].opers():
- connection.privmsg(user, message)
|