try
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
marker = 0
if event.from_chat:
user_id = event.message.from_id
user_rpl = event.message.reply_message
group_id = GR_ID
if str("-") in str(user_id):
marker = 1
print("Это сообщества")
time.sleep(3)
if marker == 0 :
except Exception as e:
print("КРИТИЧЕСКАЯ ОШИБКА :")
print(e)
time.sleep(30)
print("!!!RESTART!!!")
os.execv(sys.executable, ['python'] + sys.argv)
db_object.execute(f"SELECT user_id , chat_id FROM users WHERE user_id = '{user_id}' , chat_id = '{chat_id}'")
LINE 1: ... , chat_id FROM users WHERE user_id = '160970741' , chat_id ...
^
db_object.execute(f"SELECT user_id , chat_id FROM users WHERE (user_id = '{user_id}' AND chat_id = '{chat_id}')")
user_id = event.message.from_id
user_get = vkls.users.get(user_ids=user_id, fields =("can_write_private_message") )
user_get = user_get[0]
first_name = user_get['first_name']
last_name = user_get['last_name']
db_object.execute("INSERT INTO users(id, first_name, last_name, admins) VALUES (%s, %s, %s, %s)", (user_id, first_name, last_name,admins))
db_object.execute(f"UPDATE users SET last_name= '{last_name}' WHERE id = '{user_id}' ")
db_object.execute(f"UPDATE users SET first_name = '{first_name}' WHERE id = '{user_id}' ")
from vk_api import VkApi
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
import vk_api
TOKEN = "********"
GR_ID = "*********"
vk_session = VkApi(token=TOKEN)
longpoll = VkBotLongPoll(vk_session, GR_ID)
vk = vk_session.get_api()
def send_replyls(peer_id,message,conversation_message_id):
vk_session.method("messages.send",{
"message" : message ,
"peer_id" : peer_id,
"reply_to" : conversation_message_id,
"random_id" : round(random() * 10 ** 9)
})
cars = ["Ford", "Volvo", "BMW"]
if cars in text:
message = (f"@id{user_id} ({first_name}), Вы успешно начали. \n Для вас открыто следующее достижение :)")
send(peer_id,message)
else :
message = (f"(ノ◕ヮ◕)ノ*:・゚✧ \n\n ( ^▽^)っ✂╰⋃╯")
send(peer_id,message)
Источник
Для более подробного изучения