PagerMaid-Pyro/pagermaid/utils/_sub.py
xtaodada a941308d17
Some checks failed
Docker Dev Build / docker build and publish (push) Failing after 13s
Docker Build / docker build and publish (push) Failing after 11s
🔖 Update to v1.5.0
这是一项破坏性变更,目录结构进行了重组,无核心功能变化
2024-09-28 22:01:40 +08:00

36 lines
856 B
Python

from typing import List
from pagermaid.dependence import sqlite
class Sub:
def __init__(self, name: str):
self.name = name
def get_subs(self) -> List:
return sqlite.get(f"{self.name}.sub", [])
def clear_subs(self) -> None:
sqlite[f"{self.name}.sub"] = []
del sqlite[f"{self.name}.sub"]
def add_id(self, uid: int) -> bool:
data = self.get_subs()
if uid in data:
return False
data.append(uid)
sqlite[f"{self.name}.sub"] = data
return True
def del_id(self, uid: int) -> bool:
data = self.get_subs()
if uid not in data:
return False
data.remove(uid)
sqlite[f"{self.name}.sub"] = data
return True
def check_id(self, uid: int) -> bool:
data = self.get_subs()
return uid in data