X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~matthewv/git?p=irc.git;a=blobdiff_plain;f=commands.py;h=8c22d293a09429aa2fab542f132376c17b1cb4e0;hp=7e4a94c130ddee2eb090ca3ccb7ab8bd2332709d;hb=3c9eb543dc22210bb228cb13b2eee906f5b66226;hpb=c34dc253d46cc7ad9dc3d7955e9a34660e9c4cbb diff --git a/commands.py b/commands.py old mode 100644 new mode 100755 index 7e4a94c..8c22d29 --- 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 @@ -124,6 +125,7 @@ def slashq(bot, cmd, nick, conn, public, cfg): return me = bot.connection.get_nickname() slash_msg = random.choice(fishlist) + fishpond.last=slash_msg # The bot won't slash people with themselves if irc_lower(who[0]) == irc_lower(who[1]): conn.notice(nick, "oooooh no missus!") @@ -154,9 +156,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 +189,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,6 +216,9 @@ 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.co.uk/search?q=define%%3A%s&ie=utf-8&oe=utf-8" % urllib.quote_plus(cmdrest)) @@ -246,7 +233,7 @@ def defineq(bot, cmd, nick, conn, public): # first
  • in a