BonusLevel: distinguish between packs and levels in output

This commit is contained in:
James Lu 2015-09-13 13:24:41 -07:00
parent 84dc5d4531
commit 3cad53b5bd

View File

@ -56,9 +56,9 @@ class BonusLevel(callbacks.PluginRegexp):
def _packid(self, irc, packid): def _packid(self, irc, packid):
url = 'http://www.bonuslevel.org/games/pack_-_%s.html' % packid url = 'http://www.bonuslevel.org/games/pack_-_%s.html' % packid
return self._fetch(irc, url) return self._fetch(irc, url, itemname="Pack")
def _fetch(self, irc, url): def _fetch(self, irc, url, itemname="Level"):
self.log.debug('BonusLevel: fetching URL %s', url) self.log.debug('BonusLevel: fetching URL %s', url)
data = utils.web.getUrl(url) data = utils.web.getUrl(url)
soup = BeautifulSoup(data) soup = BeautifulSoup(data)
@ -71,7 +71,7 @@ class BonusLevel(callbacks.PluginRegexp):
gamelink = linkobj["href"].replace('..', 'http://www.bonuslevel.org') gamelink = linkobj["href"].replace('..', 'http://www.bonuslevel.org')
title = linkobj.find("span", class_="gtitle").text title = linkobj.find("span", class_="gtitle").text
author = div.ul.find_all('li')[1].a.text.strip() author = div.ul.find_all('li')[1].a.text.strip()
s = format("Level %s by %s: %u", ircutils.bold(title), ircutils.bold(author), gamelink) s = format("%s %s by %s: %u", itemname, ircutils.bold(title), ircutils.bold(author), gamelink)
irc.reply(s) irc.reply(s)
def levelSnarfer(self, irc, msg, match): def levelSnarfer(self, irc, msg, match):