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.

SubChannel script doesn't work correctly all the time

Old posts that have not been replied to for several years.
Locked
s
superfly

SubChannel script doesn't work correctly all the time

Post by superfly »

9 times out of 10 the script works correctly [waits 60 seconds, then rescans to see if the user has joined the main channel]. Any advise on how to get this working completely?

Code: Select all

#############################
#  This is the main channel
#############################

set om_subc(main) "#xbox-help"

#############################
# This is the sub channel
#############################

set om_subc(sub) "#xbox-help2"

#############################
#  Warning time, in minutes
#############################

set om_subc(warntime) 1

#############################
# Warning Message
#############################

set om_subc(warnmsg) "You have $om_subc(warntime) minute to join $om_subc(main) or you will be banned"

#############################
# Kick Message
#############################

set om_subc(kickmsg) "You were banned from $om_subc(sub) because you have not joined $om_subc(main).  Please join $om_subc(main) to have the ban removed."

#############################
#  Unban message
#############################

set om_subc(unbannotice) "You have been unbanned from $om_subc(sub) , if you part $om_subc(main) you while in $om_subc(sub) you will be banned again."

#############################
# Set the ban type here:    #
# 1 - *!*@host.domain	    #
# 2 - *!user@host.domain    #
# 3 - nick!*@host.domain    #
# 4 - nick!user@host.domain #
# 5 - *!?user@*.host.domain #
#############################

set om_subc(bantype) "1"

###################################
# Enable use of bold in DCC chat? #
###################################

set om_subc(bold) 1

#########################################
# Prefix "SPLIT:" in DCC chat messages? #
#########################################

set om_subc(SUBCHAN:) 1


#############################
#  Code begin
#############################

if {![string match 1.6.* $version]} { putlog "\002SUBCHAN:\002 \002WARNING:\002 This script is intended to run on eggdrop 1.6.x or later." }
if {[info tclversion] < 8.2} { putlog "\002SUBCHAN:\002 \002WARNING:\002 This script is intended to run on Tcl Version 8.2 or later." }

bind join - "$om_subc(sub) *" subchan_checkjoin
bind join - "$om_subc(main) *" subchan_checkjoin
bind part - "$om_subc(main) *" subchan_checkpart

proc subchan_ncm {pattern string} { return [string match [string tolower $pattern] [string tolower $string]] }
proc subchan_dopre {} {
	global om_subc
	if {!$om_subc(SUBCHAN:)} { return "" }
	if {!$om_subc(bold)} { return "SUBCHAN: " }
	return "\002SUBCHAN:\002 "
}
proc subchan_maskban {nick uhost} {
	global om_subc
	switch -- $om_subc(bantype) {
		1 { set ban "*!*@[lindex [split $uhost @] 1]" }
		2 { set ban "*!$uhost" }
		3 { set ban "$nick!*@[lindex [split $uhost @] 1]" }
		4 { set ban "$nick!$uhost" }
		5 { set ban [maskhost $uhost] }
		default { set ban "*!*@[lindex [split $uhost @] 1]" }
	}
	return $ban }

proc subchan_checkjoin {nick uhost hand chan} {
	global om_subc
	if {![botisop $om_subc(sub)]} { return }
	set banmask [subchan_maskban $nick $uhost]
	if {[subchan_ncm $chan $om_subc(main)]} {
		if {![ischanban $banmask $om_subc(sub)]} { return }
		
		regsub -all -- "%mainchan" $om_subc(unbannotice) $om_subc(main) msg
		regsub -all -- "%subchan" $msg $om_subc(sub) msg
		pushmode $om_subc(sub) -b $banmask
		
		if {$msg != ""} { puthelp "NOTICE $nick :$msg" }
		return }

	if {[onchan $nick $om_subc(main)] || [matchattr $hand ov|ov $om_subc(main)] || [matchattr $hand ov|ov $om_subc(sub)] || [isvoice $nick $om_subc(main)] || [isop $nick $om_subc(main)]} { return }
				
	if {![onchan $nick $om_subc(main)]} {
	
		putserv "NOTICE $nick :$om_subc(warnmsg)" }
		
	timer $om_subc(warntime) [list subchan_setJoinban $nick $uhost]
}

proc subchan_checkpart {nick uhost hand chan text} {
	global om_subc
	set banmask [subchan_maskban $nick $uhost]
	
	if {![botisop $om_subc(sub)] || ![onchan $nick $om_subc(sub)] || [matchattr $hand vo|vo $om_subc(main)] || [matchattr $hand vo|vo $om_subc(sub)] || [isvoice $nick $om_subc(sub)] || [isop $nick $om_subc(sub)]} { return }
	
	if {[onchan $nick $om_subc(sub)] } {
	
		putserv "NOTICE $nick :$om_subc(warnmsg)" }
	
	timer $om_subc(warntime) [list subchan_setPartban $nick $uhost ]
}

proc subchan_setPartban {nick uhost} {
	global om_subc
	set banmask [subchan_maskban $nick $uhost]
	
	if {![botisop $om_subc(sub)] || ![onchan $nick $om_subc(sub)] || [isvoice $nick $om_subc(sub)] || [isop $nick $om_subc(sub)] || [onchan $nick $om_subc(main)] || [isvoice $nick $om_subc(main)] || [isop $nick $om_subc(main)]} { return }
			
	putserv "MODE $om_subc(sub) +b $banmask"
	putserv "KICK $om_subc(sub) $nick :$om_subc(kickmsg)"
}

proc subchan_setJoinban {nick uhost} {
	global om_subc
	set banmask [subchan_maskban $nick $uhost]
	
	if {![botisop $om_subc(sub)] || ![onchan $nick $om_subc(sub)] || [isvoice $nick $om_subc(sub)] || [isop $nick $om_subc(sub)] || [onchan $nick $om_subc(main)] || [isvoice $nick $om_subc(main)] || [isop $nick $om_subc(main)]} { return } 
	putserv "MODE $om_subc(sub) +b $banmask"
	putserv "KICK $om_subc(sub) $nick :$om_subc(kickmsg)"
}
	

	

putlog "\002SUBCHAN:\002 OMSubChannel.tcl 1.0 is loaded."


This is an edited version of DAWG tcl's subchan.tcl, hope it was ok to edit it :oops:

EDIT

Forgot to include the problem with it.

When someone joins the subchannel, it notices them that says they have 1 minute to join (based on warn time), but it will ban them after 3 seconds or so. It really isn't a big deal, because they can just join the main channel to have the ban removed, but it'd be nice to have it working correctly all the time.
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

That's because you use eggdrop's "timer" command. It is coded in a way that will give you a delay from 0 to 60 seconds (+ additional minutes) depending on when you start it (relative to the internal "one minute timer")

I suggest using "utimer".
s
superfly

thanks

Post by superfly »

thanks, that worked... i knew it was something stupid. This was my first attempt with tcl and I think it'll be my last :roll:
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

It's no tcl's fault! If eggdrop made you hate tcl, you should sue the eggheads ;P
Locked