Skip to content

Commit f9b9e19

Browse files
committed
allow fallback flag
1 parent 2acad47 commit f9b9e19

File tree

11 files changed

+2523
-1
lines changed

11 files changed

+2523
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ After launching the bot, you can interact with it via Telegram (message `@whatev
281281

282282
Contributions are welcome! If you have suggestions for improvements or bug fixes, please open an issue or submit a pull request.
283283

284+
## License
285+
286+
Licensed under the MIT License. See the [LICENSE](./LICENSE) file for more details.
287+
284288
## Credits
285289

286290
- [FlyingFathead](https://github.com/FlyingFathead) - Project creator

build/lib/config_loader.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# config_loader.py
2+
# (update to include RateLimitSettings and NotificationSettings)
3+
4+
import configparser
5+
import os
6+
import logging
7+
8+
logger = logging.getLogger(__name__)
9+
10+
class ConfigLoader:
11+
_instance = None
12+
_config = None
13+
14+
def __new__(cls):
15+
if cls._instance is None:
16+
cls._instance = super(ConfigLoader, cls).__new__(cls)
17+
cls._config = configparser.ConfigParser()
18+
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
19+
config_path = os.path.join(base_dir, 'config', 'config.ini')
20+
21+
if os.path.exists(config_path):
22+
cls._config.read(config_path)
23+
logger.info(f"Loaded config from {config_path}")
24+
for section in cls._config.sections():
25+
logger.debug(f"Section [{section}]: {dict(cls._config[section])}")
26+
else:
27+
logger.warning(f"Config file not found at {config_path}")
28+
return cls._instance
29+
30+
@classmethod
31+
def get_config(cls):
32+
if cls._config is None:
33+
cls()
34+
return cls._config
35+
36+
# NEW: Method to get Notification Settings
37+
@classmethod
38+
def get_notification_settings(cls):
39+
config = cls.get_config() # Get the config object
40+
send_completion_message = config.getboolean('NotificationSettings', 'sendcompletionmessage', fallback=True)
41+
completion_message = config.get('NotificationSettings', 'completionmessage', fallback="Transcription complete. Have a nice day!")
42+
43+
return {
44+
'send_completion_message': send_completion_message,
45+
'completion_message': completion_message
46+
}
47+
48+
# Usage example:
49+
# from config_loader import ConfigLoader
50+
# notification_settings = ConfigLoader.get_notification_settings()

build/lib/main.py

Lines changed: 710 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)