egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Warn Action
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
MrBeta
Voice


Joined: 28 Dec 2013
Posts: 35

PostPosted: Wed Mar 10, 2021 3:54 am    Post subject: Reply with quote

Thanks for your work Wink
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
View user's profile Send private message Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Wed Mar 10, 2021 8:00 am    Post subject: Reply with quote

What TCL version do you have?

Anyway, replacing:
Code:

incr warn($host) 1
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:
Code:

unset warn($host)

_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
MrBeta
Voice


Joined: 28 Dec 2013
Posts: 35

PostPosted: Wed Mar 10, 2021 9:47 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Wed Mar 10, 2021 11:58 am    Post subject: Remove the extra } Reply with quote

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
View user's profile Send private message Visit poster's website
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 393

PostPosted: Wed Mar 10, 2021 2:14 pm    Post subject: Reply with quote

Haven't tested it myself yet though, but will after work Smile
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
MrBeta
Voice


Joined: 28 Dec 2013
Posts: 35

PostPosted: Thu Mar 11, 2021 9:52 am    Post subject: Reply with quote

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 Rolling Eyes
The bot give only Warning1 messagge, but don't ban and no give another warn message, only "Warning1"
Back to top
View user's profile Send private message Visit poster's website
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Thu Mar 11, 2021 10:21 am    Post subject: Reply with quote

"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
View user's profile Send private message Visit poster's website
MrBeta
Voice


Joined: 28 Dec 2013
Posts: 35

PostPosted: Thu Mar 11, 2021 10:36 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Thu Mar 11, 2021 6:49 pm    Post subject: No Action Dude Reply with quote

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
View user's profile Send private message Visit poster's website
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 393

PostPosted: Thu Mar 11, 2021 8:32 pm    Post subject: Reply with quote

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 Smile

(Not sure if it's the "best" way to do so, but it works perfectly here)
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
MrBeta
Voice


Joined: 28 Dec 2013
Posts: 35

PostPosted: Fri Mar 12, 2021 4:52 am    Post subject: Reply with quote

Thanks guys, you are the top everything works perfectly. Very Happy
Back to top
View user's profile Send private message Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Fri Mar 12, 2021 5:18 am    Post subject: Reply with quote

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
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Fri Mar 12, 2021 10:22 am    Post subject: pros and cons of many utimers Reply with quote

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
View user's profile Send private message Visit poster's website
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Fri Mar 12, 2021 10:29 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
MrBeta
Voice


Joined: 28 Dec 2013
Posts: 35

PostPosted: Fri Mar 12, 2021 4:04 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber