Mise en forme de code: pensez à utiliser les balises [ tcl ] et [ /tcl ] (sans les espaces bien sûr) autour de vos codes tcl afin d'avoir un meilleur rendu et une coloration syntaxique.
x
You have a global badwords in your proc, but I can't find any place where this variable is setted.
And I don't know how you copy/paste your code here, but next time, just copy from your source file. And don't double post, it won't make us reply you faster.
20/11/2020, 01:52 (This post was last modified: 20/11/2020, 02:02 by AlbozZ.)
Sorr yi am new in this forum i dont know how functions here till i learn
I am not a script tcl coders what to do now with this error cant be fix this error to set variable?
As previously said, the variable $badwords is never created nor filled, you just declare that it's a global variable.
Your script lacks an initialisation procedure to fill (and refresh) $badwords with the content of your file.
Well, your first post was: Tcl error [pubm_badword]: can't read "badwords": no such variable
Now, you have Tcl error [badwords: pubm]: can't read "badword": no such variable
$badword is set in foreach badword [string tolower $badwords] { so it exists if $badwords is set and no empty, else you won't enter the loop:
Code:
.tcl set badwords ""
Tcl:
.tcl foreach badword [string tolower $badwords] { putlog "*$badword*" }
Tcl:
.tcl set badwords "test another"
Tcl: test another
.tcl foreach badword [string tolower $badwords] { putlog "*$badword*" }
[14:27] *test*
[14:27] *another*
Already explained in IRC: trying to match s t u p i d is really dangerous: you'll have to remove all the spaces in the line and check if it matches *stupid*. The risk is to have a lot of false positive.
Example (in french): badword is "con" and someone say "donc on fait quoi?". Without spaces, it gives "donconfaitquoi?" and it matches.
For the two others, I already gave you the regexp to use:
[18:35:37] <VIRUS> s tu-pid]
[18:35:37] * Nasa sets mode: + b *!*@nasa.army-3F8BE0D0.access.hol.gr
[18:36:30] <Test1> Stup id
[18:36:30] * Nasa sets mode: + b *! Uid465250 @ *
[18:38:07] <VIRUS> shiscute
[18:38:11] <VIRUS> sh it
[18:38:11] * Nasa sets mode: + b *!*@nasa.army-3F8BE0D0.access.hol.gr
[18:39:15] <VIRUS> i have to work the late shift
[18:39:17] <VIRUS> sh it
[18:39:17] * Nasa sets mode: + b *!*@nasa.army-3F8BE0D0.access.hol.gr
and action ctcp cant match badword
but how to make a alias letters replacement
to match and this patterns when they replace letters with other letters char numbers?
[06:46:25] <VIRUS> sh1t
i = 1! l |
a = 4 @
e = 3
o = 0
s = $ 5
ctcp actions is not match badwords
actual code i have now
tcl
### ++++ Script name: Badwords######################################################## New Commands (Public or Message)# .bw #channel/global on/off# .bw #channel/global ban-reason REASON# .bw #channel/global ban-type 1/2/3/4# .bw #channel/global add WORD/PHRASE# .bw #channel/global del WORD/PHRASE# .bw #channel/global list######################################################setudef flag badwords
bind MSG n .bw badwords:msgbindctcp - ACTION ctcp_badwords
proc badwords:msg{nick uhost hand arg}{
badwords:pub$nick$uhost$hand""$arg}proc badwords:pub{nick uhost hand chan arg}{global badwords tempbw
if{$chan eq ""}{set sendto $nick;set pre ""}else{set sendto $chan;set pre "\002$nick\002 - "}set alist [split[string trim $arg]]set opt [string tolower [lindex$alist0]]if{[string match "#*"$opt] || $opt eq "global" || $opt eq "glob"}{if{[string match "g*"$opt]}{set target "global"}else{if{![validchan$opt]}{putserv"PRIVMSG $sendto :${pre}$opt is not a valid channel.";return}set target $opt}set alist [lrange$alist1 end]set opt [string tolower [lindex$alist0]]}elseif{$chan eq ""}{set target "global"}else{set target [string tolower $chan]}#putlog "chan=$chan||arg=$arg|<>|sendto=$sendto||opt=$opt||target=$target||alist=$alist||"set word [lindex$alist1]set words [string trim [join[lrange$alist1 end]]]switch -exact -- $opt{
ban-type -
-ban-type {if{$word eq ""}{putserv"PRIVMSG $sendto :${pre}You have to specify ban-type (1/2/3/4)";return}if{![regexp{^(1|2|3|4)$}$word]}{putserv"PRIVMSG $sendto :${pre}valid types are 1/2/3 or 4 (!badwords ban-type 2)";return}set tempbw($target,ban-type)$word
badwords:saveputserv"PRIVMSG $sendto :${pre}$target 'ban-type' has been SET"}
-r -
-reason {if{$word eq ""}{putserv"PRIVMSG $sendto :${pre}You have to specify a ban-reason";return}set tempbw($target,reason)$words
badwords:saveputserv"PRIVMSG $sendto :${pre}$target 'ban-reason' has been SET"}
on -
-on {if{$target eq "global"}{foreach ch [channels]{channelset$ch +badwords }putserv"PRIVMSG $sendto :${pre}Succesfully activated \00303badwords\003 script on all channels."}else{channelset$target +badwords
putserv"PRIVMSG $sendto :${pre}Succesfully activated \00303badwords\003 script on $target"}}
off -
-off {if{$target eq "global"}{foreach ch [channels]{channelset$ch -badwords }putserv"PRIVMSG $sendto :${pre}Succesfully deactivated \00303badwords\003 script on all channels."}else{channelset$target -badwords
putserv"PRIVMSG $sendto :${pre}Succesfully deactivated \00303badwords\003 script on $target"}}
add -
-add {if{$word eq ""}{putserv"PRIVMSG $sendto :${pre}You have to specify a badword to add.";return}set isbad [string tolower $words]if{[info exists badwords($target,$isbad)]}{putserv"PRIVMSG $sendto :${pre}'\00312$isbad\003' already exists in the $target database."return}set badwords($target,$isbad)"[unixtime] $nick"
badwords:saveputserv"PRIVMSG $sendto :${pre}Succesfully added '\00312$isbad\003' into the $target database."}
del -
-del {if{$word eq ""}{putserv"PRIVMSG $sendto :${pre}You have to specify a badword to delete.";return}set isbad [string tolower $words]if{![info exists badwords($target,$isbad)]}{putserv"PRIVMSG $sendto :${pre}'\00312$isbad\003' was not found in the $target database."return}
unset -nocomplain badwords($target,$isbad)
badwords:saveputserv"PRIVMSG $sendto :${pre}Succesfully removed '\00312$isbad\003' from the $target database."}list -
-list{set temp(list)""foreach b [array names badwords $target,*]{lappend temp(list)[lindex[split$b ,]1]}if{$temp(list) eq ""}{putserv"PRIVMSG $sendto :${pre}Badwords database for \00303$target\003 is \002empty\002"return}putserv"PRIVMSG $sendto :${pre}$target \00303badwords\003: [join $temp(list) ", "]"}
reset -
-reset {
array unset badwords "$target,*"
badwords:saveputserv"PRIVMSG $sendto :${pre}Succesfully RESET $target badwords."}}}bind PUBM - * badwords:pubmproc badwords:pubm{nick uhost hand chan arg}{global badwords tempbw
if{![channel get $chan badwords] || ![botisop$chan] || [matchattr$hand mn] || [isop$nick$chan]}{return0}set chan [string tolower $chan]set clist [array names badwords "$chan,*"]set glist [array names badwords "global,*"]set users [list]set umasks [list]set arg [string trim $arg]set arg [split$arg]set text [string tolower $arg]set ban_time 5foreach b [concat$clist$glist]{set re [join[split[lindex[split$b ,]1]{}]{+[^a-zA-Z0-9]*}]if{[string match -nocase "*[lindex [split $b ,] 1]*"$arg] || [regexp -nocase $re$text]}{if{[info exists tempbw($chan,ban-type)]}{set bantype $tempbw($chan,ban-type)}elseif{[info exists tempbw(global,ban-type)]}{set bantype $tempbw(global,ban-type)}else{set bantype 2}if{[info exists tempbw($chan,reason)]}{set reason $tempbw($chan,reason)}elseif{[info exists tempbw(global,reason)]}{set reason $tempbw(global,reason)}else{set reason "Go sit in the corner"}if{[set chost $uhost] ne ""}{switch -glob -- $chost{{*.irccloud.com} - {*.mibbit.com} - {*.kiwiirc.com}{set mask *![lindex[split$chost @]0]@*}{default}{set mask [maskhost"$nick!$chost"2]}}}lappend users $nicklappend umasks $maskset count [llength$users]set count [llength$umasks]putquick"MODE $chan -[string repeat "v" $count]+[string repeat "b" $count] [join $users] [join $umasks]"
after [expr$ban_time*1000*60][listputserv"MODE $chan -[string repeat "b" $count] [join $umasks]"]#putserv "Kick $chan $nick :$badword_msg"return0}}}proc ctcp_badwords {nick uhost hand chan key arg}{proc badwords:pubm{nick uhost hand chan arg}{}}proc mh {nuhost type}{
lassign [split$nuhost!@] n u h
switch$type{1{return$nuhost}2{return*!*@$h}3{return*!*$u@$h}4{return*!*$u@*}}}proc badwords:save{}{global badwords tempbw
set ofile [open badwords w]puts$ofile"array set badwords [list [array get badwords]]"puts$ofile"array set tempbw [list [array get tempbw]]"close$ofile}catch{source badwords}putlog"Succesfully loaded: \00312Badwords TCL Script"
If you really have done the script, you're able to implement the two regsub I gave you.
If you just found a script and say it's yours, I can't help you.