A
A
antontrr2021-12-17 14:04:01
Python
antontrr, 2021-12-17 14:04:01

How to make a bot greeting when adding a user to a VK conversation?

import vk_api
from vk_api.utils import get_random_id
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
def write_message (sender, message):
authorize.method ('messages.send', {'chat_id' : sender, 'message':message, 'random_id' :get_random_id ()})
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW and event.from_chat and event.message.get('text') !="":
reseived_message = event.message. get('text')
sender = event.chat_id
InfoEvent = event.object['message']
from_id = InfoEvent['from_id']
peer_id = InfoEvent['peer_id']
chat_id = event.chat_id
user_id = event.obj.from_id
if reseived_message == "Hello" :
write_message ( sender,"Good afternoon!")
How exactly to add this function here??

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question