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.

auto +i

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
.
.pt
Halfop
Posts: 71
Joined: Wed Nov 16, 2005 10:14 am

auto +i

Post by .pt »

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
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

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? :!: uncool); fixed it.

Edit3: Updated the code to avoid +/-i spamming.
Last edited by Sir_Fz on Tue Jan 12, 2010 6:15 pm, edited 1 time in total.
.
.pt
Halfop
Posts: 71
Joined: Wed Nov 16, 2005 10:14 am

Post by .pt »

ty u, but it keeps spamming +i and -i during that time, i tried to fix it but with no luck
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Sir_Fz's code above slightly altered can do this. Also made it easier for you to set the channel and durations.

Code: Select all

# 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.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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: Select all

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
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Yes indeed, my bad :oops: Updated my post above.
Post Reply