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 voice between 11pm and 8am

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

nml375 wrote:speechles,
I did not make any comments as to your flood protection, neither anyone else's. You might also like to keep in mind that the original request did not come with flood protection, neither did the initial code example by the requester have one.

That, however, does not change the case that you've attached my signature to code I've not written, and which is non-functional. At best, I consider that slander.
Which part isn't functional, and notice after your nick says minor tweaks.. why are you so offended that your participation in a script has been noted in some regard, do you wish that removed, just say so? maybe you already have in this case just say so without being sarcastic about it or just "mod edit" it out. You do have this power. I remember the incident when you attained it precisely.
nml375 wrote:On a side note, you could improve performance in your script by using the lappend command rather than resetting the variable with a concat'd value...
Lappand won't behave the same when using the foreach constructed below. I wanted a single inline list. Not a series of lists within lists. With those I would need to run a series of sets with lindexes on them to get the contents of each element. With an inline list, which concat gives back, is the only way the foreach constructed on the timer:onjoin can work. This is done to keep the code short and remove all those sets and lindexes otherwise required.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

speechles,
lappend will work just fine, if you know how to use it.. Such as below:

Code: Select all

lappend ::voicelist $nick $uhost $handle $channel
This is the recommended way of doing it, as it yields significant performance boost with large lists (see the lappend manpage for further details).
NML_375
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

speechles,
The code I proposed is this:

Code: Select all

if {$hour >= $start && $hour < $end || ($hour >= $start || $hour < $end) && $start > $end} {
That's not even remotely close to the code you pinned my signature.. "minor tweak" does not cut it. What you wrote in your script is not my code, as such - do not attribute it to me, correct or faulty.

Your code does not work, as it makes the assumption $vStartHour is always less than $vEndHour. This is not the case in the original request.
NML_375
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

nml375 wrote:speechles,
lappend will work just fine, if you know how to use it.. Such as below:

Code: Select all

lappend ::voicelist $nick $uhost $handle $channel
This is the recommended way of doing it, as it yields significant performance boost with large lists (see the lappend manpage for further details).
Corrected the prior script to properly use lappend. For some reason every time I've tried to use it this way it has failed me but might be because I've always tried it using [list $elements $go $here] rather than just list the elements singularly after the lappend.

Also, corrected the code advice you gave and incorporated it into the script along with mention to you. If this is done poorly shout it out. If you'd rather not participate then I'll change the "maybe this is" back into a "this is not".. haw ;)
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

For additional flexibility, I was trying to allow use of a secondary GMT offset in case a time zone was required within an IRC community that was not the same as the bot's GMT offset time.

Using nml375's hour checking statement, I think the following is now the correct logic.

Code: Select all

set vStartHour 23
set vEndHour 8
set vGmtOffset +1
set vVoiceDelay 10

bind JOIN - * pTimedVoiceJoin

proc pTimedVoiceJoin {nick uhost hand chan} {
    global vGmtOffset vStartHour vEndHour vVoiceDelay
    set hour [clock format [expr {[clock seconds] + ($vGmtOffset * 3600)}] -format %k -gmt 1]
    if {$hour >= $vStartHour && $hour < $vEndHour || ($hour >= $vStartHour || $hour < $vEndHour) && $vStartHour > $vEndHour} {
        utimer $vVoiceDelay [list pTimedVoiceDelay $nick $chan]
    }
    return 0
}

proc pTimedVoiceDelay {nick chan} {
    if {[botisop $chan]} {
        if {[onchan $nick $chan]} {
            if {(![isop $nick $chan]) && (![isvoice $nick $chan])} {
                pushmode $chan +v $nick
                flushmode $chan
            }
        }
    }
    return 0
}

# eof
I must have had nothing to do
Post Reply