| View previous topic :: View next topic |
| Author |
Message |
.pt Halfop
Joined: 16 Nov 2005 Posts: 71
|
Posted: Tue Dec 29, 2009 10:50 am Post subject: auto +i |
|
|
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 |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Wed Dec 30, 2009 7:42 pm Post subject: |
|
|
| 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? 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 |
|
 |
.pt Halfop
Joined: 16 Nov 2005 Posts: 71
|
Posted: Sat Jan 09, 2010 5:11 pm Post subject: |
|
|
| ty u, but it keeps spamming +i and -i during that time, i tried to fix it but with no luck |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sat Jan 09, 2010 5:37 pm Post subject: |
|
|
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 |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Jan 12, 2010 6:06 pm Post subject: |
|
|
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 |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
|
| Back to top |
|
 |
|