mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-05-01 07:51:10 -05:00
add error messages
This commit is contained in:
parent
e2c8e89440
commit
96c37944c0
@ -77,6 +77,9 @@ class IMDb(callbacks.Plugin):
|
|||||||
url = None
|
url = None
|
||||||
result = None
|
result = None
|
||||||
apikey = self.registryValue('omdbAPI')
|
apikey = self.registryValue('omdbAPI')
|
||||||
|
if not apikey:
|
||||||
|
irc.reply("Error: You must set an API key to use this plugin.")
|
||||||
|
return
|
||||||
if self.registryValue("googleSearch", channel):
|
if self.registryValue("googleSearch", channel):
|
||||||
url = self.dosearch(query)
|
url = self.dosearch(query)
|
||||||
if url and 'imdb.com/title/' in url:
|
if url and 'imdb.com/title/' in url:
|
||||||
|
@ -53,18 +53,22 @@ class Weed(callbacks.Plugin):
|
|||||||
"""<strain>
|
"""<strain>
|
||||||
Searches API based on user input
|
Searches API based on user input
|
||||||
"""
|
"""
|
||||||
|
|
||||||
response1 = None
|
response1 = None
|
||||||
response2 = None
|
response2 = None
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
strain = re.sub('[^\w\:\"\#\-\.\' ]', '', strain).casefold()
|
strain = re.sub('[^\w\:\"\#\-\.\' ]', '', strain).casefold()
|
||||||
strain_api = self.registryValue('strain_api')
|
strain_api = self.registryValue('strain_api')
|
||||||
|
if not strain_api:
|
||||||
|
irc.reply("Error: You must set an API key to use this plugin.")
|
||||||
|
return
|
||||||
url = "http://strainapi.evanbusse.com/{0}/strains/search/name/{1}".format(strain_api, strain)
|
url = "http://strainapi.evanbusse.com/{0}/strains/search/name/{1}".format(strain_api, strain)
|
||||||
|
request = requests.get(url)
|
||||||
data = requests.get(url)
|
ok = request.status_code == requests.codes.ok
|
||||||
data = json.loads(data.content)
|
if not ok:
|
||||||
|
irc.reply("Error: Unable to retrieve data. Did you set an API key?")
|
||||||
|
log.error("IMDB: API Error %s: %s" % (request.status_code, request.content.decode()))
|
||||||
|
return
|
||||||
|
data = json.loads(request.content)
|
||||||
for item in data:
|
for item in data:
|
||||||
if item['desc'] is not None and item['name'].casefold() == strain:
|
if item['desc'] is not None and item['name'].casefold() == strain:
|
||||||
id = item['id']
|
id = item['id']
|
||||||
@ -99,7 +103,6 @@ class Weed(callbacks.Plugin):
|
|||||||
irc.reply(response2)
|
irc.reply(response2)
|
||||||
else:
|
else:
|
||||||
irc.reply('No results found, what have you been smoking?')
|
irc.reply('No results found, what have you been smoking?')
|
||||||
|
|
||||||
strain = wrap(strain, ['text'])
|
strain = wrap(strain, ['text'])
|
||||||
|
|
||||||
Class = Weed
|
Class = Weed
|
||||||
|
@ -69,8 +69,8 @@ class YouTube(callbacks.Plugin):
|
|||||||
try:
|
try:
|
||||||
log.debug("YouTube: requesting %s" % (api_url))
|
log.debug("YouTube: requesting %s" % (api_url))
|
||||||
request = requests.get(api_url, timeout=10)
|
request = requests.get(api_url, timeout=10)
|
||||||
request = json.loads(request.content)
|
response = json.loads(request.content)
|
||||||
video_id = request["items"][0]["id"]["videoId"]
|
video_id = response["items"][0]["id"]["videoId"]
|
||||||
except Exception:
|
except Exception:
|
||||||
log.error("YouTube: YouTube API HTTP %s: %s" % (request.status_code, request.content.decode()))
|
log.error("YouTube: YouTube API HTTP %s: %s" % (request.status_code, request.content.decode()))
|
||||||
pass
|
pass
|
||||||
@ -113,6 +113,9 @@ class YouTube(callbacks.Plugin):
|
|||||||
Search for YouTube videos
|
Search for YouTube videos
|
||||||
"""
|
"""
|
||||||
apikey = self.registryValue('developerKey')
|
apikey = self.registryValue('developerKey')
|
||||||
|
if not apikey:
|
||||||
|
irc.reply("Error: You need to set an API key to use this plugin.")
|
||||||
|
return
|
||||||
channel = msg.channel
|
channel = msg.channel
|
||||||
yt_template = Template(self.registryValue("template", channel))
|
yt_template = Template(self.registryValue("template", channel))
|
||||||
response = None
|
response = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user