eggdrop icon indicating copy to clipboard operation
eggdrop copied to clipboard

matchattr throws an error when testing -|-

Open crazycatdevs opened this issue 2 years ago • 4 comments

A long time before, with eggdrop 1.6.21, it was possible to do matchattr $nick -|- $chan and it returned 1 when user was unknow or haven't any flag in eggdrop. Actually (since 1.8.x), it throws an error:

Tcl error: Unknown flag specified for matching

This also happen if you want to check if user has no global flag but a channel flag, or if user has global flag but no chan flag.

So, the only way to now check that is to do $handle != "*" && [chattr $handle $chan]=="-" Old scripts must be modified, which could be a potential danger: some users don't update their eggdrops because scripts doesn't work anymore

crazycatdevs avatar Mar 02 '22 15:03 crazycatdevs

Origin of the issue: MenzAgitat

crazycatdevs avatar Mar 05 '22 15:03 crazycatdevs

When we redid the matchattr logic in 1.8.3, we did not accout for the '-' flag. Oops.

    if (!minus.global && !minus.udef_global && !minus.chan &&
        !minus.udef_chan && !minus.bot) {
      nom = 1;
      if (!plus.global && !plus.udef_global && !plus.chan &&
          !plus.udef_chan && !plus.bot) {
        Tcl_AppendResult(irp, "Unknown flag specified for matching", NULL);
        return TCL_ERROR;

So, we need to either modify the struct in flags.h, or just generally allow it in code, and make down-code changes.

vanosg avatar Mar 05 '22 15:03 vanosg

Referencing: #815

In my quizbot I had to apply a patch to check for "-" and "-|-":

if {$flags in [list "-" "-|-"] || [matchattr $hand $flags $chan]} {
	return 1
}
return 0

wilkowy avatar Jun 16 '22 09:06 wilkowy

So again I jumped the gun without re-acquainting myself with how this command works - previously discussed in #815. The '-' in this case means "not a flag", not "anything" as it does when used with binds, for instance. ie, +o means "has o", and -o means "not o", and "-" results in an error because there is no flag listed after the -.

Open for more discussion on this, but we have one symbol meaning two things, with both having historical precedent in this command

vanosg avatar Sep 06 '22 20:09 vanosg