W
W
wsappx2021-06-07 06:06:44
In contact with
wsappx, 2021-06-07 06:06:44

Why does not see the token variable in the script?

the script gives an error name "vk_api" is not defined

import vk_api as message
import requests
import os
import time
import api
import vk

def main():
    all_tokens = list()
    try:
        file = open("tokens.txt", 'r')
        for line in file.readlines():
            all_tokens.extend(line.rstrip().split(' '))

        users = ['', '', '']

        try:
            chats = input('Кол-во создаваемых бесед: ')
            spot = 0
            while int(spot) < int(chats):
                vk = vk_api.messages.createChat(user_ids=users, title="text") #название беседы
                spot += 1
                time.sleep(80)
        except Exception as er:
            print(er)

    except:
        a = os.listdir()
        print('Убедитесь, что в текущей директории есть  файл с токенами, возможно он просто неверно назван.\nВсе файлы в текущей директории:\n')
        b = input(a) 

main()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SagePtr, 2021-06-07
@SagePtr

And where do you have vk_api defined? You are importing this module under the name message, not under its original name.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question