xenu_nntp/lib/nntp/tiny/server.py
2024-11-22 23:57:14 -05:00

21 lines
548 B
Python

import enum
from nntp.tiny.db import Database
from nntp.tiny.newsgroup import Newsgroup
class ServerCapability(enum.Flag):
NONE = 0
AUTH = enum.auto()
POST = enum.auto()
class Server():
def __init_(self, db: Database):
self.db = db
self.capabilities = ServerCapability.NONE
self.newsgroups = dict()
self._init_groups()
def _init_newsgroups(self):
for newsgroup in self.db.query(Newsgroup).each():
self.newsgroups[newsgroup.name.casefold()] = newsgroup