mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-08-28 05:14:12 +00:00
fix: Update escape sequence documentation for consistency
- Revised `config.ini.example` and `README.md` to clarify the usage of escape sequences for newlines, changing from double backslashes (`\\n`) to single backslashes (`\n`). - Enhanced comments in `CommandManager` and `GreeterCommand` to reflect the updated escape sequence behavior, ensuring accurate processing of newline characters and literal backslashes. - Improved logging in `GreeterCommand` for better debugging of mesh info formatting.
This commit is contained in:
@@ -181,7 +181,11 @@ class CommandManager:
|
||||
"""Decode escape sequences in config strings.
|
||||
|
||||
Processes common escape sequences like \\n (newline), \\t (tab), \\\\ (backslash).
|
||||
This allows users to add newlines in keyword responses using \\n.
|
||||
This allows users to add newlines in keyword responses using \n (single backslash).
|
||||
|
||||
Behavior:
|
||||
- \n in config file → newline character
|
||||
- \\n in config file → literal backslash + n
|
||||
|
||||
Args:
|
||||
text: The text string to process.
|
||||
@@ -191,6 +195,7 @@ class CommandManager:
|
||||
"""
|
||||
# Replace escape sequences
|
||||
# Order matters: \\ must be processed first to avoid double-processing
|
||||
# This preserves literal backslashes (\\n becomes \n, not a newline)
|
||||
text = text.replace('\\\\', '\x00') # Temporary placeholder for backslash
|
||||
text = text.replace('\\n', '\n') # Newline
|
||||
text = text.replace('\\t', '\t') # Tab
|
||||
|
||||
Reference in New Issue
Block a user