Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
import vk_api
from vk_api.longpoll import VkLongPoll, VkEventType
vk_session = vk_api.VkApi(token = 'dda72434d647022c3a39a0a192e054e4e02d1ce7a211971263c6e4b9548bd539025459f72de84c5c19380')
session_api = vk_session.get_api()
longpool = VkLongPoll(vk_session) #Работа с событиями сообщества в реальном времени
def send_some_msg(id, some_text):
vk_session.method("messages.send", {"user_id":id, "message":some_text, "random_id":0})
for event in longpool.listen():
if event.type == VkEventType.MESSAGE_NEW:
if event.to_me:
msg = event.text.lower()
id = event.user_id
print(msg)
if msg == "hi":
send_some_msg(id,"Hi friend")