egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
ertz
Voice


Joined: 07 Mar 2010
Posts: 2
Location: Philadelphia

PostPosted: Sun Mar 07, 2010 1:40 pm    Post subject: #ch talk script with random line from txt file every x min Reply with quote

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!
Back to top
View user's profile Send private message
Torrevado
Op


Joined: 02 Aug 2006
Posts: 101

PostPosted: Sun Mar 07, 2010 1:49 pm    Post subject: Re: #ch talk script with random line from txt file every x m Reply with quote

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-0-1-advertisement.htm
Back to top
View user's profile Send private message
ertz
Voice


Joined: 07 Mar 2010
Posts: 2
Location: Philadelphia

PostPosted: Mon Mar 08, 2010 2:09 pm    Post subject: Reply with quote

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




Code:

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"




Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber