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.
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
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...").