I would like to put the returned player who sent the message !player1
or !player2
into a short list so that I can them for later, but I can't seem to find out how to get returned variables from functions inside of functions. I saw something about Closure which I think this is but even following the example I can't seem to get the returned values so I can assign them.
def players(sender, event):
def getplayer():
msg = event.parsed[0]['msg']
if msg == '!player1':
BotBasicFunction.sendmsg(msgg='{} has joined the game!'.format(hasplayer()))
hasplayer()
if msg == '!player2':
BotBasicFunction.sendmsg(msgg='{} has joined the game!'.format(hasplayer()))
hasplayer()
def hasplayer():
invoker = event.parsed[0]['invokername']
return invoker
parsedmsg = event.parsed[0]['msg']
players = [getplayer(), getplayer(), getplayer(), getplayer()]
if parsedmsg == '!players':
BotBasicFunction.sendmsg(msgg='{}'.format(players))