aboutsummaryrefslogtreecommitdiff
path: root/modules/isbn.py
diff options
context:
space:
mode:
authorGravatar jesopo2016-04-03 13:20:05 +0100
committerGravatar jesopo2016-04-03 13:20:05 +0100
commit504e93a78d59d51243acbcab6831309805d01fd1 (patch)
treef5687e4611875e3b4b5e5370492bf7df86e77703 /modules/isbn.py
parentadded 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.py35
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")