diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..81884d3
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..933052a
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/ocab.iml b/.idea/ocab.iml
new file mode 100644
index 0000000..74d515a
--- /dev/null
+++ b/.idea/ocab.iml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/config.json b/src/config.json
new file mode 100644
index 0000000..e69de29
diff --git a/src/core.py b/src/core.py
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/src/core.py
@@ -0,0 +1 @@
+
diff --git a/src/modules/DataBase.py b/src/modules/DataBase.py
new file mode 100644
index 0000000..2d092d4
--- /dev/null
+++ b/src/modules/DataBase.py
@@ -0,0 +1,128 @@
+import os
+import sqlite3
+
+
+class DataBase:
+ def __init__(self):
+ self.bot_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.getcwd())))
+ self.db = sqlite3.connect(os.path.join(self.bot_dir, 'DataBase/OCAB_DB.db'))
+ self.cursor = self.db.cursor()
+ self.check_db()
+
+ # Проверки наличия таблиц в базе данных
+ def check_db(self):
+ self.check_chatdb()
+ self.check_userdb()
+ self.check_messagedb()
+
+ def check_chatdb(self):
+ self.cursor.execute("""SELECT name FROM sqlite_master WHERE type='table' AND name='chat_list'""")
+ if self.cursor.fetchone() is None:
+ self.create_chatdb()
+
+ def check_userdb(self):
+ self.cursor.execute("""SELECT name FROM sqlite_master WHERE type='table' AND name='user_list'""")
+ if self.cursor.fetchone() is None:
+ self.create_userdb()
+
+ def check_messagedb(self):
+ self.cursor.execute("""SELECT name FROM sqlite_master WHERE type='table' AND name='message_list'""")
+ if self.cursor.fetchone() is None:
+ self.create_messagedb()
+
+ # Создание таблиц в базе данных
+ def create_chatdb(self):
+ self.cursor.execute("""CREATE TABLE IF NOT EXISTS chat_list (
+ chat_id INTEGER PRIMARY KEY,
+ chat_role INTEGER NOT NULL,
+ chat_stats INTEGER NOT NULL,
+ chat_federation INTEGER,
+ )""")
+ self.db.commit()
+
+ def create_userdb(self):
+ self.cursor.execute("""CREATE TABLE IF NOT EXISTS user_list (
+ user_id INTEGER PRIMARY KEY,
+ user_name TEXT NOT NULL,
+ user_tag TEXT,
+ user_role INTEGER,
+ user_stats INTEGER
+ user_rep INTEGER
+ )""")
+ self.db.commit()
+
+ def create_messagedb(self):
+ self.cursor.execute("""CREATE TABLE IF NOT EXISTS message_list (
+ message_id INTEGER PRIMARY KEY,
+ message_text TEXT NOT NULL,
+ message_id_sender INTEGER NOT NULL,
+ answer_to_id INTEGER
+ )""")
+ self.db.commit()
+
+ async def add_chat(self, chat_id, chat_role, chat_stats=0, chat_federation=0):
+ self.cursor.execute("""INSERT INTO chat_list VALUES (?, ?, ?, ?)""",
+ (chat_id, chat_role, chat_stats, chat_federation))
+
+ async def add_user(self, user_id, user_name, user_tag=None, user_role=0, user_stats=0, user_rep=0):
+ self.cursor.execute("""INSERT INTO user_list VALUES (?, ?, ?, ?, ?, ?)""",
+ (user_id, user_name, user_tag, user_role, user_stats, user_rep))
+ self.db.commit()
+
+ async def add_message(self, message_id, message_text, message_sender, answer_id):
+ self.cursor.execute("""INSERT INTO message_list VALUES (?, ?, ?, ?)""",
+ (message_id, message_text, message_sender, answer_id))
+ self.db.commit()
+
+ async def get_chat(self, chat_id):
+ self.cursor.execute("""SELECT * FROM chat_list WHERE chat_id=?""", (chat_id,))
+ return self.cursor.fetchone()
+
+ async def get_user(self, user_id):
+ self.cursor.execute("""SELECT * FROM user_list WHERE user_id=?""", (user_id,))
+ return self.cursor.fetchone()
+
+ async def get_message(self, message_id):
+ self.cursor.execute("""SELECT * FROM message_list WHERE message_id=?""", (message_id,))
+ return self.cursor.fetchone()
+
+ async def change_user_name(self, user_id, new_user_name):
+ self.cursor.execute("""UPDATE user_list SET user_name=? WHERE user_id=?""", (new_user_name, user_id))
+ self.db.commit()
+
+ async def change_user_role(self, user_id, new_user_role):
+ self.cursor.execute("""UPDATE user_list SET user_role=? WHERE user_id=?""", (new_user_role, user_id))
+ self.db.commit()
+
+ async def change_user_stats(self, user_id, new_user_stats):
+ self.cursor.execute("""UPDATE user_list SET user_stats=? WHERE user_id=?""", (new_user_stats, user_id))
+ self.db.commit()
+
+ async def change_user_rep(self, user_id, new_user_rep):
+ self.cursor.execute("""UPDATE user_list SET user_rep=? WHERE user_id=?""", (new_user_rep, user_id))
+ self.db.commit()
+
+ async def change_chat_role(self, chat_id, new_chat_role):
+ self.cursor.execute("""UPDATE chat_list SET chat_role=? WHERE chat_id=?""", (new_chat_role, chat_id))
+ self.db.commit()
+
+ async def change_chat_stats(self, chat_id, new_chat_stats):
+ self.cursor.execute("""UPDATE chat_list SET chat_stats=? WHERE chat_id=?""", (new_chat_stats, chat_id))
+ self.db.commit()
+
+ async def change_chat_federation(self, chat_id, new_chat_federation):
+ self.cursor.execute("""UPDATE chat_list SET chat_federation=? WHERE chat_id=?""",
+ (new_chat_federation, chat_id))
+ self.db.commit()
+
+ async def update_user_stats(self):
+ self.cursor.execute("""UPDATE user_list SET user_stats=user_stats+1""")
+ self.db.commit()
+
+ async def update_user_rep(self):
+ self.cursor.execute("""UPDATE user_list SET user_rep=user_rep+1""")
+ self.db.commit()
+
+ async def update_chat_stats(self):
+ self.cursor.execute("""UPDATE chat_list SET chat_stats=chat_stats+1""")
+ self.db.commit()
diff --git a/src/modules/Roles.py b/src/modules/Roles.py
new file mode 100644
index 0000000..e69de29