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.

msg

Help for those learning Tcl or writing their own scripts.
p
pilouuu
Halfop
Posts: 82
Joined: Mon Dec 26, 2005 8:03 pm

msg

Post by pilouuu »

Code: Select all

set idx -1 
set chans {#chan #chan2} 
set msgs {"msg chan 1" msg chan 2"} 
bind time - * fouu 
proc fouu {m args} { 
   if {$m!="08" && $m!="09" && $m%20==0} { 
      foreach c $::chans { 
         puthelp "privmsg $c :[lindex $::msgs [incr ::idx]]" 
      } 
   } 
}

code by daemon

my question is the tcl say msg chan1 and chan 2 after reboot. it oK. Is possible to say msg all them 20 mns?

thx
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

I'm not sure if I understood you correctly, but do you mean you want it to work every 20 minutes? if so then just remove

Code: Select all

$m!="08" && $m!="09" && 
p
pilouuu
Halfop
Posts: 82
Joined: Mon Dec 26, 2005 8:03 pm

Post by pilouuu »

yes 20 mns say msg 20mns after etc etc. =]
$m!="08" && $m!="09" && *remove*
Tcl error [fouu]: can't use invalid octal number as operand of "%"

Code: Select all

proc fouu {m args} { 
   if {$m%20==0} { 
      foreach c $::chans { 
         puthelp "privmsg $c :[lindex $::msgs [incr ::idx]]"
Thx sir_Fz
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

I've seen this error before but didn't figure out why exactly it occurs (maybe a bug in Tcl), I think it occurs (sometimes) only when m is "0?" so try:

Code: Select all

if {[string trimleft $m 0]%20 == 0} {
p
pilouuu
Halfop
Posts: 82
Joined: Mon Dec 26, 2005 8:03 pm

Post by pilouuu »

[01:00] Tcl error [fouu]: can't use empty string as operand of "%"

:( always
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Not always, but every hour (when $m is 00). Use this:

Code: Select all

if {[regexp {00|20|40} $m]} {
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

Sir_Fz wrote:I've seen this error before but didn't figure out why exactly it occurs (maybe a bug in Tcl)
no, it's not a bug

a number starting with 0 is considered octal (base eight) in Tcl, as in many other languages (most important being of course C/C++); so you don't have 8 in the octal system, eight becomes 10

so 08 or 09, passed as argument to [bind time] handler isn't valid number and can't be part of numerical expression, hence that error
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
p
pilouuu
Halfop
Posts: 82
Joined: Mon Dec 26, 2005 8:03 pm

Post by pilouuu »

hi

not error detected but that does not go.
the bot one said the sentence right once but it repeat not


thank you very much of your assistance
p
pilouuu
Halfop
Posts: 82
Joined: Mon Dec 26, 2005 8:03 pm

Post by pilouuu »

No solution? :(
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

The solution I gave you works just fine. It will msg every 20 minutes (for example at 4:00 4:20 4:40 5:00 5:20...etc)
p
pilouuu
Halfop
Posts: 82
Joined: Mon Dec 26, 2005 8:03 pm

Post by pilouuu »

Code: Select all

if {[regexp {4:20|4:40|5:00} $m]} {

etc etc?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

No

Code: Select all

if {[regexp {00|20|40} $m]} {
p
pilouuu
Halfop
Posts: 82
Joined: Mon Dec 26, 2005 8:03 pm

Post by pilouuu »

the procedure is not good the bot say only 1. no repat msg :(
p
pilouuu
Halfop
Posts: 82
Joined: Mon Dec 26, 2005 8:03 pm

Post by pilouuu »

it east can be possible with a timer?
expl:

Code: Select all

bind time - "20 * * * *" drtime
proc drtime { min hour day month year } {
thx
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

set idx -1
set chans {#chan #chan2}
set msgs {"msg chan 1" msg chan 2"} 
bind time - * fouu
proc fouu {m args} {
   if {[regexp {00|20|40} $m]} {
      foreach c $::chans {
         puthelp "privmsg $c :[lindex $::msgs [incr ::idx]]"
      }
   }
}
works perfectly.
Post Reply