+ # list know commands
+ def listq(self, cmd, nick, conn, public):
+ conn.notice(nick, "%s" % string.join(self.known))
+ # flirt with someone
+ def flirtq(self, cmd, nick, conn, public):
+ self.fish_quota()
+ if self.DoS == 1:
+ conn.notice(nick, "Sorry, but %s made me take Holy Orders." %
+ self.Boring_Git)
+ return
+ if self.cur_fish <= 0:
+ conn.notice(nick, "My libido is over-used!")
+ else:
+ self.cur_fish -=1
+ try:
+ target = string.join(cmd.split()[1:])
+ me = self.connection.get_nickname()
+ trout_msg = random.choice(self.flirts)
+ # ...and touchy.
+ if me.lower() == target.lower():
+ target = nick
+ if public == 0:
+ if random.random() <= 0.1:
+ trout_msg+= ' (but %s is their secret admirer)' % nick
+ conn.action(self.channel, trout_msg % target)
+ except IndexError:
+ conn.notice(nick, "Who do you wish me to flirt with?")
+
+ # trout someone
+ def troutq(self, cmd, nick, conn, public):
+ self.fish_quota()
+ if self.DoS == 1:
+ conn.notice(nick, "Sorry, but %s is being a spoilsport." %
+ self.Boring_Git)
+ return
+ if self.cur_fish <= 0:
+ conn.notice(nick, "Fish stocks exhausted.")
+ else:
+ self.cur_fish -=1
+ try:
+ target = string.join(cmd.split()[1:])
+ me = self.connection.get_nickname()
+ trout_msg = random.choice(self.trouts)
+# # The bot is loyal(ish)...
+# if target.lower() == self.owner.lower():
+# target = nick
+ # ...and touchy.
+ if me.lower() == target.lower():
+ target = nick
+ if public == 0:
+ if random.random() <= 0.1:
+ trout_msg+= ' (at the instigation of %s)' % nick
+ conn.action(self.channel, trout_msg % target)
+ except IndexError:
+ conn.notice(nick, "Who do you wish me to trout?")
+
+ # stock up on trouts
+ def reloadq(self, cmd, nick, conn, public):
+ if irc_lower(nick) == irc_lower(self.owner):
+ tback = self.trouts
+ fback = self.flirts
+ try:
+ f = open("trouts", "r")
+ self.trouts = [l.strip() for l in f.readlines() if l.find("%s") != -1]
+ f.close()
+ f = open("flirts", "r")
+ self.flirts = [l.strip() for l in f.readlines() if l.find("%s") != -1]
+ conn.notice(nick, "I am re-armed!")
+ except IOError:
+ conn.notice(nick, "Trout re-arming failed!")
+ self.trouts = tback
+ self.flirts = fback
+ else:
+ conn.notice(nick, "This command can only be invoked by my owner.")
+ # Shut up trouting for a minute
+ def nofish(self, cmd, nick, conn, public):
+ self.cur_fish=0
+ self.DoS=1
+ self.Boring_Git=nick
+ self.quotatime=time.time()
+ self.quotatime+=60 #60 seconds of no fishing
+ conn.notice(nick, "Fish stocks depleted, as you wish.")
+ # Check on fish stocks
+ def fish_quota(self):
+ if self.DoS==1:
+ if time.time()>=self.quotatime:
+ self.DoS=0
+ else:
+ return
+ if self.DoS==0:
+ if (time.time()-self.quotatime)>self.fish_time_inc:
+ self.cur_fish+=(((time.time()-self.quotatime)/self.fish_time_inc)*self.fish_inc)
+ if self.cur_fish>self.max_fish:
+ self.cur_fish=self.max_fish
+ self.quotatime=time.time()
+