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.

topic change ban

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
s
samhain
Halfop
Posts: 77
Joined: Wed Jan 03, 2007 5:19 am

topic change ban

Post by samhain »

* Inertia changes topic to 'ANUS RECTUM ANUS RECTUM ANUssss RECTUM ANUS RECTUMANUS RECTUM AHAHAHAHAHAHHA ANUS RECTUM AHAHA
A guy usually floods our channel with that kind of stuff, Because usually our channel is -t, so normal users can change topics, I need a script which has a list of words, so if a user changes a topic that includes one of those words, the guy should be banned from the channel by the eggie, thanks
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

try this script, it has couple of years... it should work...

Code: Select all

# Author: tomekk
# e-mail:  tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

# if you want to use this script on your chan, type in eggdrop console (via telnet or DCC chat)
# .chanset #channel_name +tb
# and later .save

# kick message
set kick_msg "bye bye"

# bad words (case insensitive, line-by-line)
set bad_topic_words {
	*anus*
	*something*
	*word1*
	*word2*
}

# ban type 
# 1)  *!*@*.domain.com 
# 2)  *!*@some.domain.com 
# 3)  *nick*!*@some.domain.com 
# 4)  *!*ident*@some.domain.com
set ban_type 1

######################################################
bind topc -|- "*" topc_proc 

setudef flag tb

proc topc_proc { nick uhost handle chan topic } {
	global bad_topic_words kick_msg botnick

	if {![channel get $chan tb]} {
		return
	}  

	set kick_fag 0                                                                                          

	foreach b_word [split $bad_topic_words "\n"] {
		if {[string match -nocase [join $b_word] $topic]} {                                          
			set kick_fag 1
			break
		}
	}

	if {$kick_fag == 1} {                                                                         
		if {$botnick != $nick} {
			putquick "MODE $chan +b [banmask $uhost $nick]"
			putkick $chan $nick $kick_msg
		}
	}
}

proc banmask { host nick } {
	global ban_type

	switch -- $ban_type {
		1 {
			set mask "*!*@[lindex [split [maskhost $host] "@"] 1]"
		}

		2 {
			set mask "*!*@[lindex [split $host @] 1]"
		}

		3 {
			set mask "*$nick*!*@[lindex [split $host "@"] 1]"
		}

		4 {
			set mask "*!*[lindex [split $host "@"] 0]*@[lindex [split $host "@"] 1]"
		}
		return $mask
	}
}

putlog "topic-ban.tcl ver 0.1 by tomekk loaded"
s
samhain
Halfop
Posts: 77
Joined: Wed Jan 03, 2007 5:19 am

Post by samhain »

* gasgas changes topic to ' anus rectum'
* BallotBox sets mode: +b *!*@182.177.61.*
* gasgas was kicked by BallotBox (Trolling with the channel topic Badword in topic detected.)
<+Hawk-> good
* Retrieving #AmericaPolitics modes...
* sheperd changes topic to ' Ron Paul / Michelle Bachmann 2012 '
* Hawk- changes topic to 'Today is the anniversary of the ratification of the US Constitution on June 21, 1788'
* ezwinner changes topic to ''
* BallotBox sets mode: -b+b *!*@Cunty.users.undernet.org *!*@*.undernet.org
* WebGuy sets mode: -b *!*@*.undernet.org
* ezwinner was kicked by BallotBox (Trolling with the channel topic Badword in topic detected.)
* BallotBox sets mode: +b *!*@Cunty.users.undernet.org

The script banned ezwinner for doing nothing.....
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

fixed...

Code: Select all

# Author: tomekk
# e-mail:  tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

# if you want to use this script on your chan, type in eggdrop console (via telnet or DCC chat)
# .chanset #channel_name +tb
# and later .save

# kick message
set kick_msg "bye bye"

# bad words (case insensitive)
set bad_topic_words {
	*anus*
	*something*
	*word1*
	*word2*
}

# ban type 
# 1)  *!*@*.domain.com 
# 2)  *!*@some.domain.com 
# 3)  *nick*!*@some.domain.com 
# 4)  *!*ident*@some.domain.com
set ban_type 1

######################################################
bind topc -|- "*" topc_proc 

setudef flag tb

proc topc_proc { nick uhost handle chan topic } {
	global bad_topic_words kick_msg botnick

	if {![channel get $chan tb]} {
		return
	}  


	if {[string trim $topic] != "" } {
		set kick_fag 0                                                                                          

		foreach b_word [split $bad_topic_words "\n"] {
			if {[string match -nocase [join $b_word] $topic]} {                                          
				set kick_fag 1
				break
			}
		}
	
		if {$kick_fag == 1} {                                                                         
			if {$botnick != $nick} {
				putquick "MODE $chan +b [banmask $uhost $nick]"
				putkick $chan $nick $kick_msg
			}
		}
	}
}

proc banmask { host nick } {
	global ban_type

	switch -- $ban_type {
		1 {
			set mask "*!*@[lindex [split [maskhost $host] "@"] 1]"
		}

		2 {
			set mask "*!*@[lindex [split $host @] 1]"
		}

		3 {
			set mask "*$nick*!*@[lindex [split $host "@"] 1]"
		}

		4 {
			set mask "*!*[lindex [split $host "@"] 0]*@[lindex [split $host "@"] 1]"
		}
		return $mask
	}
}

putlog "topic-ban.tcl ver 0.1 by tomekk loaded"
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

you should replace

Code: Select all

if {$botnick != $nick} { 
with

Code: Select all

if {[isbotnick $nick]} return
and move it after

Code: Select all

if {![channel get $chan tb]} {
Once the game is over, the king and the pawn go back in the same box.
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

You're right, moving botnick check before foreach could save some IO operations when this situation occurs (but I don't think so this ever will happen...)

'global botnick' is kinda oldschool but is proper
s
samhain
Halfop
Posts: 77
Joined: Wed Jan 03, 2007 5:19 am

Post by samhain »

The script works perfect, tommek, One more little tweak to do, I want that after the bot bans the user, The bot should change the topic to some text.
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

try it:

Code: Select all

# Author: tomekk
# e-mail:  tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

# if you want to use this script on your chan, type in eggdrop console (via telnet or DCC chat)
# .chanset #channel_name +tb
# and later .save

# kick message
set kick_msg "bye bye"

# bad words (case insensitive)
set bad_topic_words {
	*anus*
	*something*
	*word1*
	*word2*
}

# topics
set topics {
	"#chan1\ntopic for channel #chan1"
	"#chan2\ntopic for channel #chan2"
}

# ban type 
# 1)  *!*@*.domain.com 
# 2)  *!*@some.domain.com 
# 3)  *nick*!*@some.domain.com 
# 4)  *!*ident*@some.domain.com
set ban_type 1

######################################################
bind topc -|- "*" topc_proc 

setudef flag tb

proc topc_proc { nick uhost handle chan topic } {
	global bad_topic_words kick_msg botnick topics

	if {![channel get $chan tb]} {
		return
	}  

	if {$botnick == $nick} {
		return
	}

	if {[string trim $topic] != "" } {
		set kick_fag 0                                                                                          

		foreach b_word [split $bad_topic_words "\n"] {
			if {[string match -nocase [join $b_word] $topic]} {                                    
				set kick_fag 1
				break
			}
		}
	
		if {$kick_fag == 1} {                                                                         
			putquick "MODE $chan +b [banmask $uhost $nick]"
			putkick $chan $nick $kick_msg

			foreach topic $topics {
				if {$topic != ""} {
					set topic_data [split $topic "\n"]
					set topic_chan [lindex $topic_data 0]
					set topic_topic [lindex $topic_data 1]
					
					if {$topic_chan == $chan} {
						putquick "TOPIC $chan :$topic_topic"
						break
					}
				}
			}
		}
	}
}

proc banmask { host nick } {
	global ban_type

	switch -- $ban_type {
		1 {
			set mask "*!*@[lindex [split [maskhost $host] "@"] 1]"
		}

		2 {
			set mask "*!*@[lindex [split $host @] 1]"
		}

		3 {
			set mask "*$nick*!*@[lindex [split $host "@"] 1]"
		}

		4 {
			set mask "*!*[lindex [split $host "@"] 0]*@[lindex [split $host "@"] 1]"
		}
		return $mask
	}
}

putlog "topic-ban.tcl ver 0.1 by tomekk loaded"
User avatar
hrz
Voice
Posts: 5
Joined: Tue Jun 21, 2011 4:47 pm
Location: Sweden
Contact:

Post by hrz »

I think this would be much simpler, basically:
.chanset #chan *word1*,*word2*,*some more words :D*
and
.chanset $chan This is what I want the topic to be if someone puts something nasty in my old topic
and
.chanset #chan tb-kickmsg I think you're mean for setting that topic, meanie!
and
.chanset #chan +tb

Code: Select all

setudef flag tb 
setudef str tb-words
setudef str tb-topic
setudef str tb-kickmsg

proc topc_proc {nick uhost handle chan topic} { 
    if {![channel get $chan tb] || [isbotnick $nick] || [string trim $topic] == "" } {
        return
    }
    foreach word [split [channel get $chan tb-words] ,] { 
        if {[string match -nocase [join $b_word] $topic]} {set match 1} 
    }
    if {[info exists $match]} {
        set banmask [maskhost $nick!$uhost [channel get $chan ban-type]]
        newchanban $chan $banmask TOPICBAN [channel get $chan tp-kickmsg] [channel get $chan ban-time]
        pushmode $target_chan "+b" $banmask
        flushmode $chan
        putkick $chan $nick [channel get $chan tp-kickmsg]
    }
}
bind topc -|- "*" topc_proc
putlog "Topic badword banner thingy hack"
Post Reply