TCL-DebugLoader is a Tcl script designed to be loaded first in an Eggdrop bot's configuration. It facilitates the loading of other Tcl scripts while providing robust error handling and advanced debugging features inspired by LiveBugTracer. Errors are redirected to a log file (logs_Error/${::botnet-nick}_Error.log
) and optionally to a specified IRC channel (CONF(CHANNEL_LOG)
). This tool is invaluable for developers, ensuring stable bot operation and detailed error tracking.
- Error Redirection: Captures and logs Tcl script errors to
logs_Error/${::botnet-nick}_Error.log
with full stack traces. - Channel Logging: Sends error messages to a configurable IRC channel (
CONF(CHANNEL_LOG)
) for real-time monitoring. - Crash Prevention: Ensures the Eggdrop bot remains stable even if a loaded script contains syntax errors, with optional bot termination (
DIE_ON_ERROR
). - Variable Tracing: Tracks read/write/unset operations on specified variables (e.g.,
CONF
) for debugging. - Infinite Loop Protection: Detects and interrupts infinite loops in
for
andwhile
commands, configurable viaANTI_INFINITE_LOOP
. - Network Error Reporting: Sends error messages to other bots via
putallbots
(configurable viaNETWORK_ERROR_REPORT
). - Developer-Friendly: Centralizes error reporting, suppresses duplicate errors, and provides detailed stack traces for easier debugging.
- Eggdrop: Version 1.6.20 or higher.
- Tcl: Version 8.6 or higher (typically included with Eggdrop).
- Write Permissions: Ensure the bot has write permissions in the
logs_Error/
directory for error log creation.
-
Clone or Download the Repository:
git clone https://github.com/ZarTek-Creole/TCL-DebugLoader.git
Alternatively, download the ZIP file from the GitHub repository and extract it.
-
Move the Script: Copy the
TCL-DebugLoader.tcl
file to your Eggdrop bot'sscripts
directory:cp TCL-DebugLoader/TCL-DebugLoader.tcl /path/to/eggdrop/scripts/
-
Edit Eggdrop Configuration: Open your Eggdrop configuration file (e.g.,
eggdrop.conf
) and add the following line at the top of the script loading section:source scripts/TCL-DebugLoader.tcl
-
Rehash or Restart the Bot: In the Eggdrop console or IRC, run:
.rehash
Alternatively, restart the bot:
./eggdrop -m eggdrop.conf
-
Set the Debug Channel: In
TCL-DebugLoader.tcl
, configure theCONF(CHANNEL_LOG)
variable to specify the IRC channel for error reporting:array set CONF { CHANNEL_LOG "#mydebugchannel" SCRIPTS_LIST {script1.tcl script2.tcl} DIE_ON_ERROR 0 NETWORK_ERROR_REPORT 0 WATCH_VARIABLES {CONF} ANTI_INFINITE_LOOP 0 ASSUME_INFINITE_LOOP_AFTER 5 }
Ensure the bot is joined to this channel in your Eggdrop configuration.
-
Log File Location: The script creates a log file in
logs_Error/${::botnet-nick}_Error.log
. Ensure write permissions in thelogs_Error/
directory. -
Loading Additional Scripts: Specify scripts to load in
CONF(SCRIPTS_LIST)
:array set CONF { SCRIPTS_LIST {TopClient/TopClient.tcl} ... }
-
Variable Tracing: Add variables to trace in
CONF(WATCH_VARIABLES)
(e.g.,{CONF error_report}
) to monitor their read/write/unset operations. -
Infinite Loop Protection: Enable loop protection by setting
CONF(ANTI_INFINITE_LOOP) 1
and configure the timeout withCONF(ASSUME_INFINITE_LOOP_AFTER)
(in seconds).
-
Start the Bot: Run your Eggdrop bot as usual. TCL-DebugLoader will load first and handle other specified Tcl scripts.
-
Monitor Errors:
- Check
logs_Error/${::botnet-nick}_Error.log
for detailed error messages and stack traces. - Join the configured
CONF(CHANNEL_LOG)
IRC channel for real-time error notifications.
- Check
-
Debugging:
- If a script fails to load, TCL-DebugLoader logs the error without crashing the bot (unless
DIE_ON_ERROR
is enabled). - Use variable tracing to monitor specific variables (e.g.,
CONF
orerror_report
). - Fix scripts and issue
.rehash
to reload.
- If a script fails to load, TCL-DebugLoader logs the error without crashing the bot (unless
Suppose your bot’s nickname is MyBot
, and CONF(CHANNEL_LOG)
is set to #debug
. If TopClient/TopClient.tcl
contains an error (e.g., undefined variable error_report
), TCL-DebugLoader will:
-
Write to
logs_Error/MyBot_Error.log
:[2025-07-22 01:00:00] Variable read $::DebugLoader::error_report: N/A (Context: some_proc arg1 arg2) [2025-07-22 01:00:00] Error loading TopClient/TopClient.tcl: can't read "error_report": no such variable (Line: 123) [2025-07-22 01:00:00] Stack Trace: [2025-07-22 01:00:00] > can't read "error_report": no such variable [2025-07-22 01:00:00] > while executing [2025-07-22 01:00:00] > "set result $error_report" [2025-07-22 01:00:00] > (procedure "some_proc" line 123)
-
Send to
#debug
:[DebugLoader] Variable read $::DebugLoader::error_report: N/A (Context: some_proc arg1 arg2) [DebugLoader] Error loading TopClient/TopClient.tcl: can't read "error_report": no such variable (Line: 123)
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes and commit (
git commit -m "Add new feature"
). - Push to your branch (
git push origin feature-branch
). - Open a pull request on the GitHub repository.
Please ensure changes are well-documented and tested with an Eggdrop bot.
This project is licensed under the MIT License. See the LICENSE file or https://opensource.org/licenses/MIT for details.
For questions or support, open an issue on the GitHub repository or contact ZarTek-Creole via GitHub.
© 2025 ZarTek-Creole