Give direct_to_user confirmation that breeds list reloaded, if reloadbreeds called by user, and not if called by listbreeds

This commit is contained in:
Adam Piontek 2018-08-25 17:51:00 -04:00
parent 5b866c4a2a
commit 85a037aefc

View file

@ -37,12 +37,13 @@ class Doggo(BotPlugin):
return resp.json()['message'] return resp.json()['message']
@botcmd @botcmd(split_args_with=' ')
def listbreeds(self, msg, args): def listbreeds(self, msg, args):
""" """
List available breeds for use in the random image retriever List available breeds for use in the random image retriever
""" """
if not self.breeds: if not self.breeds:
args.append('calledbyfunction')
self.reloadbreeds(msg, args) self.reloadbreeds(msg, args)
if not self.breeds: if not self.breeds:
return 'Unable to load breeds list' return 'Unable to load breeds list'
@ -53,8 +54,7 @@ class Doggo(BotPlugin):
for breed in sorted(self.breeds.keys()): for breed in sorted(self.breeds.keys()):
self.send(direct_to_user, breed) self.send(direct_to_user, breed)
@botcmd(admin_only=True,split_args_with=' ')
@botcmd(admin_only=True)
def reloadbreeds(self, msg, args): def reloadbreeds(self, msg, args):
""" """
Reloads the list of breeds currently available Reloads the list of breeds currently available
@ -74,3 +74,8 @@ class Doggo(BotPlugin):
for breed in data: for breed in data:
self.breeds[breed] = [] self.breeds[breed] = []
if 'calledbyfunction' not in args:
# Tell user command was successful
direct_to_user = self.build_identifier(str(msg.frm))
self.send(direct_to_user, "Breed list successfully loaded")