Compare commits

...

1 Commits
main ... redis

Author SHA1 Message Date
Egor Guslyancev a4e3fc265e
DB path and type config 2023-12-19 09:10:39 -03:00
3 changed files with 17 additions and 2 deletions

6
bot.py
View File

@ -17,7 +17,10 @@ import timeout as tmo
# TODO more backends (redis at least)
db = db_classes.PickleDB(".db")
db = {
"pickle": db_classes.PickleDB,
# "redis": db_classes.RedisDB,
}.get(cr.read("settings.db_type"))(cr.read("settings.db_path"))
db.load()
CURRENT_VERSION = "v1.0rc9"
VERSION = db.read("about.version", CURRENT_VERSION)
@ -1409,6 +1412,7 @@ def update(forum: int) -> None:
def update_notify(forum: int) -> None:
"Notifies the forum about bot's new version."
# TODO changelog
bot.reply_to(
get_chat(forum),
f"Обновился до версии {telebot.formatting.escape_markdown(CURRENT_VERSION)}",

View File

@ -7,4 +7,6 @@
prod = 0000000000:ooooooooooooooooooooooooooooooooooo
[settings]
notify_period = 120
notify_period = 120
db_type = pickle
db_path = .db

View File

@ -10,6 +10,15 @@ FIELDS = {
"tokens.prod": (str, "" if __debug__ else None, None),
"tokens.devel": (str, None if __debug__ else "", None),
"settings.notify_period": (int, 120, None),
"settings.db_path": (str, ".db", None),
"settings.db_type": (
str,
None,
(
"pickle",
# "redis",
),
),
}
CONFIG_FILENAME = "config.ini"