stop posts on chan.
#1
salut a tous..

hi .a friend of mine ask me for help for about a code what he uses on his eggdrop. he said he uses this code for triggering some help lines on channel.its a very simple code what he used. so he asked me that some help triggers are too long,and i want to cut that off with a "!stop" command and than bot should stop posting these help lines on channel.
(by the way those help lines not in a readable .txt file)

so i tried couple of things allnight long on this code.but i couldn't make it to stop the bot posting lines.here it is my edit of the code :
Code :
bind pub - !start foo_start
bind pub - !stop stop_foo

proc foo_start {nick uhost hand chan text} {
if {![isop $nick $chan]} {
  global foo_status
  set foo_status 1
  if {!$foo_status} break
utimer 15 [list puthelp "PRIVMSG $chan :message"]
utimer 25 [list puthelp "PRIVMSG $chan :message 1"]
utimer 35 [list puthelp "PRIVMSG $chan :message 2"]
utimer 45 [list puthelp "PRIVMSG $chan :message 3"]
}
}
proc stop_foo {nick uhost hand chan text} {
  global foo_status
  set foo_status 0
}
but as you can see ,its not working .so than i connect #egghelp channel for to get a suggestion how can i do that !stop thing*.
and speechless suggest me to edit like that,they said it should work like that.here is the second edition of this code:
Code :
bind pub - !start foo_start
bind pub - !stop stop_foo

proc foo_start {nick uhost hand chan text} {
    if {![isop $nick $chan]} {
        global foo_status
        if {![array exists foo_status]} {
            set foo_status(1) [utimer 15 [list puthelp "PRIVMSG $chan :message"]]
            set foo_status(2) [utimer 25 [list puthelp "PRIVMSG $chan :message 1"]]
            set foo_status(3) [utimer 35 [list puthelp "PRIVMSG $chan :message 2"]]
            set foo_status(4) [utimer 45 [list puthelp "PRIVMSG $chan :message 3"]]
        }
    }
}
proc stop_foo {nick uhost hand chan text} {
    global foo_status
    foreach timer [list 1 2 3 4] { killutimer $timer }
    array unset foo_status
}

but this edition is not working either...
and it has some terrible issues : like when it starts !stop not working and gave an error on partyline like : invalid timerID stop_foo..
and if when make it !stop you have to restart the bot after to try second time !start command..so its useless and not working for to stop posting lines.

so i would like to open a new thread in here for to ask your advices and suggestions for about this issue.

thanks in advance.
Répondre Avertir
#2
Well, your timers'ID aren't 1 to 4, you must store the [list [utimer ....]] in foo_status.

TCL
bind pub - !start foo_start
bind pub - !stop stop_foo
 
proc foo_start {nick uhost hand chan text} {
    if {![isop $nick $chan]} {
        global foo_status
        if {![array exists foo_status]} {
            set foo_status(1) [list [utimer 15 [list puthelp "PRIVMSG $chan :message"]]]
            set foo_status(2) [list [utimer 25 [list puthelp "PRIVMSG $chan :message 1"]]]
            set foo_status(3) [list [utimer 35 [list puthelp "PRIVMSG $chan :message 2"]]]
            set foo_status(4) [list [utimer 45 [list puthelp "PRIVMSG $chan :message 3"]]]
        }
    }
}
proc stop_foo {nick uhost hand chan text} {
    global foo_status
    foreach timer [list 1 2 3 4] { killutimer $foo_status[$timer] }
    array unset foo_status
}


Répondre
#3
hi CrazyCat thank you for your quick replySmile
i've also tried your edition but unfortunatly i got this on partyline
Code :
Tcl error [stop_foo]: can't read "foo_status": no such variable
[03:13:06] [egglib]: Catched BGError: can't read "foo_status": no such variable
[03:13:06] -----> can't read "foo_status": no such variable
[03:13:06] ----->     while executing
[03:13:06] -----> "killutimer $foo_status[$timer] "
[03:13:06] ----->     (procedure "stop_foo" line 3)
[03:13:06] ----->     invoked from within
[03:13:06] -----> "stop_foo $_pub1 $_pub2 $_pub3 $_pub4 $_pub5"
so i've tried to add this line under the global foo_status into stop_foo procedure
Code :
if {[array exists dur_status]} {
but this time i got nuthin...
no any error no any posts and no stop Razz
interesting....
[i don't know about if this could be the reason these errors but i've been trying these codes on eggdrop1.8 latest snapshot with tcl8.6b3]
thank you ...
Répondre Avertir
#4
re..
uhm sorry my bad i've tried to add a line like
Code :
    if {[array exists foo_status]} {
not dur_status ....

first i tried yours but i seen an error and i tried like this .
Code :
bind pub - !start foo_start
bind pub - !stop stop_foo
  
proc foo_start {nick uhost hand chan text} {
     if {![isop $nick $chan]} {
         global foo_status
         if {![array exists foo_status]} {
             set foo_status(1) [list [utimer 15 [list puthelp "PRIVMSG $chan :message"]]]
             set foo_status(2) [list [utimer 25 [list puthelp "PRIVMSG $chan :message 1"]]]
             set foo_status(3) [list [utimer 35 [list puthelp "PRIVMSG $chan :message 2"]]]
             set foo_status(4) [list [utimer 45 [list puthelp "PRIVMSG $chan :message 3"]]]
         }
     }
}
proc stop_foo {nick uhost hand chan text} {
     global foo_status
     if {[array exists foo_status]} {
      foreach timer [list 1 2 3 4] { killutimer $foo_status[$timer] }
     array unset foo_status
     }
}
Répondre Avertir
#5
Juste a small thing: don't use reserved keyword as variables.
So, avoid:
TCL
foreach timer [list 1 2 3 4] { killutimer $foo_status[$timer] }


Try :
TCL
foreach tId [list 1 2 3 4] { killutimer $foo_status[$tId] }


Répondre
#6
slt..hi.
first i've tried like this :
Code :
bind pub - !start foo_start
bind pub - !stop stop_foo
  
proc foo_start {nick uhost hand chan text} {
     if {![isop $nick $chan]} {
         global foo_status
         if {![array exists foo_status]} {
             set foo_status(1) [list [utimer 1 [list puthelp "PRIVMSG $chan :message"]]]
             set foo_status(2) [list [utimer 3 [list puthelp "PRIVMSG $chan :message 1"]]]
             set foo_status(3) [list [utimer 5 [list puthelp "PRIVMSG $chan :message 2"]]]
             set foo_status(4) [list [utimer 7 [list puthelp "PRIVMSG $chan :message 3"]]]
         }
     }
}
proc stop_foo {nick uhost hand chan text} {
     global foo_status
     if {[array exists foo_status]} {
      foreach tId [list 1 2 3 4] { killutimer $foo_status[$tId] }
     array unset foo_status
     }
}
than i tried to add another line like:
Code :
bind pub - !start foo_start
bind pub - !stop stop_foo

proc foo_start {nick uhost hand chan text} {
    if {![isop $nick $chan]} {
        global foo_status
        if {![array exists foo_status]} {
            set foo_status(1) [list [utimer 1 [list puthelp "PRIVMSG $chan :message"]]]
            set foo_status(2) [list [utimer 3 [list puthelp "PRIVMSG $chan :message 1"]]]
            set foo_status(3) [list [utimer 5 [list puthelp "PRIVMSG $chan :message 2"]]]
            set foo_status(4) [list [utimer 7 [list puthelp "PRIVMSG $chan :message 3"]]]
            set foo_status(5) [utimer 8 [list array unset ::foo_status]]
        }
    }
}
proc stop_foo {nick uhost hand chan text} {
    global foo_status
    if {[array exists foo_status]} {
        foreach tld [list 1 2 3 4 5] { killutimer $foo_status($tld) }
        array unset foo_status
    }
}
but still nuthin. no any error within !start or !stop cmds.and no any action with'em on channel...

i guess i'm gonna give up ...

i wanna thank you for your patience and for your advance.
i realy appreciated for your help thanks anyway CrazyCat ^^
Répondre Avertir
#7
I'll do some tries today, and I'll try to give you a working solution.
Répondre
#8
Just a random thought there, but shouldn't it be [isop] rather than ![isop] o_o ?

Anyway - if i understood correctly what you want is simply a custom output queue ?
Here's a somewhat different approach than CC's. I tested it quickly with a bare tcl interp, it should work on eggdrops just as well :

Code :
set ::helpQueue {}
set ::helpQueueTimer {}
set ::helpQueueDelay 2500 ;# One message every 2500 ms

# Reset queue status
proc clearHelpQueue {args} {
    set ::helpQueue {}
    set ::helpQueueTimer [after cancel $::helpQueueTimer] }

proc processHelpQueue {args} {
    if {![llength $::helpQueue]} { return [clearHelpQueue] }
    # Pop first element from list and send it to server
    putquick [lindex $::helpQueue 0]
    if {[llength [set ::helpQueue [lrange $::helpQueue 1 end]]]} {
    # Init timer for next iteration if there's more to send, otherwise stop
        set ::helpQueueTimer [after $::helpQueueDelay ::processHelpQueue]
    } else { set ::helpQueueTimer {} }
}

proc pushHelpQueue {request} {
    # Push the message to the queue
    lappend ::helpQueue $request
    # Start it if not running
    if {$::helpQueueTimer == ""} { set ::helpQueueTimer [after $::helpQueueDelay ::processHelpQueue] }
}

You can bind !stop directly to clearHelpQueue, and then just use pushHelpQueue instead of puthelp/putquick in the script.
Répondre Avertir


Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)
Tchat 100% gratuit -Discutez en toute liberté