Initial commit

This commit is contained in:
BarsTiger
2023-05-10 23:51:23 +03:00
commit 9242e5fe6a
36 changed files with 370 additions and 0 deletions

View File

@@ -0,0 +1 @@
from .db import config, sessions

17
modules/config/db.py Normal file
View File

@@ -0,0 +1,17 @@
import sqlitedict
import json
class ConfigDatabase(sqlitedict.SqliteDict):
def __init__(self, tablename):
super().__init__(
filename='config.storage',
tablename=tablename,
encode=json.dumps,
decode=json.loads,
autocommit=True
)
config = ConfigDatabase('config')
sessions = ConfigDatabase('sessions')

15
modules/config/models.py Normal file
View File

@@ -0,0 +1,15 @@
from dataclasses import dataclass, asdict
@dataclass
class SessionConfig:
def __str__(self):
return f'{self.phone} - {self.id} - {self.profile_name} {f"- @{self.username}" if self.username else ""}'
def json(self):
return asdict(self)
phone: str
profile_name: str
id: int
username: str | None = None