vk_chat_bot/vk/vk_database.py

39 lines
1.2 KiB
Python

import database
class VkDatabase(database.BasicDatabase):
def __init__(self):
super().__init__('vk.db')
self.cursor.execute("""
CREATE TABLE IF NOT EXISTS chats (
"id" INTEGER,
"active" INTEGER NOT NULL DEFAULT 0,
"rules" TEXT,
"greeting_join" TEXT,
"greeting_rejoin" TEXT,
"birthday_message" TEXT,
"ai_prompt" TEXT,
PRIMARY KEY("id"))
""")
self.cursor.execute("""
CREATE TABLE IF NOT EXISTS users (
"chat_id" INTEGER,
"user_id" INTEGER,
"last_message" INTEGER NOT NULL DEFAULT 0,
"messages_today" INTEGER NOT NULL DEFAULT 0,
"messages_month" INTEGER NOT NULL DEFAULT 0,
"warnings" INTEGER NOT NULL DEFAULT 0,
"happy_birthday" INTEGER NOT NULL DEFAULT 1,
"about" TEXT,
PRIMARY KEY("chat_id","user_id"))
""")
self.conn.commit()
def user_toggle_happy_birthday(self, chat_id: int, user_id: int, happy_birthday: int):
self.user_update(chat_id, user_id, happy_birthday=happy_birthday)
DB = VkDatabase()