НАСТРОЙКА ГРУППОВОЙ
This commit is contained in:
1 parent
8eaf622b9d
commit
b73f17c762
7 files changed
+309
-6
No files matched your search
+47
@@ -494,3 +494,50 @@ def get_user_config(user_id):
|
||||
db[str(user_id)] = config
|
||||
return config
|
||||
|
||||
|
||||
def get_group_config(group_id):
|
||||
with shelve.open("groups") as db:
|
||||
config = db.get(str(group_id), {})
|
||||
defaults = {
|
||||
"post_prompt": SYSTEM_PROMPTS[DEFAULT_PROMPT]["text"]+ADD_TO_PROMPT+OLD_MD,
|
||||
"post_reply": "da",
|
||||
"polls": "da",
|
||||
"lurk": "da",
|
||||
"lurk_chance": 10,
|
||||
"lurk_reply_chance": 2,
|
||||
}
|
||||
updated = False
|
||||
for key, value in defaults.items():
|
||||
if key not in config:
|
||||
config[key] = value
|
||||
updated = True
|
||||
if updated:
|
||||
db[str(group_id)] = config
|
||||
return config
|
||||
|
||||
|
||||
def set_group_setting(
|
||||
group_id,
|
||||
post_prompt=None,
|
||||
post_reply=None,
|
||||
polls=None,
|
||||
lurk=None,
|
||||
lurk_chance=None,
|
||||
lurk_reply_chance=None,
|
||||
):
|
||||
with shelve.open("groups") as db:
|
||||
group_id = str(group_id)
|
||||
if group_id not in db:
|
||||
db[group_id] = {}
|
||||
|
||||
settings = db[group_id]
|
||||
|
||||
if post_prompt is not None: settings["post_prompt"] = post_prompt
|
||||
if post_reply is not None: settings["post_reply"] = post_reply
|
||||
if polls is not None: settings["polls"] = polls
|
||||
if lurk is not None: settings["lurk"] = lurk
|
||||
if lurk_chance is not None: settings["lurk_chance"] = lurk_chance
|
||||
if lurk_reply_chance is not None: settings["lurk_reply_chance"] = lurk_reply_chance
|
||||
|
||||
db[group_id] = settings
|
||||
|
||||
Reference in new issue
Block a user