L
L
Lin2132019-09-18 13:35:20
Python
Lin213, 2019-09-18 13:35:20

The bot does not send pikchi, how to fix it?

#!/usr/bin/env python
import random


import vk
import vk_api
import vkapi
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType

token = "тут токен"
access_token = "сервисный ключ"
group_id = "-186540911"

vk_session = vk_api.VkApi(token=token)
vk = vk_session.get_api()
longpoll = VkBotLongPoll(vk_session, 186108970)







def get_random_wall_picture(group_id, token):
    max_num = vk.photos.get(owner_id=group_id, album_id='wall', count=0, access_token=token)['count']
    num = random.randint(1, max_num)
    photo = vk.photos.get(owner_id=str(group_id), album_id='wall', count=1, offset=num, access_token=token)['items'][0]['id']
    attachment = 'photo' + str(group_id) + '_' + str(photo)



while True:
    for event in longpoll.listen():
        if event.type == VkBotEventType.MESSAGE_NEW:
            if event.object.peer_id != event.object.from_id:
                if event.object.text.lower() == "гуг":
                    vk.messages.send(peer_id=event.object.peer_id, message='ГЭНГ', random_id=0)

                    if event.object.text.lower() == "мемы":
                        get_random_wall_picture(-186540911)

There are no errors, the bot just does not respond to the message "memes"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Elvis, 2019-09-18
@Lin213

you have the "memes" condition inside the "google" condition. accordingly, the sent message is first checked for compliance with "google", and then with "memes". that will never pass. move the "memes" condition 1 tab to the left

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question