diff --git a/plugins/plpaste.py b/plugins/plpaste.py index bf039fce..ad1edc8a 100644 --- a/plugins/plpaste.py +++ b/plugins/plpaste.py @@ -1,4 +1,5 @@ from util import hook, web +from os import listdir @hook.command(permissions=["adminonly"]) @@ -8,5 +9,8 @@ def plpaste(inp): try: with open("plugins/%s.py" % inp) as f: return web.haste(f.read(), ext='py') - except IOError: - return "Plugin not found (must be in plugins folder)" + elif inp + ".py" in listdir('plugins/'): + with open('plugins/{}.py'.format(inp)) as f: + return web.haste(f.read(), ext='py') + else: + return "Could not find specified plugin." diff --git a/plugins/spotify.py b/plugins/spotify.py index 6ad97281..7217eab8 100644 --- a/plugins/spotify.py +++ b/plugins/spotify.py @@ -54,6 +54,8 @@ def spotify(inp): try: data = http.get_json("https://api.spotify.com/v1/search", type="track", limit="1", q=inp.strip()) item = data["tracks"]["items"][0] + except IndexError: + return "Could not find track: no results." except Exception as e: return "Could not get information: {}".format(e) return format_track(item) @@ -69,6 +71,8 @@ def spotify_album(inp): try: data = http.get_json("https://api.spotify.com/v1/search", type="album", limit="1", q=inp.strip()) item = data["albums"]["items"][0] + except IndexError: + return "Could not find track: no results." except Exception as e: return "Could not get information: {}".format(e) return format_album(item) @@ -84,6 +88,8 @@ def spotify_artist(inp): try: data = http.get_json("https://api.spotify.com/v1/search", type="artist", limit="1", q=inp.strip()) item = data["artists"]["items"][0] + except IndexError: + return "Could not find track: no results." except Exception as e: return "Could not get information: {}".format(e) return format_artist(item)