chiark / gitweb /
the products of larks twisted imagination
[irc.git] / acrobat-chiark-0.2.py
index 7098c4965f07e2401d9edf96bca1f2fa610378ee..bcc25dcd664b7ec8f86649befca594bfab786212 100755 (executable)
@@ -51,7 +51,7 @@ class Acrobat(SingleServerIRCBot):
         self.owner = owner
         self.quotatime = time.time()
         #List of known !commands we respond to
-        self.known =['karma','trout','info','die','quiet','list','google','say','do']
+        self.known =['karma','trout','info','die','quiet','list','google','say','do','reload','flirt']
         #Configurable stuff - how often do we add how many fish?
         self.cur_fish=5
         self.max_fish=5       #Maximum of 5 fish
@@ -72,6 +72,12 @@ class Acrobat(SingleServerIRCBot):
             f.close()
         except IOError:
             self.trouts = [ "hits %s with a wet trout.", "thwaps %s.", "questions %s's parentage.", "pokes its tounge out at %s.", "bites its thumb at %s."]
+        try:
+            f = open("flirts", "r")
+            self.flirts = [l.strip() for l in f.readlines() if l.find("%s") != -1]
+            f.close()
+        except IOError:
+            self.flirts = [ "falls madly in love with %s", "blows kisses at %s"]
 
     ## EVENT HANDLERS
             
@@ -164,7 +170,31 @@ class Acrobat(SingleServerIRCBot):
     # 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()
@@ -187,7 +217,7 @@ class Acrobat(SingleServerIRCBot):
                 if me.lower() == target.lower():
                     target = nick
                 if public == 0:
-                    if random.random() <= 0.25:
+                    if random.random() <= 0.1:
                         trout_msg+= ' (at the instigation of %s)' % nick
                 conn.action(self.channel, trout_msg % target)
             except IndexError:
@@ -197,14 +227,18 @@ class Acrobat(SingleServerIRCBot):
     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
@@ -228,8 +262,6 @@ class Acrobat(SingleServerIRCBot):
                 if self.cur_fish>self.max_fish:
                     self.cur_fish=self.max_fish
                 self.quotatime=time.time()
-                print self.cur_fish
-                print self.quotatime
 
     # quit irc
     def quit(self, cmd, nick, conn, public):
@@ -293,6 +325,8 @@ class Acrobat(SingleServerIRCBot):
         # weaponry
         if cmd.split()[0] == "trout":
             self.troutq(cmd, nick, conn, public)
+        if cmd.split()[0] == "flirt":
+            self.flirtq(cmd, nick, conn, public)
         if cmd == "reload":
             self.reloadq(cmd, nick, conn, public)