chiark
/
gitweb
/
~matthewv
/
irc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
new flirt from rjk
[irc.git]
/
commands.py
diff --git
a/commands.py
b/commands.py
index 4bdc45ce01dcc632ae861a4194ced4a9f5c48aed..b2df479f8eef6f4ef0c0a2834f94721053942fd8 100644
(file)
--- a/
commands.py
+++ b/
commands.py
@@
-233,7
+233,7
@@
def googleq(bot, cmd, nick, conn, public):
# Look up the definition of something using google
def defineq(bot, cmd, nick, conn, public):
cmdrest = string.join(cmd.split()[1:])
# Look up the definition of something using google
def defineq(bot, cmd, nick, conn, public):
cmdrest = string.join(cmd.split()[1:])
- targ = ("http://www.google.co
m
/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
% urllib.quote_plus(cmdrest))
try:
# Just slurp everything into a string
@@
-242,16
+242,17
@@
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'.
# 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 <p> tag.
+ # The first defn starts after the following <p> tag, but as the
+ # first <li> in a <ul type="disc" class=std>
# Following that we assume that each definition is all the non-markup
# before a <br> tag. Currently we just dump out the first definition.
# Following that we assume that each definition is all the non-markup
# before a <br> tag. Currently we just dump out the first definition.
- match = re.search(r"Definitions of <b>.*?</b> on the Web.*?<
p>\s*([^>]*)<br>
",defnpage,re.MULTILINE)
+ match = re.search(r"Definitions of <b>.*?</b> on the Web.*?<
li>\s*([^>]*)((<br>)|(<li>))
",defnpage,re.MULTILINE)
if match == None:
bot.automsg(public,nick,"Some things defy definition.")
else:
# We assume google has truncated the definition for us so this
# won't flood the channel with text...
if match == None:
bot.automsg(public,nick,"Some things defy definition.")
else:
# We assume google has truncated the definition for us so this
# won't flood the channel with text...
- defn = " ".join(match.group(1).split("\n"))
;
+ defn = " ".join(match.group(1).split("\n"))
bot.automsg(public,nick,defn)
except IOError: # if the connection times out. This blocks. :(
bot.automsg(public,nick,"The web's broken. Waah!")
bot.automsg(public,nick,defn)
except IOError: # if the connection times out. This blocks. :(
bot.automsg(public,nick,"The web's broken. Waah!")
@@
-280,8
+281,11
@@
def disconnq(bot, cmd, nick, conn, public):
bot.disconnect(msg="Be right back.")
### list keys of a dictionary
bot.disconnect(msg="Be right back.")
### list keys of a dictionary
-def listkeysq(bot, cmd, nick, conn, public, dict):
- bot.automsg(public,nick,string.join(dict.keys()))
+def listkeysq(bot, cmd, nick, conn, public, dict, sort=False):
+ d=dict.keys()
+ if sort:
+ d.sort()
+ bot.automsg(public,nick,string.join(d))
### rot13 text (yes, I could have typed out the letters....)
### also "foo".encode('rot13') would have worked
### rot13 text (yes, I could have typed out the letters....)
### also "foo".encode('rot13') would have worked