mirror of
https://github.com/TeamPGM/PagerMaid-Pyro.git
synced 2024-11-21 19:38:17 +00:00
36 lines
856 B
Python
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
|