eggdrop
eggdrop copied to clipboard
WIP: Add `timerexistsname` and `utimerexistsname` Tcl commands to check timer existence
โ Title
WIP: Add `timerexists` and `utimerexists` Tcl commands to check timer existence
๐ Description
## Summary
This pull request introduces two new experimental Tcl commands for Eggdrop:
- `timerexists <name>`
- `utimerexists <name>`
These commands allow script authors to check whether a timer or utimer with a given name currently exists.
This is meant to complement `killtimer` and `killutimer` by providing a safe way to check existence before attempting to remove a timer.
---
## ๐ง Status
๐ง **Draft / WIP** โ Not tested yet.
Needs review and validation from Eggdrop core devs.
---
## ๐ Proposed Commands
### `timerexists <timerName>`
Returns `1` if a timer with this name exists, `0` otherwise.
### `utimerexists <timerName>`
Same as above, but for secondly-based timers.
---
## ๐ก Motivation
Currently, scripts must use complex or error-prone workarounds to detect timers.
This patch introduces a clean, reliable way to check if a timer/utimer exists by name.
### Example: current workaround
```tcl
set t [utimer 1 myTimer] 0 myTimer
if {[info exists t] && [catch {killutimer myTimer} error]} {
putlog "Warning: Unable to kill utimer ($error)."
}
With this feature:
utimer 1 myTimer 0 myTimer
if {[utimerexists myTimer]} {
killutimer myTimer
}
๐งฉ Integration details
- Implemented in
src/tclmisc.c - Reuses the logic from
killtimer/killutimer - No known side-effects
- Syntax is consistent with existing Eggdrop command naming (explicit and clear)
โ ๏ธ Notes
- โ Not yet tested
- โ Documentation still needs to be updated (
doc/tcl-commands.doc) - ๐งช Needs review by maintainers to confirm viability, naming, behavior, etc.
- ๐ค Suggestions and improvements welcome
i guess you want to add the documentation to doc/sphinx_source/using/tcl-commands.rst
is there any relation to #507?
Good idea but with another name, as (u)timerexists is already existing in alltools.tcl and used by several scripts and doesn't search on the same argument (command vs name).