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.

Channel cycle with delay (.cycle #channel 5)

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
n
ndrp
Voice
Posts: 9
Joined: Thu Jun 06, 2013 5:39 am

Channel cycle with delay (.cycle #channel 5)

Post by ndrp »

Hi

I would like to request a new script. Script would make eggdop cycle given channel with time delay.

For example command ".cycle #channel 5" would work like this:

1) bot leaves #channel (.chanset #channel +inactive)
2) bot waits 5 minutus
3) bot joins #channel (.chanset #channel -inactive)

Time format could be minutes, hours or days. For me minutes is enough but some other eggdeop users need longer delays.
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

Hope this will help you for now. It only works as you want but in minutes. I dont have time to make the hour/day for now because i dont have time. But i will be back and make it if noone else will make this script.

Code: Select all

bind PUB n|n !cycle cycle:pub

proc cycle:pub {nick uhost hand chan arg} {

        set target [lindex [split $arg] 0]
        set duration [lindex [split $arg] 1]

        if {$target == ""} { putserv "PRIVMSG $chan :\002$nick\002 - You didnt set the channel name"; return }
        if {[validchan $target]} {
                if {$duration != ""} {
                        putserv "PART $target :i will be back in $duration minutes ;"

                        channel set $target +inactive

                        timer $duration [list channel set $target -inactive]

                        putserv "PRIVMSG $chan :\002$nick\002 - CYCLE for $target complete (ill be back in $duration min)"
                } else {
                        putserv "PRIVMSG $chan :\002$nick\002 - You didnt set the duration (EX: !cycle #channel 5)"
                }
        } else {
                putserv "PRIVMSG $chan :\002$nick\002 - '$target' is not a valid channel"
        }
}
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

In order to get a time format in minutes, hours or days the user would need to add some kind of separator in order to figure out the format is used. The easiest way would be by formatting the duration like 5m for 5 minutes, 2h for two hours and 3d for 3 days for instance.

Just right off the bat I would set a user defined integer flag where would store the time the +inactive would expire (for instance when the command was issued in unix time to that would add the actual duration) combined with either a cron/time bind triggered every 1 second and check for this user defined flag and remove it where is due, or make a cron/time bind exactly on that time and then after it was triggered remove it.

Here's a start that needs just the last part. I'm a bit busy with work and can't test or do continue right now.

Code: Select all

bind pub n|n .cycle pub:cycle

proc pub:cycle {nick uhost hand chan text} {
	if {[scan $text {%s%s} channel duration] != 2} {
		puthelp "NOTICE $nick :Usage: \002.cycle #channel duration\002."
		return
	}
	
	if {![regexp {^[0-9]+[mhd]$} $duration]} {
		puthelp "NOTICE $nick :The duration must be expressed in minutes, hours or days. For example: .cycle #channel 5m, .cycle #channel 1h or .cycle #channel 2d"
		return
	}
	
	if {![validchan $channel]} {
		puthelp "NOTICE $nick :The channel $channel is not a valid."
		return
	}
	
	if {[channel get $chan inactive]} {
		puthelp "NOTICE $nick :The channel $channel is already set to inactive."
		return
	}

	channel set $channel +inactive
	
	# minutes
	if {[regexp {^[0-9]+[m]$} $duration]} {
		
	# hours
	} elseif {[regexp {^[0-9]+[h]$} $duration]} {
	
	# days
	} elseif {[regexp {^[0-9]+[d]$} $duration]} {
	
	}
}
Once the game is over, the king and the pawn go back in the same box.
n
ndrp
Voice
Posts: 9
Joined: Thu Jun 06, 2013 5:39 am

Post by ndrp »

Thanks! I already tested Madalins code. It worked.

Time format like 5m, 2h, 3d sounds good. I think the default should be minutes so !cycle #channel 5 is interpreted as minutes.
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

I modifyed caesar version to what you wanted as his version had what mine didnt so now it will work with minute/hours/days and if you add only lets say '5' it will be considered minutes.

Code: Select all

bind pub n|n .cycle pub:cycle

proc pub:cycle {nick uhost hand chan text} {
	if {[scan $text {%s%s} channel duration] != 2} {
		puthelp "NOTICE $nick :Usage: \002.cycle #channel duration\002."
		return
	}

	if {![regexp {^[0-9]+[mhd]$} $duration]} {
		puthelp "NOTICE $nick :The duration must be expressed in minutes, hours or days. For example: .cycle #channel 5m, .cycle #channel 1h or .cycle #channel 2d"
		return
	}

	if {![validchan $channel]} {
		puthelp "NOTICE $nick :The channel $channel is not a valid."
		return
	}

	if {[channel get $chan inactive]} {
		puthelp "NOTICE $nick :The channel $channel is already set to inactive."
		return
	}

	channel set $channel +inactive

	# minutes
	if {[regexp {^[0-9]+[m]$} $duration]} {
		timer [string index $duration 0] [list channel set $channel -inactive]

		putserv "PRIVMSG $chan :\002$nick\002 - I will comeback on \00304$channel\003 in $duration"
		# hours
	} elseif {[regexp {^[0-9]+[h]$} $duration]} {
		timer [expr [string index $duration 0] * 60] [list channel set $channel -inactive]

		putserv "PRIVMSG $chan :\002$nick\002 - I will comeback on \00304$channel\003 in $duration"
		# days
	} elseif {[regexp {^[0-9]+[d]$} $duration]} {
		timer [expr [string index 0 $duration] * 24 * 60] [list channel set $channel -inactive]

		putserv "PRIVMSG $chan :\002$nick\002 - I will comeback on \00304$channel\003 in $duration"
	} else {
		timer [string index $duration 0] [list channel set $channel -inactive]

		putserv "PRIVMSG $chan :\002$nick\002 - I will comeback on \00304$channel\003 in $duration"
	}
}
Just test it and see if it works like you wanted.
Post Reply