| View previous topic :: View next topic |
| Author |
Message |
bwkzb Voice
Joined: 12 Mar 2017 Posts: 16
|
Posted: Tue Apr 09, 2019 12:32 am Post subject: doubt of code |
|
|
| Code: |
set spy(home) "#canal1"
set spy(chan) "#canal2"
set words { *banned* }
bind KICK -|- "$spy(chan) *" spychan:kick
proc spychan:kick { nickname hostname handle channel target reason } {
global spy
if {[string equal -nocase $channel $spy(chan)]} {
putserv "PRIVMSG $spy(home) :$channel * $target was kicked from
$spy(chan) by $nickname $reason"
}
} else {
if {[string match "*" [string tolower $reason]]} {
set results 0
foreach x $::words {
if {[string match -nocase *$x* $reason]} {
incr results
}
}
if {$results > 0} { putquick "SAJOIN $target #expulsed" }
}
|
how it could be transformed or added to this code that reads the kicks of users and bots with a certain reason.
For example, read the reason of the kick ("banned") and read that reason and send them back with a SAJOIN to a channel #expulsed
Last edited by bwkzb on Tue Apr 09, 2019 5:21 pm; edited 2 times in total |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Apr 09, 2019 1:17 pm Post subject: |
|
|
Let me see if I understood your question right:
You'd like to inspect all kick-reasons for certain keywords; if found, the target should be SAJOIN'd to some channel #expulsed?
In that case, most of the bits are already there; just some cleanup and proper syntax needed:- Your brackets, {}, are misaligned causing your proc to end before the "} else {" section. This would most likely throw an error when you try to load the script.
- Testing the kick-reason against "*" will always be true, which is pointless. Just send the PRIVMSG. Also, the PRIVMSG has a newline in it, which cannot be sent correctly.
- Since you are only interrested in finding a match, not the total number of matches, there's no point in iterating through the list of patterns once a match has been found. Do the SAJOIN here and then break
| Code: | set spy(home) "#canal1"
set spy(chan) "#canal2"
set words { *banned* }
bind KICK -|- "$spy(chan) *" spychan:kick
proc spychan:kick {nickname hostname handle channel target reason} {
putserv "PRIVMSG $spy(home) :$channel * $target was kicked from $spy(chan) by $nickname $reason"
foreach x $::words {
if {[string match -nocase "*$x*" "$reason"]} {
putquick "SAJOIN $target #expulsed"
break
}
}
} |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
bwkzb Voice
Joined: 12 Mar 2017 Posts: 16
|
Posted: Fri Apr 19, 2019 4:00 pm Post subject: |
|
|
Thank you very much for responding and sorry for the delay.
and the variable so that the code reads the badwords of the reasons for the kicks in a .txt file as it would be
| Code: |
set spy(home) "#canal1"
set spy(chan) "#canal2"
set words "scripts/bd/bdreason.txt"
bind KICK -|- "$spy(chan) *" spychan:kick
proc spychan:kick {nickname hostname handle channel target reason} {
global spy
putserv "PRIVMSG $spy(home) :$channel * $target was kicked from $spy(chan) by $nickname $reason"
foreach bdreason $::words {
if {[string match -nocase "*$bdreason*" "$reason"]} {
putquick "SAJOIN $target #expulsed"
break
}
}
}
|
|
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Mon Apr 22, 2019 4:28 pm Post subject: |
|
|
Well, there are a few ways we can go here...
- Read the textfile to memory on startup
- Read the textfile everytime the kick-binding triggers
- A mix of the two... (advanced stuff)
In the first two cases, the code is pretty much the same; just a matter when to call it:
| Code: | set fd [open "scripts/bd/bdreason.txt" "r"]
set ::words [split [read $fd] "\n"]
close $fd |
This would add each line in bdreason.txt as a separate item in the _::words_ variable. This code could either be included inside the spychan:kick proc, or at the start of the script (in place of the current set words "scripts..."). _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|