diff options
| author | 2016-04-03 13:20:05 +0100 | |
|---|---|---|
| committer | 2016-04-03 13:20:05 +0100 | |
| commit | 504e93a78d59d51243acbcab6831309805d01fd1 (patch) | |
| tree | f5687e4611875e3b4b5e5370492bf7df86e77703 /modules/isbn.py | |
| parent | added code to prevent newlines being where they shouldn't be in outgoing lines. (diff) | |
tinkered with some modules and fixed a few bugs, also added the skeleton for the auto_mode.py module.
Diffstat (limited to 'modules/isbn.py')
| -rw-r--r-- | modules/isbn.py | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/modules/isbn.py b/modules/isbn.py deleted file mode 100644 index 67870520..00000000 --- a/modules/isbn.py +++ /dev/null @@ -1,35 +0,0 @@ -import json -import Utils - -URL_GOOGLEBOOKS = "https://www.googleapis.com/books/v1/volumes" - -class Module(object): - _name = "ISBN" - def __init__(self, bot): - self.bot = bot - bot.events.on("received").on("command").on("isbn").hook( - self.isbn, help="Get book information from a provided ISBN", - min_args=1) - - def isbn(self, event): - isbn = event["args_split"][0] - if len(isbn) == 10: - isbn = "978%s" % isbn - isbn = isbn.replace("-", "") - page = Utils.get_url(URL_GOOGLEBOOKS, get_params={ - "q": "isbn:%s" % isbn, "country": "us"}, json=True) - if page: - if page["totalItems"] > 0: - book = page["items"][0]["volumeInfo"] - title = book["title"] - sub_title = book["subtitle"] - authors = ", ".join(book["authors"]) - date = book["publishedDate"] - rating = book["averageRating"] - #language = book["language"] - event["stdout"].write("%s - %s (%s), %s (%s/5.0)" % ( - title, authors, date, sub_title, rating)) - else: - event["stderr"].write("Unable to find book") - else: - event["stderr"].write("Failed to load results") |
