commands.wrap update

This commit is contained in:
James Vega 2004-10-27 03:26:55 +00:00
parent d2fb6fb4f8
commit 631da9c13f
2 changed files with 91 additions and 138 deletions

View File

@ -37,16 +37,16 @@ __revision__ = "$Id$"
__author__ = supybot.authors.jamessan __author__ = supybot.authors.jamessan
import getopt import getopt
import supybot.plugins as plugins
import amazon import amazon
import supybot.registry as registry
import supybot.conf as conf import supybot.conf as conf
import supybot.utils as utils import supybot.utils as utils
from supybot.commands import *
import supybot.plugins as plugins
import supybot.ircutils as ircutils import supybot.ircutils as ircutils
import supybot.privmsgs as privmsgs import supybot.privmsgs as privmsgs
import supybot.registry as registry
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
@ -138,21 +138,17 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
self.log.warning(str(e)) self.log.warning(str(e))
return res return res
def isbn(self, irc, msg, args): def isbn(self, irc, msg, args, channel, optlist, isbn):
"""[--url] <isbn> """[--url] <isbn>
Returns the book matching the given ISBN number. If --url is Returns the book matching the given ISBN number. If --url is
specified, a link to amazon.com's page for the book will also be specified, a link to amazon.com's page for the book will also be
returned. returned.
""" """
opts = ['url']
(optlist, rest) = getopt.getopt(args, '', opts)
url = False url = False
for (option, argument) in optlist: for (option, argument) in optlist:
option = option.lstrip('-')
if option == 'url': if option == 'url':
url = True url = True
isbn = privmsgs.getArgs(rest)
isbn = isbn.replace('-', '').replace(' ', '') isbn = isbn.replace('-', '').replace(' ', '')
attribs = {'ProductName' : 'title', attribs = {'ProductName' : 'title',
'Manufacturer' : 'publisher', 'Manufacturer' : 'publisher',
@ -162,9 +158,8 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
} }
s = '%(title)s, written by %(author)s; published by ' \ s = '%(title)s, written by %(author)s; published by ' \
'%(publisher)s; price: %(price)s%(url)s' '%(publisher)s; price: %(price)s%(url)s'
chan = msg.args[0] bold = self.registryValue('bold', channel)
bold = self.registryValue('bold', chan) region = self.registryValue('region', channel)
region = self.registryValue('region', chan)
try: try:
book = amazon.searchByKeyword(isbn, locale=region) book = amazon.searchByKeyword(isbn, locale=region)
res = self._genResults(s, attribs, book, url, bold, 'title') res = self._genResults(s, attribs, book, url, bold, 'title')
@ -172,24 +167,20 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))
return return
except amazon.AmazonError, e: except amazon.AmazonError, e:
pass irc.error('No book was found with that ISBN.')
irc.error('No book was found with that ISBN.') isbn = wrap(isbn, ['channel', getopts({'url':''}), 'text'])
def books(self, irc, msg, args): def books(self, irc, msg, args, channel, optlist, keyword):
"""[--url] <keywords> """[--url] <keywords>
Returns the books matching the given <keywords> search. If --url is Returns the books matching the given <keywords> search. If --url is
specified, a link to amazon.com's page for the book will also be specified, a link to amazon.com's page for the book will also be
returned. returned.
""" """
opts = ['url']
(optlist, rest) = getopt.getopt(args, '', opts)
url = False url = False
for (option, argument) in optlist: for (option, _) in optlist:
option = option.lstrip('-')
if option == 'url': if option == 'url':
url = True url = True
keyword = privmsgs.getArgs(rest)
attribs = {'ProductName' : 'title', attribs = {'ProductName' : 'title',
'Manufacturer' : 'publisher', 'Manufacturer' : 'publisher',
'Authors' : 'author', 'Authors' : 'author',
@ -198,9 +189,8 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
} }
s = '%(title)s, written by %(author)s; published by ' \ s = '%(title)s, written by %(author)s; published by ' \
'%(publisher)s; price: %(price)s%(url)s' '%(publisher)s; price: %(price)s%(url)s'
chan = msg.args[0] region = self.registryValue('region', channel)
region = self.registryValue('region', chan) bold = self.registryValue('bold', channel)
bold = self.registryValue('bold', chan)
try: try:
books = amazon.searchByKeyword(keyword, locale=region) books = amazon.searchByKeyword(keyword, locale=region)
res = self._genResults(s, attribs, books, url, bold, 'title') res = self._genResults(s, attribs, books, url, bold, 'title')
@ -208,28 +198,23 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))
return return
except amazon.AmazonError, e: except amazon.AmazonError, e:
pass irc.error('No books were found with that keyword search.')
irc.error('No books were found with that keyword search.') books = wrap(books, ['channel', getopts({'url':''}), 'text'])
def videos(self, irc, msg, args): def videos(self, irc, msg, args, channel, optlist, keyword):
"""[--url] [--{dvd,vhs}] <keywords> """[--url] [--{dvd,vhs}] <keywords>
Returns the videos matching the given <keyword> search. If --url is Returns the videos matching the given <keyword> search. If --url is
specified, a link to amazon.com's page for the video will also be specified, a link to amazon.com's page for the video will also be
returned. Search defaults to using --dvd. returned. Search defaults to using --dvd.
""" """
opts = ['url']
products = ['dvd', 'vhs']
(optlist, rest) = getopt.getopt(args, '', opts + products)
url = False url = False
product = 'dvd' product = 'dvd'
for (option, argument) in optlist: for (option, _) in optlist:
option = option.lstrip('-')
if option == 'url': if option == 'url':
url = True url = True
if option in products: else:
product = option product = option
keyword = privmsgs.getArgs(rest)
attribs = {'ProductName' : 'title', attribs = {'ProductName' : 'title',
'Manufacturer' : 'publisher', 'Manufacturer' : 'publisher',
'MpaaRating' : 'mpaa', 'MpaaRating' : 'mpaa',
@ -240,9 +225,8 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
} }
s = '%(title)s (%(media)s), rated %(mpaa)s; released ' \ s = '%(title)s (%(media)s), rated %(mpaa)s; released ' \
'%(date)s; published by %(publisher)s; price: %(price)s%(url)s' '%(date)s; published by %(publisher)s; price: %(price)s%(url)s'
chan = msg.args[0] region = self.registryValue('region', channel)
region = self.registryValue('region', chan) bold = self.registryValue('bold', channel)
bold = self.registryValue('bold', chan)
try: try:
videos = amazon.searchByKeyword(keyword, product_line=product, videos = amazon.searchByKeyword(keyword, product_line=product,
locale=region) locale=region)
@ -251,33 +235,29 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))
return return
except amazon.AmazonError, e: except amazon.AmazonError, e:
pass irc.error('No videos were found with that keyword search.')
irc.error('No videos were found with that keyword search.') videos = wrap(videos, ['channel', getopts({'url':'', 'dvd':'', 'vhs':''}),
'text'])
def asin(self, irc, msg, args): def asin(self, irc, msg, args, channel, optlist, asin):
"""[--url] <asin> """[--url] <asin>
Returns the item matching the given ASIN number. If --url is Returns the item matching the given ASIN number. If --url is
specified, a link to amazon.com's page for the item will also be specified, a link to amazon.com's page for the item will also be
returned. returned.
""" """
opts = ['url']
(optlist, rest) = getopt.getopt(args, '', opts)
url = False url = False
for (option, argument) in optlist: for (option, _) in optlist:
option = option.lstrip('-')
if option == 'url': if option == 'url':
url = True url = True
asin = privmsgs.getArgs(rest)
asin = asin.replace('-', '').replace(' ', '') asin = asin.replace('-', '').replace(' ', '')
attribs = {'ProductName' : 'title', attribs = {'ProductName' : 'title',
'OurPrice' : 'price', 'OurPrice' : 'price',
'URL' : 'url' 'URL' : 'url'
} }
s = '%(title)s; price: %(price)s%(url)s' s = '%(title)s; price: %(price)s%(url)s'
chan = msg.args[0] region = self.registryValue('region', channel)
region = self.registryValue('region', chan) bold = self.registryValue('bold', channel)
bold = self.registryValue('bold', chan)
try: try:
item = amazon.searchByASIN(asin, locale=region) item = amazon.searchByASIN(asin, locale=region)
res = self._genResults(s, attribs, item, url, bold, 'title') res = self._genResults(s, attribs, item, url, bold, 'title')
@ -285,10 +265,10 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))
return return
except amazon.AmazonError, e: except amazon.AmazonError, e:
pass irc.error('No item was found with that ASIN.')
irc.error('No item was found with that ASIN.') asin = wrap(asin, ['channel', getopts({'url':''}), 'text'])
def upc(self, irc, msg, args): def upc(self, irc, msg, args, channel, optlist, upc):
"""[--url] <upc> """[--url] <upc>
Returns the item matching the given UPC number. If --url is Returns the item matching the given UPC number. If --url is
@ -297,14 +277,10 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
search: music, classical, software, dvd, video, vhs, electronics, search: music, classical, software, dvd, video, vhs, electronics,
pc-hardware, and photo. pc-hardware, and photo.
""" """
opts = ['url']
(optlist, rest) = getopt.getopt(args, '', opts)
url = False url = False
for (option, argument) in optlist: for (option, _) in optlist:
option = option.lstrip('-')
if option == 'url': if option == 'url':
url = True url = True
upc = privmsgs.getArgs(rest)
upc = upc.replace('-', '').replace(' ', '') upc = upc.replace('-', '').replace(' ', '')
attribs = {'ProductName' : 'title', attribs = {'ProductName' : 'title',
'Manufacturer' : 'manufacturer', 'Manufacturer' : 'manufacturer',
@ -312,9 +288,8 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
'URL' : 'url' 'URL' : 'url'
} }
s = '%(title)s %(manufacturer)s; price: %(price)s%(url)s' s = '%(title)s %(manufacturer)s; price: %(price)s%(url)s'
chan = msg.args[0] region = self.registryValue('region', channel)
region = self.registryValue('region', chan) bold = self.registryValue('bold', channel)
bold = self.registryValue('bold', chan)
try: try:
item = amazon.searchByUPC(upc, locale=region) item = amazon.searchByUPC(upc, locale=region)
res = self._genResults(s, attribs, item, url, bold, 'title') res = self._genResults(s, attribs, item, url, bold, 'title')
@ -322,24 +297,20 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))
return return
except amazon.AmazonError, e: except amazon.AmazonError, e:
pass irc.error('No item was found with that UPC.')
irc.error('No item was found with that UPC.') upc = wrap(upc, ['channel', getopts({'url':''}), 'text'])
def author(self, irc, msg, args): def author(self, irc, msg, args, channel, optlist, author):
"""[--url] <author> """[--url] <author>
Returns a list of books written by the given author. If --url is Returns a list of books written by the given author. If --url is
specified, a link to amazon.com's page for the book will also be specified, a link to amazon.com's page for the book will also be
returned. returned.
""" """
opts = ['url']
(optlist, rest) = getopt.getopt(args, '', opts)
url = False url = False
for (option, argument) in optlist: for (option, argument) in optlist:
option = option.lstrip('-')
if option == 'url': if option == 'url':
url = True url = True
author = privmsgs.getArgs(rest)
attribs = {'ProductName' : 'title', attribs = {'ProductName' : 'title',
'Manufacturer' : 'publisher', 'Manufacturer' : 'publisher',
'Authors' : 'author', 'Authors' : 'author',
@ -348,9 +319,8 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
} }
s = '%(title)s, written by %(author)s; published by ' \ s = '%(title)s, written by %(author)s; published by ' \
'%(publisher)s; price: %(price)s%(url)s' '%(publisher)s; price: %(price)s%(url)s'
chan = msg.args[0] region = self.registryValue('region', channel)
region = self.registryValue('region', chan) bold = self.registryValue('bold', channel)
bold = self.registryValue('bold', chan)
try: try:
books = amazon.searchByAuthor(author, locale=region) books = amazon.searchByAuthor(author, locale=region)
res = self._genResults(s, attribs, books, url, bold, 'title') res = self._genResults(s, attribs, books, url, bold, 'title')
@ -358,8 +328,8 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))
return return
except amazon.AmazonError, e: except amazon.AmazonError, e:
pass irc.error('No books were found by that author.')
irc.error('No books were found by that author.') author = wrap(author, ['channel', getopts({'url':''}), 'text'])
# FIXME: Until I get a *good* list of categories (ones that actually work), # FIXME: Until I get a *good* list of categories (ones that actually work),
# these commands will remain unavailable # these commands will remain unavailable
@ -379,8 +349,9 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
cats = self._textToNode.keys() cats = self._textToNode.keys()
cats.sort() cats.sort()
irc.reply(utils.commaAndify(cats)) irc.reply(utils.commaAndify(cats))
categories = wrap(categories)
def bestsellers(self, irc, msg, args): def bestsellers(self, irc, msg, args, channel, optlist, category):
"""[--url] <category> """[--url] <category>
Returns a list of best selling items in <category>. The 'categories' Returns a list of best selling items in <category>. The 'categories'
@ -388,14 +359,10 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
is specified, a link to amazon.com's page for the item will also be is specified, a link to amazon.com's page for the item will also be
returned. returned.
""" """
opts = ['url']
(optlist, rest) = getopt.getopt(args, '', opts)
url = False url = False
for (option, argument) in optlist: for (option, _) in optlist:
option = option.lstrip('-')
if option == 'url': if option == 'url':
url = True url = True
category = privmsgs.getArgs(rest).lower()
if category not in self._textToNode: if category not in self._textToNode:
irc.error('An invalid category was specified. The categories' irc.error('An invalid category was specified. The categories'
' command will return a list of valid categories') ' command will return a list of valid categories')
@ -407,39 +374,33 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
} }
s = '"%(title)s", from %(publisher)s.%(url)s' s = '"%(title)s", from %(publisher)s.%(url)s'
try: try:
#self.log.warning(category)
items = amazon.browseBestSellers(category) items = amazon.browseBestSellers(category)
#self.log.warning(items)
res = self._genResults(s, attribs, items, url) res = self._genResults(s, attribs, items, url)
if res: if res:
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))
return return
except amazon.AmazonError, e: except amazon.AmazonError, e:
pass irc.error('No items were found on that best seller list.')
irc.error('No items were found on that best seller list.') bestsellers = wrap(bestsellers,
['channel', getopts({'url':''}), rest('lowered')])
''' '''
def artist(self, irc, msg, args): def artist(self, irc, msg, args, channel, optlist, artist):
"""[--url] [--{music,classical}] <artist> """[--url] [--{music,classical}] <artist>
Returns a list of items by the given artist. If --url is specified, a Returns a list of items by the given artist. If --url is specified, a
link to amazon.com's page for the match will also be returned. The link to amazon.com's page for the match will also be returned. The
search defaults to using --music. search defaults to using --music.
""" """
products = ['music', 'classical']
opts = ['url']
(optlist, rest) = getopt.getopt(args, '', products + opts)
url = False url = False
product = '' product = None
for (option, argument) in optlist: for (option, _) in optlist:
option = option.lstrip('-')
if option == 'url': if option == 'url':
url = True url = True
if option in products: else:
product = option product = option
product = product or 'music' product = product or 'music'
artist = privmsgs.getArgs(rest)
attribs = {'ProductName' : 'title', attribs = {'ProductName' : 'title',
'Manufacturer' : 'publisher', 'Manufacturer' : 'publisher',
'Artists' : 'artist', 'Artists' : 'artist',
@ -449,9 +410,8 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
} }
s = '%(title)s (%(media)s), by %(artist)s; published by ' \ s = '%(title)s (%(media)s), by %(artist)s; published by ' \
'%(publisher)s; price: %(price)s%(url)s' '%(publisher)s; price: %(price)s%(url)s'
chan = msg.args[0] region = self.registryValue('region', channel)
region = self.registryValue('region', chan) bold = self.registryValue('bold', channel)
bold = self.registryValue('bold', chan)
try: try:
items = amazon.searchByArtist(artist, product_line=product, items = amazon.searchByArtist(artist, product_line=product,
locale=region) locale=region)
@ -460,29 +420,26 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))
return return
except amazon.AmazonError, e: except amazon.AmazonError, e:
pass irc.error('No items were found by that artist.')
irc.error('No items were found by that artist.') artist = wrap(artist, ['channel',
getopts({'music':'', 'classical':'', 'url':''}),
'text'])
def actor(self, irc, msg, args): def actor(self, irc, msg, args, channel, optlist, actor):
"""[--url] [--{dvd,vhs,video}] <actor> """[--url] [--{dvd,vhs,video}] <actor>
Returns a list of items starring the given actor. If --url is Returns a list of items starring the given actor. If --url is
specified, a link to amazon.com's page for the match will also be specified, a link to amazon.com's page for the match will also be
returned. The search defaults to using --dvd. returned. The search defaults to using --dvd.
""" """
products = ['dvd', 'video', 'vhs']
opts = ['url']
(optlist, rest) = getopt.getopt(args, '', products + opts)
url = False url = False
product = '' product = ''
for (option, argument) in optlist: for (option, _) in optlist:
option = option.lstrip('-')
if option == 'url': if option == 'url':
url = True url = True
if option in products: else:
product = option product = option
product = product or 'dvd' product = product or 'dvd'
actor = privmsgs.getArgs(rest)
attribs = {'ProductName' : 'title', attribs = {'ProductName' : 'title',
'Manufacturer' : 'publisher', 'Manufacturer' : 'publisher',
'MpaaRating' : 'mpaa', 'MpaaRating' : 'mpaa',
@ -493,9 +450,8 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
} }
s = '%(title)s (%(media)s), rated %(mpaa)s; released ' \ s = '%(title)s (%(media)s), rated %(mpaa)s; released ' \
'%(date)s; published by %(publisher)s; price: %(price)s%(url)s' '%(date)s; published by %(publisher)s; price: %(price)s%(url)s'
chan = msg.args[0] region = self.registryValue('region', channel)
region = self.registryValue('region', chan) bold = self.registryValue('bold', channel)
bold = self.registryValue('bold', chan)
try: try:
items = amazon.searchByActor(actor, product_line=product, items = amazon.searchByActor(actor, product_line=product,
locale=region) locale=region)
@ -504,29 +460,26 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))
return return
except amazon.AmazonError, e: except amazon.AmazonError, e:
pass irc.error('No items were found starring that actor.')
irc.error('No items were found starring that actor.') actor = wrap(actor, ['channel',
getopts({'dvd': '', 'video': '', 'vhs':'', 'url':''}),
'text'])
def director(self, irc, msg, args): def director(self, irc, msg, args, channel, optlist, director):
"""[--url] [--{dvd,vhs,video}] <director> """[--url] [--{dvd,vhs,video}] <director>
Returns a list of items by the given director. If --url is Returns a list of items by the given director. If --url is
specified, a link to amazon.com's page for the match will also be specified, a link to amazon.com's page for the match will also be
returned. The search defaults to using --dvd. returned. The search defaults to using --dvd.
""" """
products = ['dvd', 'video', 'vhs']
opts = ['url']
(optlist, rest) = getopt.getopt(args, '', products + opts)
url = False url = False
product = '' product = None
for (option, argument) in optlist: for (option, _) in optlist:
option = option.lstrip('-')
if option == 'url': if option == 'url':
url = True url = True
if option in products: else:
product = option product = option
product = product or 'dvd' product = product or 'dvd'
director = privmsgs.getArgs(rest)
attribs = {'ProductName' : 'title', attribs = {'ProductName' : 'title',
'Manufacturer' : 'publisher', 'Manufacturer' : 'publisher',
'MpaaRating' : 'mpaa', 'MpaaRating' : 'mpaa',
@ -537,9 +490,8 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
} }
s = '%(title)s (%(media)s), rated %(mpaa)s; released ' \ s = '%(title)s (%(media)s), rated %(mpaa)s; released ' \
'%(date)s; published by %(publisher)s; price: %(price)s%(url)s' '%(date)s; published by %(publisher)s; price: %(price)s%(url)s'
chan = msg.args[0] region = self.registryValue('region', channel)
region = self.registryValue('region', chan) bold = self.registryValue('bold', channel)
bold = self.registryValue('bold', chan)
try: try:
items = amazon.searchByDirector(director, product_line=product, items = amazon.searchByDirector(director, product_line=product,
locale=region) locale=region)
@ -548,10 +500,12 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))
return return
except amazon.AmazonError, e: except amazon.AmazonError, e:
pass irc.error('No items were found by that director.')
irc.error('No items were found by that director.') director = wrap(director, ['channel', getopts({'dvd': '', 'video': '',
'vhs': '', 'url': ''}),
'text'])
def manufacturer(self, irc, msg, args): def manufacturer(self, irc, msg, args, channel, optlist, manufacturer):
""" [--url] \ """ [--url] \
[--{pc-hardware,kitchen,electronics,videogames,software,photo}] \ [--{pc-hardware,kitchen,electronics,videogames,software,photo}] \
<manufacturer> <manufacturer>
@ -560,28 +514,21 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
specified, a link to amazon.com's page for the match will also be specified, a link to amazon.com's page for the match will also be
returned. The search defaults to using --pc-hardware. returned. The search defaults to using --pc-hardware.
""" """
products = ['electronics', 'kitchen', 'videogames', 'software',
'photo', 'pc-hardware']
opts = ['url']
(optlist, rest) = getopt.getopt(args, '', products + opts)
url = False url = False
product = '' product = None
for (option, argument) in optlist: for (option, _) in optlist:
option = option.lstrip('-')
if option == 'url': if option == 'url':
url = True url = True
if option in products: else:
product = option product = option
product = product or 'pc-hardware' product = product or 'pc-hardware'
manufacturer = privmsgs.getArgs(rest)
attribs = {'ProductName' : 'title', attribs = {'ProductName' : 'title',
'OurPrice' : 'price', 'OurPrice' : 'price',
'URL' : 'url' 'URL' : 'url'
} }
s = '%(title)s; price: %(price)s%(url)s' s = '%(title)s; price: %(price)s%(url)s'
chan = msg.args[0] region = self.registryValue('region', channel)
region = self.registryValue('region', chan) bold = self.registryValue('bold', channel)
bold = self.registryValue('bold', chan)
try: try:
items = amazon.searchByManufacturer(manufacturer, items = amazon.searchByManufacturer(manufacturer,
product_line=product, product_line=product,
@ -591,8 +538,14 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
irc.reply(utils.commaAndify(res)) irc.reply(utils.commaAndify(res))
return return
except amazon.AmazonError, e: except amazon.AmazonError, e:
pass irc.error('No items were found by that manufacturer.')
irc.error('No items were found by that manufacturer.') manufacturer = wrap(manufacturer,
['channel', getopts(
{'url':'', 'electronics':'', 'kitchen':'',
'videogames':'', 'software':'', 'photo':'',
'pc-hardware':'',
}),
'text'])
def amzSnarfer(self, irc, msg, match): def amzSnarfer(self, irc, msg, match):
r"http://www.amazon.com/exec/obidos/(?:tg/detail/-/|ASIN/)([^/]+)" r"http://www.amazon.com/exec/obidos/(?:tg/detail/-/|ASIN/)([^/]+)"
@ -623,8 +576,8 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
irc.reply(res, prefixName=False) irc.reply(res, prefixName=False)
return return
except amazon.AmazonError, e: except amazon.AmazonError, e:
pass self.log.debug('No item was found with that ASIN.')
self.log.warning('No item was found with that ASIN.') amzSnarfer = urlSnarfer(amzSnarfer)
Class = Amazon Class = Amazon

View File

@ -32,7 +32,7 @@ from testsupport import *
LICENSE_KEY = 'AMAZONS_NOT_CHECKING_KEYS' LICENSE_KEY = 'AMAZONS_NOT_CHECKING_KEYS'
if LICENSE_KEY != 'INITIAL_NON_LICENSE_KEY' and network: if LICENSE_KEY != 'INITIAL_NON_LICENSE_KEY' and network:
class AmazonTestCase(PluginTestCase): class AmazonTestCase(ChannelPluginTestCase):
plugins = ('Amazon',) plugins = ('Amazon',)
def setUp(self): def setUp(self):
PluginTestCase.setUp(self) PluginTestCase.setUp(self)