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 script

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
D
DaRkOoO
Halfop
Posts: 67
Joined: Sat Sep 27, 2008 7:27 am

topic script

Post by DaRkOoO »

Hello everyone..

I'm using this tcl for topic:

Code: Select all

bind pub - !topic holm-pub_topic
proc holm-pub_topic {nick uhost handle channel text} {
global botnick voice_chan voice_flag
		if {[isvoice $nick $channel]} {
			if {$text == ""} {
				puthelp "NOTICE $nick :Usage: !topic <topic>"
			return 0
			}
			if {[isop $botnick $channel] == "0"} {
				puthelp "NOTICE $nick :Sorry, I'm not a op on $channel."
			return 0
			}
			if {[isop $botnick $channel] == "1"} {
				putserv "TOPIC $channel :$nick: $text"
				putlog "#$nick# !topic $text"
			}
		}
	}
Now,I need : If someone try to use !topic with word channel or http or www or #,bot should ban him(and don't set that one topic ofc)

Regards,
Darko.
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

I haven't tested it but should be OK. Give it a try please

Code: Select all

set vHolmBanTime 10

set vHolmBadTopic {
    "html"
    "#"
    "www"
    "channel"
}

bind PUB - !topic pHolmTopic

proc pHolmTopic {nick uhost hand channel txt} {
    global botnick vHolmBadTopic vHolmBanTime
    if {([isvoice $nick $channel]) || ([isop $nick $channel])} {
        set topic [string trim $txt]
        if {[llength [split $topic]]] != 0} {
            if {[botisop $channel]} {
                foreach word $vHolmBadTopic {
                    if {[string match -nocase "*$word*" $topic]} {
                        newchanban $channel $nick!*@* $botnick "bad topic *$word*" $vHolmBanTime
                        return 0
                    }
                }
                putserv "TOPIC $channel :$nick \:$topic"
                putlog "#$nick# !topic $topic"
            } else {puthelp "NOTICE $nick :-error- Bot needs to be an op on $channel to change the topic"}
        } else {puthelp "NOTICE $nick :-error- Correct syntax is !topic <topic>"}
    } else {puthelp "NOTICE $nick :-error- Only channel voices or above are allowed to change the topic"}
    return 0
}
I must have had nothing to do
D
DaRkOoO
Halfop
Posts: 67
Joined: Sat Sep 27, 2008 7:27 am

Post by DaRkOoO »

Works,just this line

Code: Select all

if {[llength [split $topic]]] != 0} {
should be

Code: Select all

if {[llength [split $topic]] != 0} {
And now I need to be able to specify it just for one,or two channels,and to make bot dont kick/ban his owner[s].. :)))
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

Please excuse the extra close bracket in my earlier code. My editor should have picked up on that.

Now will work only in channels with the special flag set in the bot's partyline as follows :-

.chanset #channelname +topic

Now will exempt users with whatever global bot flag is set in the configuration section

Code: Select all

# *** Configuration *** #

# duration of bans in minutes
set vHolmBanTime 10

# global bot flag to exempt from bad topic ban
# o = global operator
# m = global master
# n = global owner
set vHolmExemptFlag n

# list of bad topic words/phrases
set vHolmBadTopic {
    "html"
    "#"
    "www"
    "channel"
}

# *** Code *** #

setudef flag topic

bind PUB - !topic pHolmTopic

proc pHolmTopic {nick uhost handle channel txt} {
    global botnick vHolmBadTopic vHolmBanTime vHolmExemptFlag
    if {[channel get $channel topic]} {
        if {([isvoice $nick $channel]) || ([isop $nick $channel])} {
            set topic [string trim $txt]
            if {[llength [split $topic]] != 0} {
                if {[botisop $channel]} {
                    if {![matchattr $handle $vHolmExemptFlag]} {
                        foreach word $vHolmBadTopic {
                            if {[string match *$word* $txt]} {
                                newchanban $channel $nick!*@* $botnick "bad topic *$word*" $vHolmBanTime
                                return 0
                            }
                        }
                    }
                    putserv "TOPIC $channel :$nick \:$topic"
                    putlog "#$nick# !topic $topic"
                } else {puthelp "NOTICE $nick :-error- I need to be an op on $channel to change the topic"}
            } else {puthelp "NOTICE $nick :-error- Correct syntax is !topic <topic>"}
        } else {puthelp "NOTICE $nick :-error- Only channel voices or above are allowed to change the topic"}
    }
    return 0
}
I'm sure stuff like this has been written before in the vast Tcl archive on this site. I sort of feel I'm reinventing the wheel.
I must have had nothing to do
D
DaRkOoO
Halfop
Posts: 67
Joined: Sat Sep 27, 2008 7:27 am

Post by DaRkOoO »

Works fine,thanks ;)
Post Reply