summaryrefslogtreecommitdiff
path: root/ATRI/plugins/bilibili_dynamic/database
diff options
context:
space:
mode:
Diffstat (limited to 'ATRI/plugins/bilibili_dynamic/database')
3 files changed, 0 insertions, 64 deletions
diff --git a/ATRI/plugins/bilibili_dynamic/database/__init__.py b/ATRI/plugins/bilibili_dynamic/database/__init__.py
deleted file mode 100644
index 6840881..0000000
--- a/ATRI/plugins/bilibili_dynamic/database/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from .db import DB
diff --git a/ATRI/plugins/bilibili_dynamic/database/db.py b/ATRI/plugins/bilibili_dynamic/database/db.py
deleted file mode 100644
index 37ed223..0000000
--- a/ATRI/plugins/bilibili_dynamic/database/db.py
+++ /dev/null
@@ -1,49 +0,0 @@
-from pathlib import Path
-from tortoise import Tortoise
-
-from ATRI import driver
-from .models import Subscription
-
-
-DB_DIR = Path(".") / "data" / "database" / "bilibili_dynamic"
-DB_DIR.mkdir(parents=True, exist_ok=True)
-
-
-class DB:
- async def __aenter__(self):
- return self
-
- async def __aexit__(self, exc_type, exc_val, exc_tb):
- pass
-
- async def init(self):
- from . import models
-
- await Tortoise.init(
- db_url=f"sqlite://{DB_DIR}/db.sqlite3",
- modules={"models": [locals()["models"]]},
- )
- await Tortoise.generate_schemas()
-
- async def add_sub(self, uid: int, group_id: int):
- await Subscription.create(uid=uid, group_id=group_id)
-
- async def update_sub(self, uid: int, update_map: dict):
- await Subscription.filter(uid=uid).update(**update_map)
-
- async def del_sub(self, query_map: dict):
- await Subscription.filter(**query_map).delete()
-
- async def get_sub_list(self, query_map: dict) -> list:
- return await Subscription.filter(**query_map)
-
- async def get_all_subs(self) -> list:
- return await Subscription.all()
-
-
-async def init():
- async with DB() as db:
- await db.init()
-
-
-driver().on_startup(init)
diff --git a/ATRI/plugins/bilibili_dynamic/database/models.py b/ATRI/plugins/bilibili_dynamic/database/models.py
deleted file mode 100644
index d0cb3dd..0000000
--- a/ATRI/plugins/bilibili_dynamic/database/models.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from datetime import datetime
-
-from tortoise import fields
-from tortoise.models import Model
-
-
-class Subscription(Model):
- uid = fields.IntField()
- group_id = fields.IntField()
- up_nickname = fields.TextField(null=True)
- last_update = fields.DatetimeField(default=datetime.fromordinal(1))
-
- def __str__(self) -> str:
- return f"[{self.uid}|{self.group_id}|{self.up_nickname}|{self.last_update}]"