K
K
Kirieshka3x2020-04-15 09:21:14
Python
Kirieshka3x, 2020-04-15 09:21:14

The message is not sent, what should I do?

token = "."
vk = vk_api.VkApi(token = token )
vk._auth_token()
easygui.msgbox("бот запущен", "Bot")
while True:
    try:
        messages = vk.method("messages.getConversations", {"offset": 0, "count": 20, "filter": "unanswered"})
        if messages["count"] >= 1:
            id = messages["items"][0]["last_message"]["from_id"]
        body = messages["items"][0]["last_message"]["text"]
        if body.lower() == "привет":
            vk.method("messages.send", {"peer_id": id, "message": "приветствую", "random_id": random.randint(1, 2147483647)})
        elif body.lower() == "новосибирск":
            vk.method("messages.send", {"peer_id": id, "message": div.text, "random_id": random.randint(1, 2147483647)})
        elif body.lower() == "доллар":
            vk.method("messages.send", {"peer_id": id, "message": span_dollar.text, "random_id": random.randint(1, 2147483647)})
        elif body.lower() == "коронавирус":
            vk.method("messages.send", {"peer_id": id, "message": div_corona.text, "random_id": random.randint(1, 2147483647)})
        else:
            vk.method("messages.send", {"peer_id": id, "message": "Не понял тебя!", "random_id": random.randint(1, 2147483647)})
            vk.method("messages.send", {"peer_id": id, "message": "команды: погода, город, доллар", "random_id": random.randint(1, 2147483647)}) 
    except Exception as E:
        time.sleep(1)

the message does not read, does not send, everything worked before. (token hidden)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lolchik, 2020-04-15
@lo1chik

indents forgot

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question