/botly/settings.py (84d336b31e6ad2d91967b469ead8782ae1546c77) (971 bytes) (mode 100644) (type blob)
#!/usr/bin/env python
"""Loads and manages the bot settings."""
from botly.db import Db
class Settings(Db):
def __init__(self):
assert self.is_loaded(), "Db is not loaded before loading settings."
self.root = self.get_node('/BotDb/Settings')
self.settingsCache = {}
def get_string(self, key, default=''):
"""Returns the string value if it exists."""
if key not in self.settingsCache:
self.settingsCache[key] = self._load_setting(key, default)
return self.settingsCache[key]
def get_int(self, key, default='0'):
"""Returns the int value if it exists."""
# Default default is a string because passed to get_string.
# It's converted back to int below
v = self.get_string(key, default=default)
return int(v)
def _load_setting(self, key, default):
setting = self.query_value(key)
return setting if setting is not None else default
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
10175 |
e454a52586f29b8ce8a6799163eac1f875e9ac01 |
LICENSE |
100644 |
blob |
912 |
43cc367ee8608a8760e6665ac29c411d58dc8b99 |
README.md |
040000 |
tree |
- |
66dcfaf2ba5cd5742f36e01d7785daf5113c2107 |
botly |
100644 |
blob |
172 |
3f148ab99d152565c46e51fd45e51030417f7faa |
example.py |
040000 |
tree |
- |
e05b34e00f419ee6a20bf1bb6a0603727b1b4399 |
examplebot |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/detche/Botly
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/detche/Botly
Clone this repository using git:
git clone git://git.rocketgit.com/user/detche/Botly
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main