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

Add chanset bind #1524

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open

Add chanset bind #1524

wants to merge 17 commits into from

Conversation

vanosg
Copy link
Member

@vanosg vanosg commented Jan 13, 2024

Patch by: Geo
Fixes: #1393

This PR adds a bind that triggers when a channel setting is set via the chanset partyline command.

@vanosg vanosg changed the title (WIP) Add chanset bind Add chanset bind Jan 13, 2024
@vanosg
Copy link
Member Author

vanosg commented Jan 13, 2024

Single setting:

.tcl bind chanset * greet foo
Tcl: greet
.tcl proc foo {chan setting value} {putlog "omg! $setting on $chan was set to $value!"}
Tcl: 
.chanset #eggdroptest +greet
[06:27:28] omg! greet on #eggdroptest was set to +!
Successfully set modes { +greet } on #eggdroptest.
[06:27:28] #-HQ# chanset #eggdroptest +greet 

Mask bind:

.tcl bind chanset * * foo
Tcl: *
.tcl proc foo {chan setting value} {putlog "omg! $setting on $chan was set to $value!"}
Tcl: 
.chanset #eggdroptest +greet flood-chan 3:30 +revenge
[06:30:26] omg! greet on #eggdroptest was set to +!
[06:30:26] omg! flood-chan on #eggdroptest was set to 3:30!
[06:30:26] omg! revenge on #eggdroptest was set to +!
Successfully set modes { +greet flood-chan { 3:30 } +revenge } on #eggdroptest.
[06:30:26] #-HQ# chanset #eggdroptest +greet flood-chan { 3:30 } +revenge 

Multi-chan binds:

.chanset * +greet
[06:31:11] omg! greet on #eggdroptest was set to +!
[06:31:11] omg! greet on #foo was set to +!
Successfully set modes { +greet } on all channels.
[06:31:11] #-HQ# chanset * +greet 

@thommey
Copy link
Member

thommey commented Jan 19, 2024

We should use the return value of the Tcl proc to deny the change as invalid. That could be in a new PR, but it is one of the main reasons for the bind, so you can reject a "setudef str" value if it's not valid for your use-case.

@vanosg
Copy link
Member Author

vanosg commented Feb 18, 2024

Added @thommey great suggestion:

.tcl proc foo {chan setting value} {putlog "Nope!"; return 1}
Tcl: 
.tcl bind chanset * bitch foo
Tcl: bitch

.chaninfo #eggtest
Settings for dynamic channel #eggtest:
<snip>
     -bitch          -autoop         -autovoice      -nodesynch
<snip>

.chanset #eggtest +bitch
[15:13:32] Nope!
.chaninfo #eggtest
Settings for dynamic channel #eggtest:
<snip>
     -bitch          -autoop         -autovoice      -nodesynch

src/mod/channels.mod/channels.c Outdated Show resolved Hide resolved
src/mod/channels.mod/channels.c Outdated Show resolved Hide resolved
src/mod/channels.mod/channels.c Outdated Show resolved Hide resolved
need-* settings can allow multiple strings (such as {putlog op me cuz I'm lame}- the attempted fix did not take this into account and would break things
@vanosg
Copy link
Member Author

vanosg commented Feb 19, 2024

Updated logic to allow other chanset values submitted in a single command that don't match the bind to proceed

Using the same proc/bind as above:

.chanset #eggtest +inactive +bitch +seen
[03:19:16] Nope!
Successfully set modes { +inactive +seen  } on #eggtest.
[03:19:16] #-HQ# chanset #eggtest +inactive +seen 

Note +bitch was not set, but other values in the chanset command were. One more example that involves the other call to check_tcl_chanset():

.tcl bind chanset * need-op foo

.chanset #eggtest +seen need-op hi
[03:30:16] Nope!
Successfully set modes { +seen  } on #eggtest.
[03:30:16] #-HQ# chanset #eggtest +seen 

@vanosg vanosg modified the milestones: v1.10.0, v1.10.1 May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add bind trigger for chanset
2 participants