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.

#ch talk script with random line from txt file every x min

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
e
ertz
Voice
Posts: 2
Joined: Sun Mar 07, 2010 1:33 pm
Location: Philadelphia

#ch talk script with random line from txt file every x min

Post by ertz »

Hello everybody,
I was browsing for this script for a while now... Maybe it's somewhere there, but i missed it.

I need a script that is going to read a random line from text file and post it in the #chan every xx min.

I would use it to show some interesting facts into the chan. I did used the on join script, when the scripts posts random line on join, but it went to messy.

Thank You!
T
Torrevado
Op
Posts: 101
Joined: Wed Aug 02, 2006 6:29 pm

Re: #ch talk script with random line from txt file every x m

Post by Torrevado »

ertz wrote: I need a script that is going to read a random line from text file and post it in the #chan every xx min.
From egghelp Tcl Archive: http://www.egghelp.org/tclhtml/3478-4-0 ... sement.htm
e
ertz
Voice
Posts: 2
Joined: Sun Mar 07, 2010 1:33 pm
Location: Philadelphia

Post by ertz »

thank you so much Torrevado!
One more question, is there I way I could set time for each channel?



Code: Select all

set anunt(char) "!"





#Here you can set what flags can use the command



set anunt(flags) "nm|MNnA"



#Here you can set the time interval of the advertisements



set anunt(time) "1"



#If you want the advertisements to be done by the PRIVMSG $chan method #set here "0" or if you want by the /me (action) set here "1"



set anunt(how) "1"



#######################################################################

#

#                         Smile Mothafucka

#

#######################################################################

set own "BLaCkShaDoW"

set vr "1.1"



bind pub $anunt(flags) $anunt(char)an anounce:process

setudef flag announce



if {![info exists announce:timer_running]} {

timer $anunt(time) announce:timer

set announce:timer_running 1

}



proc anounce:process {nick host hand chan arg} {

global anunt

set flag "announce"

set dir "logs/an($chan).txt"

set who [lindex [split $arg] 0]

set message [join [lrange [split $arg] 1 end]]

set number [lindex [split $arg] 1]

if {[channel get $chan announce]} { set status "on" } else { set status "off" }

if {$who == ""} { puthelp "NOTICE $nick :Please use $anunt(char)an <on> | <off> | <add> <mesaj> | <list> | <del> <number>"

return 0

}



if {([regexp -nocase -- {(#[0-9]+|on|off|add|list|del)} $who tmp a]) && (![regexp -nocase -- {\S#} $who])} {

    switch $a {

on {

channel set $chan +$flag

puthelp "NOTICE $nick :I activated the advertise system. To add an advertise just type $anunt(char)an add <your advertise>.You can add as many as you want"

}



off {

channel set $chan -$flag

puthelp "NOTICE $nick :I deactivated the advertise system."

}



add {

if {$message == ""} { puthelp "NOTICE $nick :Please use $anunt(char)an add <your advertise>"

return 0

}

if {$status == "off" } { puthelp "NOTICE $nick :First you have to activate the advertise system by typing $anunt(char)an on"

return 0

}

if {[file exists $dir] == 0} {

set file [open $dir a]

close $file

}

set file [open $dir a]

puts $file $message

close $file

puthelp "NOTICE $nick :Added an advertise for $chan:"

puthelp "NOTICE $nick :$message"

}



list {

if {$status == "off" } { puthelp "NOTICE $nick :First you have to activate the advertise system by typing $anunt(char)an on"

return 0

}

if {[file exists $dir] == 0} {

set file [open $dir a]

close $file

}

set dir "logs/an($chan).txt"

set file [open $dir "r"]

set w [read -nonewline $file]

close $file

set data [split $w "\n"]

set i 0

if {$data == ""} { puthelp "NOTICE $nick :There are no advertisements for $chan"

return 0

}

foreach mes $data {

set i [expr $i +1]

puthelp "NOTICE $nick :The advertisements list for $chan is:"

puthelp "NOTICE $nick :$i. $mes"

}

}



del {

if {$message == ""} { puthelp "NOTICE $nick :Please use $anunt(char)an del <number>. To list the advertisements type $anunt(char)an list"

return 0

}



if {$status == "off" } { puthelp "NOTICE $nick :First you have to activate the advertise system by typing $anunt(char)an on"

return 0

}

set dir "logs/an($chan).txt"

if {[file exists $dir] == 0} {

set file [open $dir a]

close $file

}



set file [open $dir "r"]

set data [read -nonewline $file]

close $file

set lines [split $data "\n"]

set i [expr $number - 1]

set delete [lreplace $lines $i $i]

set files [open $dir "w"]

puts $files [join $delete "\n"]

close $files



puthelp "NOTICE $nick :Deleted the advertisement number :$number for $chan."

puthelp "NOTICE $nick :Please check if i am right by typing $anunt(char)an list"

}



}

}

}





proc announce:timer {} {

global anunt

foreach chan [channels] {

set dir "logs/an($chan).txt"

if {[channel get $chan announce]} {

if {[file exists $dir] == 0} {

set file [open $dir a]

close $file

}

set file [open $dir "r"]

set data [read -nonewline $file]

close $file

set lines [split $data "\n"]

set numlines [llength $lines]

set random [rand $numlines]

set randomline [lindex $lines $random]

if {$anunt(how) == "1"} {

puthelp "PRIVMSG $chan :\001ACTION $randomline\001"

} else { 

puthelp "PRIVMSG $chan :$randomline"

}

}

}

timer $anunt(time) announce:timer

return 1

}



putlog "BlackAdvertise Tcl $vr by $own Loaded"




Post Reply