| View previous topic :: View next topic |
| Author |
Message |
MrBeta Voice
Joined: 28 Dec 2013 Posts: 35
|
Posted: Wed Mar 10, 2021 3:54 am Post subject: |
|
|
Thanks for your work
I have an error
| Code: |
can't read "host": no such variable
while executing
"incr warn($host) 1"
(file "scripts/noaction.tcl" line 22)
invoked from within
"source scripts/noaction.tcl"
|
|
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Mar 10, 2021 8:00 am Post subject: |
|
|
What TCL version do you have?
Anyway, replacing:
with: | Code: |
if {[info exists warn]} {
set warn($host) 1
} else {
incr warn($host) 1
}
|
should take care of the issue.
Next I would also replace this:
| Code: |
utimer $warn(reset) {incr warn($host) -1 }
| with: | Code: |
utimer $warn(reset) [list action:reset $host]
|
and add this nice helper function at the end of the initial code:
| Code: |
proc action:reset {host} {
global warn
if {[array names warn] != {}} {
if {[lsearch -nocase [array names warn] $host] > -1} {
if {$warn($host) > 1} {
incr warn($host) -1
} else {
unset warn($host)
}
}
}
}
|
Oh, and another thing, should consider unset the warn(host) when said host is banned to save on memory. I mean replace:
| Code: |
set warn($host) "0"
| with: _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
MrBeta Voice
Joined: 28 Dec 2013 Posts: 35
|
Posted: Wed Mar 10, 2021 9:47 am Post subject: |
|
|
It gives me this error, I use egg 1.8.4
can't read "host": no such variable
while executing
"set warn($host) 1"
(file "scripts/noaction.tcl" line 23)
| Code: | # Set max warnings before Punishment
set warn(max) "3"
# Set X time before timer undo's warning amount (in seconds)
set warn(reset) "60"
# Set Kick Reason
set warn(reason) "Hey No Action Please!"
######################
bind CTCP - ACTION action:avoid
proc action:avoid {nick host hand chan key text} {
global warn
if {[isbotnick $nick]} return
if {[matchattr $hand "ofmn|ofmm"]} return
if {[isop $nick $chan]} return}
if {[info exists warn]} {
set warn($host) 1
} else {
if {[info exists warn]} {
set warn($host) 1
} else {
incr warn($host) 1
}
}
if {$warn($host) > $warn(max)} {
putquick "MODE $chan +b $host"
putquick "KICK $chan $nick $warn(reason)"
unset warn($host)
} else {
putserv "PRIVMSG $chan :Warning $warn($host)"
utimer $warn(reset) [list action:reset $host]
}
}
proc action:reset {host} {
global warn
if {[array names warn] != {}} {
if {[lsearch -nocase [array names warn] $host] > -1} {
if {$warn($host) > 1} {
incr warn($host) -1
} else {
unset warn($host)
}
}
}
}
|
|
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Wed Mar 10, 2021 11:58 am Post subject: Remove the extra } |
|
|
Remove the extra }
| Code: | | if {[isop $nick $chan]} return} |
making it look more like this
| Code: | | if {[isop $nick $chan]} return |
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Wed Mar 10, 2021 2:14 pm Post subject: |
|
|
Haven't tested it myself yet though, but will after work  _________________ ComputerTech |
|
| Back to top |
|
 |
MrBeta Voice
Joined: 28 Dec 2013 Posts: 35
|
Posted: Thu Mar 11, 2021 9:52 am Post subject: |
|
|
I removed the extra code but it doesn't work for me, it still gives me an error. I await the code cleaned by you to test again, surely I am doing something wrong
The bot give only Warning1 messagge, but don't ban and no give another warn message, only "Warning1" |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Thu Mar 11, 2021 10:21 am Post subject: |
|
|
"doesn't work for me, it still gives me an error" is no help at all.
Post the new error here... _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
MrBeta Voice
Joined: 28 Dec 2013 Posts: 35
|
Posted: Thu Mar 11, 2021 10:36 am Post subject: |
|
|
The error message was my fault for importing the unmodified tcl.
However, the continuous Warning 1 message remains for each action sent in the channel, but no ban after 3/4/5 and more repetitions |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Thu Mar 11, 2021 6:49 pm Post subject: No Action Dude |
|
|
Try this MrBeta
| Code: |
# Set max warnings before Punishment
set warn(max) "3"
# Set X time before timer undo's warning amount (in seconds)
set warn(reset) "120"
# Set Kick Reason
set warn(reason) "Hey No Action Please!"
######################
bind CTCP - ACTION action:avoid
proc action:avoid {nick host hand chan key text} {
global warn
if {[isbotnick $nick] || [isbotnick $chan]} { return 0 }
if {[matchattr $hand "ofmn|ofmm" $chan]} { return 0 }
if {[isop $nick $chan]} { return 0 }
if {![info exists warn($host)]} {
set warn($host) 1
utimer $warn(reset) [list action:reset $host]
} else { incr warn($host) }
if {$warn($host) > $warn(max)} {
putquick "MODE $chan +b *!$host"
putquick "KICK $chan $nick $warn(reason)"
} else {
putserv "PRIVMSG $chan :Warning $warn($host): No Action Please"
}
return 0
}
proc action:reset {host} {
global warn
if {[info exists warn($host)]} { unset warn($host) }
}
|
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Thu Mar 11, 2021 8:32 pm Post subject: |
|
|
| Code: |
# Set max warnings before Punishment
set warn(max) "4"
# Set X time before timer undo's warning amount (in seconds)
set warn(time) "120"
# Set Kick Reason
set warn(reason) "Hey No Action Please!"
bind CTCP - ACTION action:avoid
proc action:avoid {nick host hand chan key text} {
global warn
if {[isbotnick $nick] || [isbotnick $chan]} { return 0 }
if {[matchattr $hand "ofmn|ofmm" $chan]} { return 0 }
if {[isop $nick $chan]} { return 0 }
incr warn($host) +1
if {$warn($host) > $warn(max)} {
putquick "MODE $chan +b *!$host"
putquick "KICK $chan $nick $warn(reason)"
unset warn($host)
} else {
putserv "PRIVMSG $chan :Warning $warn($host)"
utimer $warn(time) [list action:reset $host]
}
}
proc action:reset {host} {
global warn
if {[array names warn] != {}} {
if {[lsearch -nocase [array names warn] $host] > -1} {
if {$warn($host) > 1} {
incr warn($host) -1
} else {
unset warn($host)
}
}
}
}
|
Tested and working
(Not sure if it's the "best" way to do so, but it works perfectly here) _________________ ComputerTech |
|
| Back to top |
|
 |
MrBeta Voice
Joined: 28 Dec 2013 Posts: 35
|
Posted: Fri Mar 12, 2021 4:52 am Post subject: |
|
|
Thanks guys, you are the top everything works perfectly.  |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Fri Mar 12, 2021 5:18 am Post subject: |
|
|
With this code in mind
| Code: |
if {[info exists warn($host)]} { unset warn($host) }
|
consider the following scenario:
user dose a /me and triggers the action:avoid function. user is given 1 warning and has his warn(host) set to 1.
in a short time frame, before the utimer (with whatever value you got set at warn(time)) kicks in, the same user dose a second /me and triggers the action:avoid function gets his warning, his warn(host) goes to 2 and a second delayed utimer will reset his points.
the first utimer kicks in and instead of lowering the warning from 2 to 1 will remove the host completely, thus making the "warn before ban" not work as intended, meaning will only issue an initial "warning" without the punishment IF the user doesn't do 3x (or whatever you set at warn(max)) /me in a short time frame.
tldr: stick with the version ComputerTech posted. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Fri Mar 12, 2021 10:22 am Post subject: pros and cons of many utimers |
|
|
The biggest difference between the 2 scan methods is that the one I prefer sets a single utimer for each host, and the other method sets a utimer for each action, could be 3 or 4 running utimers per host.
I call the single timer method fuzzy scanning, and the many timer method explicit scanning. In actual usage on actual abusers few will notice any differences ever, with far fewer running timers.
Every coding method has pros and cons, tradeoffs that can be weighed and decided on. For this warning script, scanning for things that do not threaten the channel in any way, I chose the low resource fuzzy method. I stand by my decision there. Users should make their own choices between the two methods... _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Fri Mar 12, 2021 10:29 am Post subject: |
|
|
MrBeta,
Which version of the script have you tested to be working please? _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
MrBeta Voice
Joined: 28 Dec 2013 Posts: 35
|
Posted: Fri Mar 12, 2021 4:04 pm Post subject: |
|
|
This works great on my eggdrop.
| Code: | # Set max warnings before Punishment
set warn(max) "4"
# Set X time before timer undo's warning amount (in seconds)
set warn(time) "120"
# Set Kick Reason
set warn(reason) "Hey No Action Please!"
bind CTCP - ACTION action:avoid
proc action:avoid {nick host hand chan key text} {
global warn
if {[isbotnick $nick] || [isbotnick $chan]} { return 0 }
if {[matchattr $hand "ofmn|ofmm" $chan]} { return 0 }
if {[isop $nick $chan]} { return 0 }
incr warn($host) +1
if {$warn($host) > $warn(max)} {
putquick "MODE $chan +b *!$host"
putquick "KICK $chan $nick $warn(reason)"
unset warn($host)
} else {
putserv "PRIVMSG $chan :Warning $warn($host)"
utimer $warn(time) [list action:reset $host]
}
}
proc action:reset {host} {
global warn
if {[array names warn] != {}} {
if {[lsearch -nocase [array names warn] $host] > -1} {
if {$warn($host) > 1} {
incr warn($host) -1
} else {
unset warn($host)
}
}
}
} |
I just made a change for the warning message, because it only reported Warning 1, 2, 3, etc
| Code: | # Set max warnings before Punishment
set warn(max) "3"
# Set X time before timer undo's warning amount (in seconds)
set warn(time) "22"
# Set Warn Message
set warn(reason2) "Please No Action "
# Set Kick Reason
set warn(reason) "NO Action /me! Do you understand?"
bind CTCP - ACTION action:avoid
proc action:avoid {nick host hand chan key text} {
global warn
if {[isbotnick $nick] || [isbotnick $chan]} { return 0 }
if {[matchattr $hand "ofmn|ofmm" $chan]} { return 0 }
if {[isop $nick $chan]} { return 0 }
incr warn($host) +1
if {$warn($host) > $warn(max)} {
putquick "MODE $chan +b *!$host"
putquick "KICK $chan $nick $warn(reason)"
unset warn($host)
} else {
putserv "PRIVMSG $chan :$warn(reason2) $warn($host) Warning"
utimer $warn(time) [list action:reset $host]
}
}
proc action:reset {host} {
global warn
if {[array names warn] != {}} {
if {[lsearch -nocase [array names warn] $host] > -1} {
if {$warn($host) > 1} {
incr warn($host) -1
} else {
unset warn($host)
}
}
}
} |
|
|
| Back to top |
|
 |
|