Conduct in conversation. I want if some message in the conversation will contain some word, then I have automatically sent the desired message.
How to implement it?
Answer 1, Authority 100%
You can help Python and his library vk_api
Here is the example of the bot:
from random import randint
from vk_api import vkapi
from vk_api.bot_longpoll import vkbotlongpoll, vkboteventtype
vk_session = vkapi (token = "[your token]")
longpoll = vkbotlongpoll (vk_session, "[community ID]")
vk = vk_session.get_api ()
For event in longpoll.listen ():
If event.type == vkboteventtype.Message_New and event.from_Chat:
Text = event.Object ['Text']
IF 'Some kind of word' in text:
Random_id = Randint (1, 2147483647)
Chat_id = event.chat_id
Message = "[Your answer]"
vk.messages.send (
Random_ID = RANDOM_ID,
Chat_id = Chat_id,
Message = Message,
)
Note: In the example, authorization on the community key is used, since the message methods are limited and cannot be used directly using the user’s key. You will have to create a community and add it to a conversation (do not forget about the rights to read messages).