fixing issue where trying to fetch a breed before breeds list loaded resulted in trying to fetch sub-breeds and then error
This commit is contained in:
parent
755ddc2f36
commit
43f539bdd3
1 changed files with 10 additions and 9 deletions
19
doggo.py
19
doggo.py
|
@ -32,16 +32,17 @@ class Doggo(BotPlugin):
|
|||
# But what if user passed us a sub-breed?
|
||||
if len(args) > 1 and args[1]:
|
||||
subbreed = args[1]
|
||||
if len(self.breeds[breed]) == 0:
|
||||
if 'calledbyfunction' not in args:
|
||||
args.append('calledbyfunction')
|
||||
self.reloadsubbreeds(msg, args)
|
||||
if subbreed != 'calledbyfunction':
|
||||
if len(self.breeds[breed]) == 0:
|
||||
return 'No sub-breeds available for {}, so we cannot use {}.'.format(breed, subbreed)
|
||||
if subbreed in self.breeds[breed]:
|
||||
url = '{}/breed/{}/{}/images/random'.format(self.BASE_URL, breed, subbreed)
|
||||
else:
|
||||
return 'Sub-breed of {} not found: {}. List sub-breeds with !listsubbreeds'.format(breed, subbreed)
|
||||
if 'calledbyfunction' not in args:
|
||||
args.append('calledbyfunction')
|
||||
self.reloadsubbreeds(msg, args)
|
||||
if len(self.breeds[breed]) == 0:
|
||||
return 'No sub-breeds available for {}, so we cannot use {}.'.format(breed, subbreed)
|
||||
if subbreed in self.breeds[breed]:
|
||||
url = '{}/breed/{}/{}/images/random'.format(self.BASE_URL, breed, subbreed)
|
||||
else:
|
||||
return 'Sub-breed of {} not found: {}. List sub-breeds with !listsubbreeds'.format(breed, subbreed)
|
||||
|
||||
try:
|
||||
resp = requests.get(url)
|
||||
|
|
Loading…
Reference in a new issue