Answer the question
In order to leave comments, you need to log in
Need code to sort VK id?
I wrote a bot for VK in python.
Here is the code:
from tkinter import *
import pyautogui as pg
import pyautogui
import time
import vk_api
from vk_api.longpoll import VkLongPoll, VkEventType
window = Tk()
window.iconbitmap("zbot.ico")
token = *скрыт*
vk_session = vk_api.VkApi(token=token)
vk = vk_session.get_api()
longpoll = VkLongPoll(vk_session)
upload = vk_api.VkUpload(vk)
user_id_k = *скрыто*
while True:
for event in longpoll.listen():
if event.type == VkEventType.MESSAGE_NEW:
if event.to_me:
msg = event.text.lower()
if msg == '!старт':
pg.click(220, 1030)
time.sleep(0.1)
pg.doubleClick(216, 538)
time.sleep(0.1)
pg.click(1564, 9)
vk.messages.send(user_id=user_id_k, message='Запущена!', random_id=0)
elif msg == '!стоп':
pg.click(button='right', x=74, y=1032)
time.sleep(0.7)
pg.click(75, 989)
vk.messages.send(user_id=user_id_k, message='Остановлена!', random_id=0)
elif msg == '!скрин':
screen = pyautogui.screenshot('im.vk.png')
photo = upload.photo_messages('im.vk.png')
owner_id = photo[0]['owner_id']
photo_id = photo[0]['id']
access_key = photo[0]['access_key']
attachment = f'photo{owner_id}_{photo_id}_{access_key}'
vk.messages.send(peer_id=user_id_k, random_id=0, attachment=attachment)
else:
vk.messages.send(user_id=user_id_k, message='Не знаю такого!', random_id=0)
Answer the question
In order to leave comments, you need to log in
You were also answered in your previous question - to compare your ID with the sender's ID. For this, some other library is not needed, you are already using vk_api, which returns the sender's ID.
if event.user_id == ваш айди:
#выполняем код
if event.from_me:
#выполняем код
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question