Hotfix
This commit is contained in:
parent
c9274de4bc
commit
86ecf555fd
10
bot.py
10
bot.py
|
@ -5,18 +5,15 @@
|
|||
import time
|
||||
import ast
|
||||
import datetime as dt
|
||||
import configparser
|
||||
import typing
|
||||
from sys import stderr, stdout, stdin
|
||||
from threading import Thread
|
||||
import telebot
|
||||
from config_reader import config
|
||||
import db_classes
|
||||
|
||||
CONFIG_FILENAME = "config.ini"
|
||||
config = configparser.ConfigParser()
|
||||
config.read(CONFIG_FILENAME)
|
||||
|
||||
# TODO more backends
|
||||
# TODO more backends (redis at least)
|
||||
db = db_classes.PickleDB(".db")
|
||||
db.load()
|
||||
CURRENT_VERSION = "v1.0rc7"
|
||||
|
@ -1440,8 +1437,7 @@ def process1():
|
|||
|
||||
def process2():
|
||||
"The process updates duty order for every forum once a `period` seconds."
|
||||
# TODO period in config file
|
||||
period = 120
|
||||
period = int(config['settings']['notify_period'])
|
||||
prev_time = time.time()
|
||||
while True:
|
||||
cur_time = time.time()
|
||||
|
|
|
@ -4,4 +4,7 @@
|
|||
|
||||
[tokens]
|
||||
# Enter your token in the `config.ini` file
|
||||
prod = 0000000000:ooooooooooooooooooooooooooooooooooo
|
||||
prod = 0000000000:ooooooooooooooooooooooooooooooooooo
|
||||
|
||||
[settings]
|
||||
notify_period = 120
|
|
@ -0,0 +1,11 @@
|
|||
# SPDX-FileCopyrightText: 2023 Egor Guslyancev <electromagneticcyclone@disroot.org>
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
"The module reads and checks config."
|
||||
|
||||
import configparser
|
||||
|
||||
CONFIG_FILENAME = "config.ini"
|
||||
config = configparser.ConfigParser()
|
||||
config.read(CONFIG_FILENAME)
|
|
@ -2,6 +2,8 @@
|
|||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
"The module provides DB backends."
|
||||
|
||||
import pickle as p
|
||||
from os import path
|
||||
|
||||
|
@ -24,7 +26,7 @@ class PrototypeDB:
|
|||
def read(self, field: str, default: any = None, data=None) -> any:
|
||||
"Read `field` from the database. `default` argument returned when where's no such a field."
|
||||
|
||||
def pop(self, field: str) -> any | None:
|
||||
def pop(self, field: str) -> any:
|
||||
"Remove `field` from the database."
|
||||
|
||||
|
||||
|
@ -64,9 +66,9 @@ class PickleDB(PrototypeDB):
|
|||
if len(field) == 1:
|
||||
data[field[0]] = value
|
||||
else:
|
||||
if field[0] not in data or data[field[0]] is None:
|
||||
if (field[0] not in data) or (data[field[0]] is None):
|
||||
data[field[0]] = {}
|
||||
if not isinstance(type(data[field[0]]), dict):
|
||||
if not isinstance(data[field[0]], dict):
|
||||
raise ValueError("Поле не является группой.")
|
||||
data[field[0]] = self.write(".".join(field[1:]), value, data[field[0]])
|
||||
self.save()
|
||||
|
|
Loading…
Reference in New Issue