Added support for more countries (should support all english-speaking

countries) and added support for ebay.com/.*?/ws as opposed to just
ebay.com/ws
This commit is contained in:
James Vega 2003-11-03 00:16:43 +00:00
parent 96f299c10c
commit 72e554350b
2 changed files with 22 additions and 7 deletions

View File

@ -85,15 +85,16 @@ class Ebay(callbacks.PrivmsgCommandAndRegexp, plugins.Toggleable):
_info = re.compile(r'<title>eBay item (\d+) \([^)]+\) - ([^<]+)</title>',
_reopts)
_bid = re.compile(r'Current (bid):.+?<b>([^<]+?)<font', _reopts)
_bid = re.compile(r'((?:Current|Starting) bid):.+?<b>([^<]+?)<font',
_reopts)
_winningBid = re.compile(r'(Winning bid|Sold for):.+?<b>([^<]+?)<font',
_reopts)
_time = re.compile(r'(Time left):.+?<b>([^<]+?)</b>', _reopts)
_bidder = re.compile(r'(High bidder):.+?<a href[^>]+>([^<]+)</a>.+?<a '\
'href[^>]+>(\d+)</a>', _reopts)
_bidder = re.compile(r'(High bidder):.+?(?:">(User ID) (kept private)'\
'</font>|<a href[^>]+>([^<]+)</a>.+?<a href[^>]+>(\d+)</a>)', _reopts)
_winningBidder = re.compile(r'(Winning bidder|Buyer):.+?<a href[^>]+>'\
'([^<]+)</a>.+?<a href[^>]+>(\d+)</a>', _reopts)
_buyNow = re.compile(r'alt="(Buy It Now)">.*?<b>([^<]+)</b>')
_buyNow = re.compile(r'alt="(Buy It Now)">.*?<b>([^<]+)</b>', _reopts)
_seller = re.compile(r'(Seller information).+?<a href[^>]+>([^<]+)</a>'\
'.+ViewFeedback.+">(\d+)</a>', _reopts)
_searches = (_bid, _winningBid, _time, _bidder, _winningBidder, _buyNow,
@ -120,8 +121,8 @@ class Ebay(callbacks.PrivmsgCommandAndRegexp, plugins.Toggleable):
self._getResponse(irc, msg, url)
def ebaySnarfer(self, irc, msg, match):
r"http://cgi\.ebay\.com/ws/eBayISAPI\.dll\?ViewItem(?:&item=\d+|"\
"&category=\d+)+"
r"http://cgi\.ebay\.(?:com(?:.au)?|ca|co.uk)/(?:.*?/)?(?:ws/)?"\
r"eBayISAPI\.dll\?ViewItem(?:&item=\d+|&category=\d+)+"
if not self.toggles.get('auction', channel=msg.args[0]):
return
url = match.group(0)
@ -143,7 +144,11 @@ class Ebay(callbacks.PrivmsgCommandAndRegexp, plugins.Toggleable):
m = r.search(s)
if m:
if r in self._multiField:
resp.append('%s: %s (%s)' % self._bold(m.groups()))
#debug.printf(m.groups())
# [:3] is to make sure that we don't pass a tuple with
# more than 3 items. this allows self._bidder to work
# since self._bidder returns a 5 item tuple
resp.append('%s: %s (%s)' % self._bold(m.groups()[:3]))
else:
resp.append('%s: %s' % self._bold(m.groups()))
if resp:

View File

@ -44,6 +44,16 @@ class EbayTest(PluginTestCase, PluginDocumentation):
self.assertRegexp('http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&'\
'category=28033&item=3053353651', '.*Cisco 2524 Router - NO '\
'RESERVE.*izontech \(.*')
# test snarfing other countries
self.assertRegexp('http://cgi.ebay.ca/ws/eBayISAPI.dll?ViewItem&'\
'item=2357056673', 'Buffalo Pemmican')
self.assertRegexp('http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&'\
'item=2355464443', 'Any Clear Crazy')
self.assertRegexp('http://cgi.ebay.com.au/ws/eBayISAPI.dll?ViewItem&'\
'item=2762983161&category=4607', 'Apple Mac G4')
# test .com/.*/ws/eBat compatibility
self.assertRegexp('http://cgi.ebay.com/ebaymotors/ws/eBayISAPI.dll?'\
'ViewItem&item=2439393310&category=33708', '88-89 CRX amber')
def testToggle(self):
self.assertHelp('ebay toggle')