2
0
mirror of https://github.com/Nick80835/microbot synced 2025-08-22 18:19:16 +00:00
microbot/ubot/settings.py

36 lines
1.3 KiB
Python
Raw Normal View History

2023-10-16 09:46:31 -04:00
# Copyright (C) 2019 Nick Filmer (nick80835@gmail.com)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from configparser import SafeConfigParser
class Settings():
def __init__(self):
self.config = SafeConfigParser()
self.config.read("settings.ini")
def get_config(self, key):
return self.config.get("DEFAULT", key, fallback=None)
def get_bool(self, key):
return bool(self.config.get("DEFAULT", key, fallback=False) == "True")
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()