vicsdocs
vicsdocs

Reputation: 13

Missing 1 required positional argument [Telebot]

Good day! I'm new to python, I'm currently learning about passing arguments. And then there was an error.

Here is part of the code

def gosto(imia):
@bot.message_handler(content_types=['document'])
def primer(message):
    loop2 = asyncio.new_event_loop()
    asyncio.set_event_loop(loop2)
    bot.send_document(message.chat.id, open(imia, 'rb'))
primer()

def otmena(url):
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
letters = string.ascii_lowercase
rand_string = ''.join(random.choice(letters) for i in range(10))
usernames = open(str(rand_string)+'.txt', "a+", encoding='utf8')
***
    imia = rand_string+'.txt'       
    threada_ = threading.Thread(target=gosto, args=(imia,))
    threada_.start()

And I get this ERROR

Already tried different methods. Initially, there was one function, I tried to pass two arguments there - message and imia. But got the same error. Please help me understand what I'm doing wrong

Upvotes: 1

Views: 1463

Answers (1)

John Gordon
John Gordon

Reputation: 33335

You have defined primer() to require one argument:

def primer(message):
    ...

But then you call it without an argument:

primer()

Upvotes: 1

Related Questions