This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Warn Action

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
User avatar
MrBeta
Voice
Posts: 35
Joined: Sat Dec 28, 2013 2:16 pm
Contact:

Post by MrBeta »

Thanks for your work :wink:
I have an error

Code: Select all

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"
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

What TCL version do you have?

Anyway, replacing:

Code: Select all

incr warn($host) 1
with:

Code: Select all

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: Select all

utimer $warn(reset) {incr warn($host) -1 }
with:

Code: Select all

utimer $warn(reset) [list action:reset $host]
and add this nice helper function at the end of the initial code:

Code: Select all

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: Select all

set warn($host) "0" 
with:

Code: Select all

unset warn($host)
Once the game is over, the king and the pawn go back in the same box.
User avatar
MrBeta
Voice
Posts: 35
Joined: Sat Dec 28, 2013 2:16 pm
Contact:

Post by MrBeta »

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: Select all

# 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)
         }
      }
   }
}
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Remove the extra }

Post by SpiKe^^ »

Remove the extra }

Code: Select all

if {[isop $nick $chan]} return} 
making it look more like this

Code: Select all

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
.
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Haven't tested it myself yet though, but will after work :)
ComputerTech
User avatar
MrBeta
Voice
Posts: 35
Joined: Sat Dec 28, 2013 2:16 pm
Contact:

Post by MrBeta »

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 :roll:
The bot give only Warning1 messagge, but don't ban and no give another warn message, only "Warning1"
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

"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
.
User avatar
MrBeta
Voice
Posts: 35
Joined: Sat Dec 28, 2013 2:16 pm
Contact:

Post by MrBeta »

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
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

No Action Dude

Post by SpiKe^^ »

Try this MrBeta

Code: Select all

# 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
.
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Code: Select all

# 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
User avatar
MrBeta
Voice
Posts: 35
Joined: Sat Dec 28, 2013 2:16 pm
Contact:

Post by MrBeta »

Thanks guys, you are the top everything works perfectly. :D
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

With this code in mind

Code: Select all

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.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

pros and cons of many utimers

Post by SpiKe^^ »

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
.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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
.
User avatar
MrBeta
Voice
Posts: 35
Joined: Sat Dec 28, 2013 2:16 pm
Contact:

Post by MrBeta »

This works great on my eggdrop.

Code: Select all

# 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: Select all

# 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)
         }
      }
   }
}
Post Reply