Customizing Bot Reply Text¶
TG-FileStream uses a translation registry system to manage reply texts.
All default messages are defined in:
tgfs/utils/translation.py
Messages are loaded using a registry-based system.
This allows overriding text without modifying core files.
How It Works¶
The core project defines:
- A base language class (
en) - A registry dictionary
- Messages fetched dynamically via registry
Example (simplified):
When the bot needs a message, it fetches it from the active language class in the registry.
Overriding Reply Text Using a Patch¶
To override messages, you create a patch that:
- Inherits from the base language class
- Overrides specific text variables
- Registers your custom class into the registry
Official CustomReply Patch¶
You can use the official template:
https://github.com/SpringsFern/CustomReply
Step-by-Step Guide¶
1. Fork the Repository¶
Fork:
https://github.com/SpringsFern/CustomReply
Modify the code inside:
2. Example Customization¶
from tgfs.utils.translation import registry, en
class CustomText(en):
START_TEXT = "Hey there how are you\nYou can send me any file and I will generate a link for that file."
registry["en"] = CustomText
This overrides the default START_TEXT.
You can override any variable defined in:
https://github.com/SpringsFern/TG-FileStream/blob/main/tgfs/utils/translation.py
3. Install the Patch¶
Clone your fork inside:
Example:
4. Restart TG-FileStream¶
Or if running manually:
Adding New Language Support¶
You can:
- Submit pull request to: https://github.com/SpringsFern/tgfs_translation
OR
- Add new language class inside your patch:
Best Practices¶
- Do not modify
translation.pydirectly. - Always use patches.
- Only override variables you need.
- Keep your patch repository separate for easier upgrades.