chiark / gitweb /
Spell annihilates properly
[irc.git] / acrobat-chiark-0.2.py
index 0d9757d68d90a421f37ec76cde3b3057a988aefc..63f52e3b38cf7cd7fc5f4450878cd4a4542f6a76 100755 (executable)
@@ -50,6 +50,8 @@ class Acrobat(SingleServerIRCBot):
         self.channel = channel
         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','reload']
         #Configurable stuff - how often do we add how many fish?
         self.cur_fish=5
         self.max_fish=5       #Maximum of 5 fish
@@ -86,15 +88,15 @@ class Acrobat(SingleServerIRCBot):
            and (irc_lower(a[0]) == irc_lower(self.connection.get_nickname())
                 or irc_lower(a[0])[:-1] == irc_lower(self.connection.get_nickname())):
 
-            self.do_command(self.channel, string.strip(a[1]), public = 1)
+            self.do_command(nm_to_n(evt.source()), string.strip(a[1]), public = 1)
         if a[0].endswith("++"):
             self.karmaup(a[0])
         if a[0].endswith("--"):
             self.karmadown(a[0])
         if payload[0] == "!" and len(payload)>1:
-            self.do_command(self.channel, string.strip(payload[1:]), public=1)
+            self.do_command(nm_to_n(evt.source()), string.strip(payload[1:]), public=1)
         if payload[0] == "~" and len(payload)>1:
-            self.do_command(self.channel, string.strip(payload[1:]), public=1)
+            self.do_command(nm_to_n(evt.source()), string.strip(payload[1:]), public=1)
 
     # And now bot commands;
 
@@ -159,6 +161,10 @@ class Acrobat(SingleServerIRCBot):
             conn.notice(nick, "My owner is %s; I have karma on %s items." %
                         (self.owner, len(self.karma.dict.keys())))
 
+    # list know commands
+    def listq(self, cmd, nick, conn, public):
+        conn.notice(nick, "%s" % string.join(self.known))
+
     # trout someone
     def troutq(self, cmd, nick, conn, public):
         self.fish_quota()
@@ -166,7 +172,7 @@ class Acrobat(SingleServerIRCBot):
             conn.notice(nick, "Sorry, but %s is being a spoilsport." %
                         self.Boring_Git)
             return
-        if self.cur_fish == 0:
+        if self.cur_fish <= 0:
             conn.notice(nick, "Fish stocks exhausted.")
         else:
             self.cur_fish -=1
@@ -180,10 +186,10 @@ class Acrobat(SingleServerIRCBot):
                 # ...and touchy.
                 if me.lower() == target.lower():
                     target = nick
-                conn.action(self.channel, trout_msg % target)
                 if public == 0:
                     if random.random() <= 0.1:
-                        conn.action(self.channel, "notes %s is conducting a whispering campaign" % nick)
+                        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?")
 
@@ -248,17 +254,17 @@ class Acrobat(SingleServerIRCBot):
                 if public == 0:
                     conn.notice(nick, str(gsearch))
                 else: # we haven't found anything.
-                    conn.privmsg(nick, str(gsearch))
+                    conn.privmsg(self.channel, str(gsearch))
             else:
                 if public == 0:
                     conn.notice(nick, "No pages found.")
                 else:
-                    conn.privmsg(nick, "No pages found.")
+                    conn.privmsg(self.channel, "No pages found.")
         except IOError: # if the connection times out. This blocks. :(
             if public == 0:
                 conn,notice(nick, "The web's broken. Waah!")
             else:
-                conn.privmsg(nick, "The web's broken. Waah!")
+                conn.privmsg(self.channel, "The web's broken. Waah!")
                 
     # General query handler
     def do_command(self, nick, cmd, public=0):
@@ -279,6 +285,9 @@ class Acrobat(SingleServerIRCBot):
         if cmd == "info":
             self.infoq(cmd, nick, conn, public)
 
+        # Known commands
+        if cmd == "list":
+            self.listq(cmd, nick, conn, public)
         # weaponry
         if cmd.split()[0] == "trout":
             self.troutq(cmd, nick, conn, public)