Added cyborg.

This commit is contained in:
Jeremy Fincher 2004-01-23 16:41:01 +00:00
parent 75ef7630a8
commit f3b49e4e88
2 changed files with 19 additions and 0 deletions

View File

@ -1,3 +1,6 @@
* Added Http.cyborg, a fun little command for getting cyborg
abbreviations for names.
* Added Sourceforge.totalbugs and Sourceforge.totalrfes
* Removed Admin.setprefixchar, since it's unneeded with the new

View File

@ -202,6 +202,22 @@ class Http(callbacks.Privmsg):
quote = ' // '.join(quote.splitlines())
irc.reply(quote)
_cyborgRe = re.compile(r'<p class="mediumheader">(.*?)</p>', re.I)
def cyborg(self, irc, msg, args):
"""<name>
Returns a cyborg acronym for <name> from <http://www.cyborgname.com/>.
"""
name = privmsgs.getArgs(args)
name = urllib.quote(name)
url = 'http://www.cyborgname.com/cyborger.cgi?acronym=%s' % name
html = webutils.getUrl(url)
m = self._cyborgRe.search(html)
if m:
irc.reply(m.group(1))
else:
irc.errorPossibleBug('No cyborg name returned.')
_acronymre = re.compile(r'valign="middle" width="7\d%" bgcolor="[^"]+">'
r'(?:<b>)?([^<]+)')
def acronym(self, irc, msg, args):