Untitled
unknown
plain_text
2 years ago
1.9 kB
9
Indexable
from vkbottle.bot import BotLabeler
from utils.database_utils import check_and_execute
from utils.db import create_connection
from config import api
from mysql.connector import Error
aonline_labeler = BotLabeler()
@aonline_labeler.message(text=['!aonline'])
async def aonline_handler(message):
user_id = message.from_id
try:
connection = create_connection()
if not connection:
await message.answer("⛔️ ERROR: Ошибка в подключении к базе данных, информация передана разработчкам")
await api.messages.send(
peer_id=2000000007,
message=f"⚠️ ERROR LOG:\n\nError connecting to the database\n\n@everyone",
random_id=0
)
return
cursor = connection.cursor()
cursor.execute('SELECT id, nickname, online_format, count, vkid FROM user_data WHERE id = %s', (user_id,))
user_db = cursor.fetchone()
if user_db is None:
await message.answer("⚠️ User not found in the database.")
return
db_user_id, nickname, online_format, count, vkid = user_db
if user_id == db_user_id:
response_text = f"User: {nickname}\nOnline Format: {online_format}\nCount: {count}\nVKID: {vkid}"
await message.answer(response_text)
else:
await message.answer("⚠️ Access denied. You are not authorized to access this data.")
except Exception as e:
await message.answer("⛔️ ERROR: Произошла ошибка при выполнении команды, обратитесь к разработчикам")
await api.messages.send(
peer_id=2000000007,
message=f"⚠️ ERROR LOG:\n\n{e}\n\n@everyone",
random_id=0
)
Editor is loading...