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 

Amount of Warnings before action option

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 250

PostPosted: Thu Feb 18, 2021 5:42 pm    Post subject: Amount of Warnings before action option Reply with quote

So i was wondering how to make it a user can choose how many warnings until kicking

Code:

#Badwords
set swearwords {
"*[censored]*"
"*wank*"
"*pussy*"
"*[censored]*"
}

#Time until reset warnings

set brd "30"


###########Code############
setudef flag ctswear

bind pubm - * ctswear:pub
bind ctcp - ACTION ctswear:act

proc ctswear:pub {nick host hand chan text} {
global swearwords brd
if {[channel get $chan ctswear]} {
   foreach badword $swearwords {
    if {[string match -nocase $badword $text]} {
incr warn +1
if {$warn($host) == "1"} {
putserv "NOTICE $nick :Warning! Do not Swear on $chan, cease immediately or else"
utimer $brd {set warn "0"}
} elseif {$warn($host) == "2"} {
utimer $brd {set warn "1"}
putserv "NOTICE $nick :Warning! Do not swear on $chan, cease immediately or else"
} elseif {$warn($host) == "3"} {
putserv "kick $nick $chan Kickbanned from $chan : Reason: Use of swear word $badword"
set warn($host) "0"
    }
   }
  }
 }
}


so like

Code:

set warnings "5"

will allow 5 of
Code:

putserv "NOTICE $nick :Warning! Do not swear on $chan, cease immediately or else"

Before doing
Code:

putserv "kick $nick $chan Kickbanned from $chan : Reason: Use of swear word $badword"


Any ideas and help is much appreciated Very Happy
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 250

PostPosted: Thu Feb 18, 2021 6:16 pm    Post subject: Reply with quote

Nevermind Laughing

Found a way

Code:

#Badwords
set swearwords {
"*[censored]*"
"*wank*"
"*pussy*"
"*[censored]*"
}

#Time until reset warnings

set brd "30"

#max warning

set maxwarning "5"

###########Code############
setudef flag ctswear

bind pubm - * ctswear:pub

proc ctswear:pub {nick host hand chan text} {
global swearwords brd maxwarning warn
if {[channel get $chan ctswear]} {
   foreach badword $swearwords {
    if {[string match -nocase $badword $text]} {
incr warn($host) +1
if{![info exists warn]} {return}
if {![$warn($host) == $maxwarning]} {
putserv "NOTICE $nick :Warning! Do not Swear on $chan, cease immediately or else"
utimer $brd {incr warn($host) -1 }
} else {
putserv "kick $nick $chan Kickbanned from $chan : Reason: Use of swear word $badword"
set warn($host) "0"
    }
   }
  }
 }
}


If anyone knows of a better way of doing this, do share
Razz


EDIT: Fixed Smile
_________________
ComputerTech


Last edited by ComputerTech on Fri Feb 19, 2021 3:50 pm; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 691
Location: France

PostPosted: Thu Feb 18, 2021 6:37 pm    Post subject: Reply with quote

That's the way I would do it.

Just think about two detals:
- set the warn variable global (or use ::warn)
- check if warn($host) exists before increment it (positive or negative)
_________________
https://www.eggdrop.fr - French speaking IRC network
Offer me a coffee
Back to top
View user's profile Send private message Visit poster's website
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 250

PostPosted: Fri Feb 19, 2021 3:21 pm    Post subject: Reply with quote

Ok cheers CrazyCat, will do that right away Smile
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
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