eggheads / eggdrop

The Eggdrop IRC Bot
GNU General Public License v2.0
493 stars 88 forks source link

python: unable to remove a bind #1560

Open crazycatdevs opened 2 months ago

crazycatdevs commented 2 months ago

Hi, testing the feature/python branch, I notice it's quite difficult to remove a python bind.

Test script:

from eggdrop import *

def tb(nick, uhost, handle, chan, text, **kwargs):
    tcl.putmsg(chan, 'ok, try unbinding')
    try:
        unbind('pub', '*', '!tb', tb)
    except:
        tcl.putmsg(chan, "1. unbind didn't work")
        try:
            tcl.unbind('pub', '*', '!tb', tb)
        except:
            tcl.putmsg(chan, "2. tcl.unbind didn't work")

bind('pub', '*', '!tb', tb)

Script loaded:

#CrazyCat# binds python
Command bindings:
      TYPE FLAGS    COMMAND              HITS BINDING (TCL)
       pub -|-      !tb                     0 *python:pub:!tb:74a92668

In channel:

<CrazyCat> !tb
<pyegg> ok, try unbinding
<pyegg> 1. unbind didn't work
<pyegg> 2. tcl.unbind didn't work

And the only way to delete it is .tcl unbind pub * !tb *python:pub:!tb:74a92668

vanosg commented 2 months ago

in short- @thommey we need a python unbind command

michaelortmann commented 1 month ago

maybe it would be enough to change function tcl_bind() in tclhash.c so it works similar to function tell_binds() in tclhash.c? so that .tcl unbind python * [...] would work?