I've looked around and don't really know what else to do. My function is not defined after the place where I call it. I'm thinking its probably something stupid, but I can't find it.
def function1():
global tobegrouped
if(len(tobegrouped) >= 2):
print(len(tobegrouped))
prs1 = random.choice(tobegrouped)
print("got prs1")
prs2 = random.choice(tobegrouped)
print("got prs2")
newgroup = group(prs1, prs2)
print("made group")
global groups
groups.append(newgroup)
print("appended to group")
newgroup.send_message("Welcome to robinbot, have fun, and don't spam", self)
else :
print("no group ready yet")
And this is where I'm calling it. I've already checked that its past the definition of the function in the file.
if command == '/start':
# MAYBE CHECK IF IN GROUP HERE
global tobegrouped
tobegrouped.append(chat_id)
print("in to be grouped")
self.sendMessage(chat_id, "welcome to robin, please wait to be grouped")
print("sent message")
function1()
print("function1s working")
And here is the error just in case you need it
EDIT: Error as text
File "bot.py", line 133, in on_chat_message
function1()
NameError: name 'function1' is not defined
Traceback (most recent call last):
File "bot.py" line 223, in (module)
time.sleep(10)