I need to pass values from one function to the next from within the function.
For example (my IRC bot programmed to respond to commands in the channel):
def check_perms(nick,chan,cmd):sql = "SELECT `"+ cmd +"` FROM permissions WHERE nick = '"+ nick +"' and chan = '"+ chan +"'" # This returns 0#sql = "SELECT `restart` FROM permissions WHERE nick = 'Me' and chan = '#mychan'" # this works as intendedcursor.execute(sql)result = cursor.fetchall()for row in result:if (row[0] == 1): # Nick logged in and has permissionreturn 1 else: # nick does not have permissionsreturn 0def com_restart(nick,chan):perm = check_perms(nick,chan,"restart")if (perm == 0): # nick did not have permissionirc.send("NOTICE "+ nick +" :Permission denied.\n")elif (perm == 1): # nick has permissionirc.send("PRIVMSG "+ chan +" :I've been asked to restart myself by "+ nick +".\n")nick = "Me" # This is determined by a bunch of regex splits and such
chan = "#mychan" # This is determined by regex splits as well
com_restart(nick,chan)
When I try this, though, it seems the values do not get passed to the SQL query, so it returns 0.
Thanks for any help you can provide.
EDIT - Added code that I'm working with as it stands right now.