2
0
mirror of https://github.com/Nick80835/microbot synced 2025-08-23 10:38:51 +00:00
microbot/ubot/settings.py

23 lines
667 B
Python
Raw Normal View History

2020-03-16 21:02:05 -04:00
# SPDX-License-Identifier: GPL-2.0-or-later
2023-10-16 09:46:31 -04:00
from configparser import SafeConfigParser
class Settings():
def __init__(self):
self.config = SafeConfigParser()
self.config.read("settings.ini")
def get_config(self, key, default=None):
return self.config.get("DEFAULT", key, fallback=default)
2023-10-16 09:46:31 -04:00
def get_bool(self, key, default=False):
return bool(self.config.get("DEFAULT", key, fallback=default) == "True")
2023-10-16 09:46:31 -04:00
def set_config(self, key, value):
self.config.set("DEFAULT", key, value)
with open('settings.ini', 'w') as config_file:
self.config.write(config_file)
config_file.close()