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 

auto +i

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


Joined: 16 Nov 2005
Posts: 71

PostPosted: Tue Dec 29, 2009 10:50 am    Post subject: auto +i Reply with quote

can someome make a script that will put a especific channel +i during a especific hour of the day, for example lock the channel all day except from 20:00 to 00:00


ty in advance
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Wed Dec 30, 2009 7:42 pm    Post subject: Reply with quote

Code:
bind time - * lock:chan

proc lock:chan {min hour args} {
 if {![botisop #channel]} return
 set hr [scan $hour %d]
 if {$hr >= 20 && $hr <= 23} {
  if {[string match "*i*" [getchanmode #channel]]} {
   pushmode #channel -i
  }
 } elseif {![string match "*i*" [getchanmode #channel]]} {
  pushmode #channel +i
 }
}


Edit1: Replace #channel with your channel's name.

Edit2: It seems someone modified my post (moderators? Exclamation uncool); fixed it.

Edit3: Updated the code to avoid +/-i spamming.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts


Last edited by Sir_Fz on Tue Jan 12, 2010 6:15 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
.pt
Halfop


Joined: 16 Nov 2005
Posts: 71

PostPosted: Sat Jan 09, 2010 5:11 pm    Post subject: Reply with quote

ty u, but it keeps spamming +i and -i during that time, i tried to fix it but with no luck
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sat Jan 09, 2010 5:37 pm    Post subject: Reply with quote

Sir_Fz's code above slightly altered can do this. Also made it easier for you to set the channel and durations.
Code:
# channel
variable lockchan "#mychannel"
# durations
variable lockstart 20
variable lockend 23

# changed the time bind to do this _AT_ the start
# of every hour, since we base this on hours, and
# not to run the proc every minute needlessly
# checking when to change modes...
bind time - "00 *" lock:chan

proc lock:chan {min hour args} {
   global lockchan
   if {![botisop $lockchan]} return
   set hr [scan $hour %d]
   # stole this from nml375  this allows wrapping of start/end hours.
   if {($hour >= $::lockstart && $hour < $::lockend || \
      ($hour >= $::lockstart || $hour < $::lockend) && \
      $::lockstart > $::lockend) && [string match "*i*" [getchanmode #channel]]} {
      channel set $lockchan chanmode -i
   } else {
      channel set $lockchan chanmode +i
   }
}

You simply channel set (chanset) the #channel's chanmode settings to keep this from happening. This also keeps other ops from changing this schedule making the bot enforce these modes during these time periods.
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Jan 12, 2010 6:06 pm    Post subject: Reply with quote

The main logic problem, is that you test if the time is within the desired range (correct) and if mode i is set (incorrect).

If i is not set, the logics will always evaluate to false, and the channel will be set +i. As such, you'll still end up adding and removing the i mode every other minute.

Solution would be to nest the mode check, rather than AND it to the time-check:
Code:
if {validtime} {
  if {channel-is+i} {
    pushmode #channel -i
  }
} else {
  if {!channel-is+i} {
    pushmode #channel +i
  }
}

Sorry for the psuedo-code, just got home from a long drive and can't be arsed to write too much code at once :p
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue Jan 12, 2010 6:17 pm    Post subject: Reply with quote

Yes indeed, my bad Embarassed Updated my post above.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
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