D
D
dead_1ns1d_e2021-08-24 02:50:30
Python
dead_1ns1d_e, 2021-08-24 02:50:30

How to make the bot respond to all messages?

I wrote a bot and I don’t understand how to make it respond to all messages

def sender(id, text):
    vk_session.method('messages.send', {'chat_id': id, 'message': text, 'random_id' : 0})
for event in longpoll.listen():
    if event.type == VkEventType.MESSAGE_NEW:
        if event.to_me:
            if event.from_chat:
                msg = event.text.lower()
                id = event.chat_id
                if msg == '1':
                    sender(id, '1')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LXSTVAYNE, 2021-08-24
@lxstvayne

If an event of type MESSAGE_NEW came, then react. In general, look towards the library https://github.com/lxstvayne/vk_maria . See how the examples are implemented, conveniently.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question