egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Channel cycle with delay (.cycle #channel 5)

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
ndrp
Voice


Joined: 06 Jun 2013
Posts: 9

PostPosted: Thu Jun 06, 2013 5:58 am    Post subject: Channel cycle with delay (.cycle #channel 5) Reply with quote

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
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Fri Jun 07, 2013 7:55 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Fri Jun 07, 2013 11:10 am    Post subject: Reply with quote

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
View user's profile Send private message
ndrp
Voice


Joined: 06 Jun 2013
Posts: 9

PostPosted: Fri Jun 07, 2013 6:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Sat Jun 08, 2013 7:27 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber