mirror of
https://github.com/cupcakearmy/mercatus.git
synced 2024-12-22 08:06:28 +00:00
default db data
This commit is contained in:
parent
b7336b6a97
commit
840f1b4511
18
src/Utils.py
18
src/Utils.py
@ -2,9 +2,23 @@ from telegram import Update
|
|||||||
from telegram.ext import PicklePersistence, Updater
|
from telegram.ext import PicklePersistence, Updater
|
||||||
from yaml import load, Loader
|
from yaml import load, Loader
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
import pickle
|
||||||
|
|
||||||
config = load(open('./config.yml', 'r'), Loader=Loader)
|
DB_FILE = './data.db'
|
||||||
persistence = PicklePersistence('./data.db')
|
CONFIG_FILE = './config.yml'
|
||||||
|
DEFAULT_DATA = {
|
||||||
|
'user_data': {},
|
||||||
|
'chat_data': {},
|
||||||
|
'conversations': {},
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
pickle.load(open(DB_FILE, 'rb'))
|
||||||
|
except:
|
||||||
|
pickle.dump(DEFAULT_DATA, open(DB_FILE, 'wb'))
|
||||||
|
|
||||||
|
config = load(open(CONFIG_FILE, 'r'), Loader=Loader)
|
||||||
|
persistence = PicklePersistence(DB_FILE)
|
||||||
updater: Updater = Updater(config['token'], use_context=True, persistence=persistence)
|
updater: Updater = Updater(config['token'], use_context=True, persistence=persistence)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user