This commit closes #9
This commit is contained in:
@@ -16,13 +16,23 @@ logger = logging.getLogger(__name__)
|
||||
class PyroGroup:
|
||||
"""Dataclass of DB entry of a group"""
|
||||
|
||||
__slots__ = ("_id", "id", "locale", "locale_auto")
|
||||
__slots__ = (
|
||||
"_id",
|
||||
"id",
|
||||
"locale",
|
||||
"locale_auto",
|
||||
"ban_failed",
|
||||
"timeout_join",
|
||||
"timeout_verify",
|
||||
)
|
||||
|
||||
_id: ObjectId
|
||||
id: int
|
||||
locale: Union[str, None]
|
||||
locale_auto: bool
|
||||
ban_failed: bool
|
||||
timeout_join: int
|
||||
timeout_verify: int
|
||||
|
||||
@classmethod
|
||||
async def create_if_not_exists(
|
||||
@@ -31,6 +41,8 @@ class PyroGroup:
|
||||
locale: Union[str, None] = sync.config_get("locale", "defaults", "group"),
|
||||
locale_auto: bool = sync.config_get("locale_auto", "defaults", "group"),
|
||||
ban_failed: bool = sync.config_get("ban_failed", "defaults", "group"),
|
||||
timeout_join: int = sync.config_get("timeout_join", "defaults", "group"),
|
||||
timeout_verify: int = sync.config_get("timeout_verify", "defaults", "group"),
|
||||
):
|
||||
db_entry = await col_groups.find_one(
|
||||
{
|
||||
@@ -45,6 +57,8 @@ class PyroGroup:
|
||||
"locale": locale,
|
||||
"locale_auto": locale_auto,
|
||||
"ban_failed": ban_failed,
|
||||
"timeout_join": timeout_join,
|
||||
"timeout_verify": timeout_verify,
|
||||
}
|
||||
)
|
||||
db_entry = await col_groups.find_one({"_id": inserted.inserted_id})
|
||||
@@ -78,6 +92,26 @@ class PyroGroup:
|
||||
{"_id": self._id}, {"$set": {"ban_failed": enabled}}
|
||||
)
|
||||
|
||||
async def set_timeout_join(self, timeout: int) -> None:
|
||||
logger.debug(
|
||||
"Join timeout in group %s has been set to %s",
|
||||
self.id,
|
||||
timeout,
|
||||
)
|
||||
await col_groups.update_one(
|
||||
{"_id": self._id}, {"$set": {"timeout_join": timeout}}
|
||||
)
|
||||
|
||||
async def set_timeout_verify(self, timeout: int) -> None:
|
||||
logger.debug(
|
||||
"Verification timeout in group %s has been set to %s",
|
||||
self.id,
|
||||
timeout,
|
||||
)
|
||||
await col_groups.update_one(
|
||||
{"_id": self._id}, {"$set": {"timeout_verify": timeout}}
|
||||
)
|
||||
|
||||
# Group settings
|
||||
# User locale
|
||||
def select_locale(
|
||||
|
Reference in New Issue
Block a user