Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.8.4] matchattr is not backward compatible #815

Closed
wilkowy opened this issue Jun 19, 2019 · 4 comments · Fixed by #1005
Closed

[1.8.4] matchattr is not backward compatible #815

wilkowy opened this issue Jun 19, 2019 · 4 comments · Fixed by #1005
Milestone

Comments

@wilkowy
Copy link
Contributor

@wilkowy wilkowy commented Jun 19, 2019

1.6.21:

.tcl matchattr "handle" "-|-" "#channel"
Tcl: 1

1.8.4:

.tcl matchattr "handle" "-|-" "#channel"
Tcl error: Unknown flag specified for matching

Bug or change?

The workaround for now is to check flags for "-" & "-|-" before.

@vanosg vanosg added this to the v1.9.0 milestone Sep 8, 2019
@vanosg
Copy link
Member

@vanosg vanosg commented Sep 8, 2019

Yep, definitely a bug, from what I can see. Yikes!

@vanosg
Copy link
Member

@vanosg vanosg commented Jul 6, 2020

Hi @wilkowy, looking in to this a little more, I want to walk back my last comment of 'bug'. In 1.6.21, the code you wrote would use the - as a 'not' prefix to a flag, not a 'any' flag the way they are used in bind masks (I'm assuming, perhaps incorrectly, that the bind mask format is how you thought it would work?), and didn't provide error checking if no flags were specified after the -. Now, it does.

Is there a specific use case you have, where you anticipate code as you wrote out being used like this? As it was implemented in 1.6.21, I can't think of any scenario where something other than a '1' would be returned when passing - or -|-. Essentially you're not providing Eggdrop any flags to match against, this change brings it more in line and, correctly in my opinion, tells you that no flags were provided (or in the exact terms of the error message, an unknown flag).

But hey, I could easily be wrong here- let me know your thoughts and we'll work through it. I think at minimum I'll add an additional phrase to tcl-commands.doc making explicit the functionality of '-' before closing out this issue. Thanks!

Test examples from 1.6.21 always returning 1:

.+user test1
Added test1 (no host) with no password and no flags.
.whois test1       
HANDLE    PASS NOTES FLAGS           LAST
test1     no       0 -               never (nowhere)
.tcl matchattr test1 -
Tcl: 1
.tcl matchattr test1 -|-
Tcl: 1

.chattr test1 +f #eggheads
No global flags for test1.
Channel flags for test1 on #eggheads are now +f.
.whois test1
HANDLE    PASS NOTES FLAGS           LAST
test1     no       0 -               never (nowhere)
   #eggheads          f               never
.tcl matchattr test1 -
Tcl: 1
.tcl matchattr test1 -|- #eggheads
Tcl: 1
.tcl matchattr test1 |- #eggheads
Tcl: 1

.chattr test1 -f #eggheads
No global flags for test1.
No flags for test1 on #eggheads.
.chattr test1 +f          
Global flags for test1 are now +f.
.whois test1
HANDLE    PASS NOTES FLAGS           LAST
test1     no       0 f               never (nowhere)
   #eggheads          -               never
.tcl matchattr test1 -
Tcl: 1
.tcl matchattr test1 -|-
Tcl: 1
.tcl matchattr test1 -|- #eggheads
Tcl: 1
.tcl matchattr test1 |- #eggheads
Tcl: 1

@vanosg
Copy link
Member

@vanosg vanosg commented Jul 15, 2020

@wilkowy Hi! Any comments on these new docs or what I presented above, before we close it out? Thanks!

vanosg added a commit that referenced this issue Jul 15, 2020
Found by: wilkowy
Patch by: Geo
Fixes: #815

One-line summary:
Update docs to better describe matchattr functionality

Additional description (if needed):
While not necessarily a bug, better docs can help explain the functionality of matchattr. Also fixed some typos in tcl-commands.doc and firstinstall while we're at it.
@wilkowy
Copy link
Contributor Author

@wilkowy wilkowy commented Oct 8, 2020

@vanosg Sorry, had no time to check GitHub for some time. This issue is not the problem with the docs, but with the changed handling of matchattr which causes some older scripts to break now. The "-|-" or "-" check is to see if user isn't added to userlist or is added without any global/channel flags (a handle grouping multiple hosts for a single user) - a common user without any privileges.
Currently I don't have access to Eggdrop 1.6.21 nor time to setup one, but I'm pretty sure this behaviour is different/broken than it was in 1.6.21 - now it is:

.tcl matchattr unknownwilk "-|-" #channel
Tcl: 0
.tcl matchattr unknownwilk "-" #channel
Tcl: 0
.tcl matchattr unknownwilk "" #channel
Tcl: 0

.+user knownwilk
Added knownwilk (no host) with no password and no flags.

.tcl matchattr knownwilk "-|-" #channel
Tcl error: Unknown flag specified for matching
.tcl matchattr knownwilk "-" #channel
Tcl error: Unknown flag specified for matching
.tcl matchattr knownwilk "" #channel
Tcl error: Unknown flag specified for matching

Eggdrop 1.8.4 triggers an error while checking for existing user, while it doesn't for not added one. Eggdrop 1.6.21 just returned "0" for both cases. Such behaviour was useful for example in triggering actions for dynamic binds which processed whole channel text:

set ourchan "#funnychan"

set privileged_users "f|f"
# change to "-|-"/"-" to allow access by everyone

[...]

bind pubm - "$ourchan *" handler

proc handler {nick uhost hand chan text} {

	if {[string match -nocase "*hello*" $text] && [matchattr $hand $::privileged_users $chan]} {
		puthelp "PRIVMSG $chan :Hello my friend!"
	} else {
		puthelp "PRIVMSG $chan :Hello random person."
	}

}

The non-existing handle can be checked with validuser function, but how to quickly check if existing handle has no flags?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants