This repository was archived by the owner on Apr 22, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathconfig_builder.py
More file actions
106 lines (96 loc) · 2.57 KB
/
config_builder.py
File metadata and controls
106 lines (96 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
from copy import deepcopy
DEFAULT_CONFIG = {
"limits": {
"post_content": 2000,
"search_results": 30,
},
"uploads": {
"emoji_allowed_file_types": ["gif", "jpg", "jpeg", "png"],
},
"attachments": {
"enabled": True,
"max_size": 104857600,
"permanent_expiration_days": 365,
"permanent_tiers": ["pro", "max"],
"allowed_types": ["image/*", "video/*", "audio/*", "application/pdf"],
"uploads_per_minute": 10,
"subscription_cache_ttl": 300,
"max_attachments_per_user": -1,
"free_tier_max_expiration_days": 7,
"compression": {
"enabled": True,
"max_width": 1920,
"max_height": 1920,
"jpeg_quality": 85,
"webp_quality": 85,
"png_compression": 6,
},
},
"rate_limiting": {
"enabled": True,
"messages_per_minute": 60,
"burst_limit": 10,
"cooldown_seconds": 30,
},
"modlog": {
"enabled": True,
"retention": {
"default": 90,
"user_moderation": 365,
"role_management": 365,
"channel_management": 180,
"message_moderation": 90,
"server_management": 180,
},
},
"DB": {
"channels": "db/channels.json",
"users": {
"file": "db/users.json",
"default": {
"roles": ["user"],
},
},
},
"websocket": {
"host": "127.0.0.1",
"port": 5613,
},
"service": {
"name": "OriginChats",
"version": "1.0.0",
},
"server": {
"name": "My OriginChats Server",
"owner": {
"name": "Admin",
},
},
"auth_mode": "rotur",
"cracked": {
"allow_registration": True,
},
}
def _deep_merge(base, overrides):
for key, value in overrides.items():
if isinstance(value, dict) and isinstance(base.get(key), dict):
_deep_merge(base[key], value)
continue
base[key] = value
return base
def _remove_none_values(data):
cleaned = {}
for key, value in data.items():
if isinstance(value, dict):
nested = _remove_none_values(value)
if nested:
cleaned[key] = nested
continue
if value is not None:
cleaned[key] = value
return cleaned
def build_config(overrides=None):
config = deepcopy(DEFAULT_CONFIG)
if overrides:
_deep_merge(config, _remove_none_values(overrides))
return config