37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
import database
|
|
|
|
|
|
class VkDatabase(database.BasicDatabase):
|
|
def __init__(self):
|
|
super().__init__()
|
|
|
|
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,
|
|
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,
|
|
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()
|