X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~matthewv/git?p=irc.git;a=blobdiff_plain;f=commands.py;h=19f8c4b6327f9c577c6792fd91370603cd0d1c5a;hp=637ec5fddffbbb14f4d1d9c0b5c2b302f2c48753;hb=61e45f545d8207514f70e0f8c0a27128f97e6967;hpb=9e280b60903fa9ce16809540ec6c8174adb762cd diff --git a/commands.py b/commands.py old mode 100644 new mode 100755 index 637ec5f..19f8c4b --- a/commands.py +++ b/commands.py @@ -1,5 +1,5 @@ # Part of Acrobat. -import string, cPickle, random, urllib, sys, time, re, os +import string, cPickle, random, urllib, sys, time, re, os, twitter, subprocess, datetime from irclib import irc_lower, nm_to_n # query karma @@ -36,7 +36,7 @@ def karmadelq(bot, cmd, nick, conn, public, karma): # help - provides the URL of the help file def helpq(bot, cmd, nick, conn, public): bot.automsg(public,nick, - "For help see http://www.pick.ucam.org/~matthew/irc/servus.html") + "For help see http://www.chiark.greenend.org.uk/~matthewv/irc/servus.html") # query bot status @@ -84,6 +84,7 @@ def troutq(bot, cmd, nick, conn, public, cfg): return me = bot.connection.get_nickname() trout_msg = random.choice(fishlist) + fishpond.last=trout_msg # The bot won't trout or flirt with itself; if irc_lower(me) == irc_lower(target): target = nick @@ -154,9 +155,9 @@ def unitq(bot, cmd, nick, conn, public): conn.notice(nick, "syntax: units arg1 as arg2") return if args[1]=='?': - sin,sout=os.popen2(["units","--verbose",args[0]],"r") + sin,sout=os.popen4(["units","--verbose","--",args[0]],"r") else: - sin,sout=os.popen2(["units","--verbose",args[0],args[1]],"r") + sin,sout=os.popen4(["units","--verbose","--",args[0],args[1]],"r") sin.close() res=sout.readlines() #popen2 doesn't clean up the child properly. Do this by hand @@ -187,24 +188,6 @@ def reloadq(bot, cmd, nick, conn, public): bot.automsg(public,nick, "Configuration can only be reloaded by my owner, by /msg.") -# lose the game and/or install a new trigger word -def gameq(bot, cmd, nick, conn, public, game): - #only install a new trigger if it's not too short. - if len(' '.join(cmd.split()[1:]))>2: - game.trigger=' '.join(cmd.split()[1:]) - if (time.time()> game.grace): - if not public: - if irc_lower(nick) == irc_lower(bot.owner): - conn.action(bot.channel,"loses the game!") - else: - conn.privmsg(bot.channel,nick+" just lost the game!") - else: - if not public: - conn.notice(nick, "It's a grace period!") - game.grace=time.time()+60*20 #20 minutes' grace - game.losetime=time.time()+random.randrange(game.minlose,game.maxlose) - conn.notice(bot.owner, str(game.losetime-time.time())+" "+game.trigger) - # quit irc def quitq(bot, cmd, nick, conn, public): if irc_lower(nick) == irc_lower(bot.owner): @@ -232,8 +215,11 @@ def googleq(bot, cmd, nick, conn, public): # Look up the definition of something using google def defineq(bot, cmd, nick, conn, public): + #this doesn't work any more + bot.automsg(public,nick,"'define' is broken because google are bastards :(") + return cmdrest = string.join(cmd.split()[1:]) - targ = ("http://www.google.com/search?q=define%%3A%s&ie=utf-8&oe=utf-8" + targ = ("http://www.google.co.uk/search?q=define%%3A%s&ie=utf-8&oe=utf-8" % urllib.quote_plus(cmdrest)) try: # Just slurp everything into a string @@ -242,10 +228,11 @@ def defineq(bot, cmd, nick, conn, public): # This is of course going to be a bit fragile. We first look for # 'Definitions of %s on the Web' -- if this isn't present we # assume we have the 'no definitions found page'. - # The first defn starts after the following

tag. + # The first defn starts after the following

tag, but as the + # first

  • in a