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.

Message + timer

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
User avatar
Arkadietz
Halfop
Posts: 67
Joined: Fri Jul 14, 2006 11:43 am
Location: cat /dev/zero > /dev/null;

Message + timer

Post by Arkadietz »

Okay it's simple.

1. To has a list where i can put my messages
2. To has a settable timer ( where show the messages in the channel/s )
On a unix system everything is a file ; if something is not a file , it is a proccess.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Would that timer read one line from the file??

Maybe keep track of the last line read, and read the next line in the file?
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
Arkadietz
Halfop
Posts: 67
Joined: Fri Jul 14, 2006 11:43 am
Location: cat /dev/zero > /dev/null;

Post by Arkadietz »

i got some example script for this but is old.. and not work properly

http://paste.tclhelp.net/?id=bm3
On a unix system everything is a file ; if something is not a file , it is a proccess.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Try this:

Code: Select all

# The list of channel ads to run (set to {} to disable this script) #
set prnl(msgs) {

1st example ad.
2nd example ad.
Next ad.
Last ad.

}


# The channels to msg: #chan1 #chan2 #etc  (* = all channels) #
set prnl(chans) {*}


# The number of minutes between channel ads  (1 or more minutes) #
set prnl(minutes) 5


###### END OF SETTINGS ######


set prnl(tmls) [split [string trim $prnl(msgs)] "\n"]
set prnl(msgs) ""
foreach prnl(tmit) $prnl(tmls) {
  set prnl(tmit) [string trim $prnl(tmit)]
  if {$prnl(tmit) ne ""} {  lappend prnl(msgs) $prnl(tmit)  }
}
unset prnl(tmls) prnl(tmit)

if {$prnl(msgs) eq ""} {  return  }

if {$prnl(chans) eq "*" || $prnl(chans) eq ""} {  set prnl(chans) [channels]  }
if {![info exists prnl(next)]} {  set prnl(next) 0  }
if {![info exists prnl(timer)]} { set prnl(timer) [timer 2 [list prnl:rnext]] }


proc prnl:rnext {} {  global prnl
 if {$prnl(msgs) eq ""} {  return  }

 foreach ch $prnl(chans) {
  puthelp "PRIVMSG $ch :[lindex $prnl(msgs) $prnl(next)]"
 }

 incr prnl(next)
 if {$prnl(next)>=[llength $prnl(msgs)]} {  set prnl(next) 0  }
 set prnl(timer) [timer $prnl(minutes) [list prnl:rnext]]
}


putlog "Public Read Next Line v1.1 loaded."

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
Arkadietz
Halfop
Posts: 67
Joined: Fri Jul 14, 2006 11:43 am
Location: cat /dev/zero > /dev/null;

Post by Arkadietz »

could you add an option to post random quotes ( where can not repeat last 5 quotes at least )
On a unix system everything is a file ; if something is not a file , it is a proccess.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Now you have a choice of reading 'in order' or eggdrops somewhat less than 'random' :)

Code: Select all

# The list of channel ads to run (set to {} to disable this script) #
set prnl(msgs) {

1st example ad.
2nd example ad.
Next ad.
Last ad.

}


# The channels to msg: #chan1 #chan2 #etc  (* = all channels) #
set prnl(chans) {*}


# The number of minutes between channel ads  (1 or more minutes) #
set prnl(minutes) 5


# Read the lines in order or random  (1=inorder || 2=random) #
set prnl(order) 2


###### END OF SETTINGS ######


set prnl(tmls) [split [string trim $prnl(msgs)] "\n"]
set prnl(msgs) ""
foreach prnl(tmit) $prnl(tmls) {
  set prnl(tmit) [string trim $prnl(tmit)]
  if {$prnl(tmit) ne ""} {  lappend prnl(msgs) $prnl(tmit)  }
}
unset prnl(tmls) prnl(tmit)

if {$prnl(msgs) eq ""} {  return  }

if {$prnl(chans) eq "*" || $prnl(chans) eq ""} {  set prnl(chans) [channels]  }
if {![info exists prnl(next)]} {  set prnl(next) 0  }
if {![info exists prnl(timer)]} { set prnl(timer) [timer 2 [list prnl:rnext]] }


proc prnl:rnext {} {  global prnl
 if {$prnl(msgs) eq ""} {  return  }

 if {$prnl(order)=="2"} {  set prnl(next) [rand [llength $prnl(msgs)]]  }

 foreach ch $prnl(chans) {
  puthelp "PRIVMSG $ch :[lindex $prnl(msgs) $prnl(next)]"
 }

 incr prnl(next)
 if {$prnl(next)>=[llength $prnl(msgs)]} {  set prnl(next) 0  }
 set prnl(timer) [timer $prnl(minutes) [list prnl:rnext]]
}


putlog "Public Read Next Line v1.1 loaded."

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
Arkadietz
Halfop
Posts: 67
Joined: Fri Jul 14, 2006 11:43 am
Location: cat /dev/zero > /dev/null;

Post by Arkadietz »

could you add a second timer:

1. minimum time before post the quote
2. maximum time before post the quote

result:
get some random time between min and max time
On a unix system everything is a file ; if something is not a file , it is a proccess.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Public Read Next Line v1.2

Post by SpiKe^^ »

This should do it.

Code: Select all

# The list of channel ads to run (set to {} to disable this script) #
set prnl(msgs) {

1st example ad.
2nd example ad.
Next ad.
Last ad.

}


# The channels to msg: #chan1 #chan2 #etc  (* = all channels) #
set prnl(chans) {*}


# The number of minutes between channel ads  (1 or more minutes) #
set prnl(min-lo) 5


# The number of minutes between channel ads  (same or above min-lo) #
set prnl(min-hi) 10


# Read the lines in order or random  (1=inorder || 2=random) #
set prnl(order) 2


###### END OF SETTINGS ######


set prnl(tmls) [split [string trim $prnl(msgs)] "\n"]
set prnl(msgs) ""
foreach prnl(tmit) $prnl(tmls) {
  set prnl(tmit) [string trim $prnl(tmit)]
  if {$prnl(tmit) ne ""} {  lappend prnl(msgs) $prnl(tmit)  }
}
unset prnl(tmls) prnl(tmit)

if {$prnl(msgs) eq ""} {  return  }

if {$prnl(chans) eq "*" || $prnl(chans) eq ""} {  set prnl(chans) [channels]  }
if {![info exists prnl(next)]} {  set prnl(next) 0  }
if {![info exists prnl(timer)]} { set prnl(timer) [timer 2 [list prnl:rnext]] }

if {$prnl(min-hi)<$prnl(min-lo)} {  set prnl(min-hi) $prnl(min-lo)  }


proc prnl:rnext {} {  global prnl
 if {$prnl(msgs) eq ""} {  return  }

 if {$prnl(order)=="2"} {  set prnl(next) [rand [llength $prnl(msgs)]]  }

 foreach ch $prnl(chans) {
  puthelp "PRIVMSG $ch :[lindex $prnl(msgs) $prnl(next)]"
 }

 incr prnl(next)
 if {$prnl(next)>=[llength $prnl(msgs)]} {  set prnl(next) 0  }

 set randmin $prnl(min-lo)
 if {$prnl(min-hi)>$prnl(min-lo)} {
   incr randmin [rand [expr {$prnl(min-hi)-$prnl(min-lo)+1}]]
 }

 set prnl(timer) [timer $randmin [list prnl:rnext]]
}


putlog "Public Read Next Line v1.2 loaded."

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
Arkadietz
Halfop
Posts: 67
Joined: Fri Jul 14, 2006 11:43 am
Location: cat /dev/zero > /dev/null;

Post by Arkadietz »

okay, but can you keep both timers i mean to looks something like that:

1. timer to use static/dynamric
a. static - in the first post ( where always post a reply on same time )
b. dynamic - last post ( where use the values min and max )
2. possible bugs ( tested ):
no working properly if in the quotes has [,],(,),%,&,!, .
example:
Dr. Kucho! feat. Aris - Doing Better Without You (Original Mix).mp3
On a unix system everything is a file ; if something is not a file , it is a proccess.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

1. timer to use static/dynamric
To have the ads always on the same time interval, set min-lo & min-hi both to the same number of minutes.

no working properly if in the quotes has [,],(,),%,&,!, .
The issue there is with a few tcl special characters.
We can get around that by storing all our ad lines to a plain text file, and not in the script tcl file.
Make a ad-file.txt, and put it in the scripts dir with this new script...

Code: Select all

# set the route and file name of the channel ads file #
# make the ads file as a plain text document, 1 ad per file line #
set prnl(ad-file) "scripts/ad-file.txt"


# The channels to msg: #chan1 #chan2 #etc  (* = all channels) #
set prnl(chans) {*}


# The minimum number of minutes between channel ads  (1 or more minutes) #
set prnl(min-lo) 5


# The maximum number of minutes between channel ads  (same or above min-lo) #
set prnl(min-hi) 10


# Read the lines in order or random  (1=inorder || 2=random) #
set prnl(order) 2


###### END OF SETTINGS ######


set prnl(msgs) ""
if {![file exists $prnl(ad-file)]} {  return  }

set prnl(tm-open) [open $prnl(ad-file)]
while {![eof $prnl(tm-open)]} {
 set prnl(tm-line) [string trim [gets $prnl(tm-open)]]
 if {$prnl(tm-line) ne ""} {
   lappend prnl(msgs) $prnl(tm-line)
 }
}
close $prnl(tm-open)
unset prnl(tm-open) prnl(tm-line) prnl(ad-file)

if {$prnl(msgs) eq ""} {  return  }

if {$prnl(chans) eq "*" || $prnl(chans) eq ""} {  set prnl(chans) [channels]  }
if {![info exists prnl(next)]} {  set prnl(next) 0  }
if {![info exists prnl(timer)]} { set prnl(timer) [timer 2 [list prnl:rnext]] }

if {$prnl(min-hi)<$prnl(min-lo)} {  set prnl(min-hi) $prnl(min-lo)  }


proc prnl:rnext {} {  global prnl
 if {$prnl(msgs) eq ""} {  return  }

 if {$prnl(order)=="2"} {  set prnl(next) [rand [llength $prnl(msgs)]]  }

 foreach ch $prnl(chans) {
  puthelp "PRIVMSG $ch :[lindex $prnl(msgs) $prnl(next)]"
 }

 incr prnl(next)
 if {$prnl(next)>=[llength $prnl(msgs)]} {  set prnl(next) 0  }

 set randmin $prnl(min-lo)
 if {$prnl(min-hi)>$prnl(min-lo)} {
   incr randmin [rand [expr {$prnl(min-hi)-$prnl(min-lo)+1}]]
 }

 set prnl(timer) [timer $randmin [list prnl:rnext]]
}


putlog "Public Read Next Line v1.3 loaded."

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
Arkadietz
Halfop
Posts: 67
Joined: Fri Jul 14, 2006 11:43 am
Location: cat /dev/zero > /dev/null;

Post by Arkadietz »

has been tested and does not work at all
On a unix system everything is a file ; if something is not a file , it is a proccess.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Probably problems with finding the ads file.
Let's try it with some error lines added...

Code: Select all

# set the route and file name of the channel ads file #
# make the ads file as a plain text document, 1 ad per file line #
set prnl(ad-file) "scripts/ad-file.txt"


# The channels to msg: #chan1 #chan2 #etc  (* = all channels) #
set prnl(chans) {*}


# The minimum number of minutes between channel ads  (1 or more minutes) #
set prnl(min-lo) 5


# The maximum number of minutes between channel ads  (same or above min-lo) #
set prnl(min-hi) 10


# Read the lines in order or random  (1=inorder || 2=random) #
set prnl(order) 2


###### END OF SETTINGS ######


set prnl(msgs) ""
if {![file exists $prnl(ad-file)]} {
  putlog "PRNL Error: Unable to find file: $prnl(ad-file)"
  putlog "Public Read Next Line v1.4 NOT loaded!"
  return
}

set prnl(tm-open) [open $prnl(ad-file)]
while {![eof $prnl(tm-open)]} {
 set prnl(tm-line) [string trim [gets $prnl(tm-open)]]
 if {$prnl(tm-line) ne ""} {
   lappend prnl(msgs) $prnl(tm-line)
 }
}
close $prnl(tm-open)
unset prnl(tm-open) prnl(tm-line) prnl(ad-file)

if {$prnl(msgs) eq ""} {
  putlog "PRNL Error: No text in ad file: $prnl(ad-file)"
  putlog "Public Read Next Line v1.4 NOT loaded!"
  return
}


if {$prnl(chans) eq "*" || $prnl(chans) eq ""} {  set prnl(chans) [channels]  }
if {![info exists prnl(next)]} {  set prnl(next) 0  }
if {![info exists prnl(timer)]} { set prnl(timer) [timer 2 [list prnl:rnext]] }

if {$prnl(min-hi)<$prnl(min-lo)} {  set prnl(min-hi) $prnl(min-lo)  }


proc prnl:rnext {} {  global prnl
 if {$prnl(msgs) eq ""} {  return  }

 if {$prnl(order)=="2"} {  set prnl(next) [rand [llength $prnl(msgs)]]  }

 foreach ch $prnl(chans) {
  puthelp "PRIVMSG $ch :[lindex $prnl(msgs) $prnl(next)]"
 }

 incr prnl(next)
 if {$prnl(next)>=[llength $prnl(msgs)]} {  set prnl(next) 0  }

 set randmin $prnl(min-lo)
 if {$prnl(min-hi)>$prnl(min-lo)} {
   incr randmin [rand [expr {$prnl(min-hi)-$prnl(min-lo)+1}]]
 }

 set prnl(timer) [timer $randmin [list prnl:rnext]]
}


putlog "Public Read Next Line v1.4 loaded."

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Post Reply