| View previous topic :: View next topic |
| Author |
Message |
ndrp Voice
Joined: 06 Jun 2013 Posts: 9
|
Posted: Thu Jun 06, 2013 5:58 am Post subject: Channel cycle with delay (.cycle #channel 5) |
|
|
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. |
|
| Back to top |
|
 |
Madalin Master

Joined: 24 Jun 2005 Posts: 310 Location: Constanta, Romania
|
Posted: Fri Jun 07, 2013 7:55 am Post subject: |
|
|
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: | 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"
}
} |
_________________ https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Fri Jun 07, 2013 11:10 am Post subject: |
|
|
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: |
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. |
|
| Back to top |
|
 |
ndrp Voice
Joined: 06 Jun 2013 Posts: 9
|
Posted: Fri Jun 07, 2013 6:03 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Madalin Master

Joined: 24 Jun 2005 Posts: 310 Location: Constanta, Romania
|
Posted: Sat Jun 08, 2013 7:27 am Post subject: |
|
|
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: |
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. _________________ https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL |
|
| Back to top |
|
 |
|