What I would like it to do is:
- upon the !topic command, bot should randomly select a line from the topic.txt file
- the line should be posted to the channel for all to see
- anyone should be able to use the trigger
This is the script I was working with, with my edits:
Code: Select all
### Simple Advertise 1.2. by DeeJay
###
### Thanks to #TCL @ Quakenet for all the help
### and NO^DICKHILL for putting his eggdrops
### thru what my script did to them.
###
### Usage: !advertise will advertise a random
### advertise to all channels from the specified
### file (Bellow here) - The script will automaticly
### attempt to take a random line from the
### advertise database and send it to the channels.
###
### This script may be edited as much you want
### Aslong as these lines remains.
###
### Contact
### irc: #nequam @ quakenet
### msn: djs@deejay-spunk.dk
### mail: djs@deejay-spunk.dk
###
### Changelog:
### 1.2) Completly rewrite of the whole script, added alot of new stuff (Still SIMPLE)
### 1.1) Fixed some bugs with the timing stuff
### 1.0) First release
### Advertisement trigger, to trigger a advertising outside the timer.
set trigger "!topic"
### "Header" - This will show when your bot advertises like 'Header advertise-message'
### Example: [Advertise] bla bla bla bla bla
### Leave empty if you dont want to use this.
set header "Y/your topic, as requested..."
### If you want the messages only to be shown in a specific timesquare, then put in the times here
### (20:00 to 21:00 etc, seperate with spaces, for no timer you can write like: 00:00 23:59)
set adv_time "00:00 23:59"
### The file where the advertise messages is stored in. (FILE MUST EXISTS IN THAT FOLDER!
### Remember to give read access to the file, chmod 644 or something)
###
### Linux: touch /path/to/my/file && chmod 644 /path/to/my/file
### Then edit the file with your favourite editor like 'nano' or 'vi' and wrote your
### advertisements there.
set adv_file "/home/paradisum/eggdrop1.8/scripts/data/topic.txt"
### Channels the advertise message should go to. For all channels, write ALL only.
### e.g: #chan1 #chan2 #chan3
set adv_chans "#DsParadisum"
### How long time between the messages (In minutes)
set adv_timer "300"
#############################################################
### Code bellow, Only edit if you know what you are doing ###
#############################################################
bind pub $trigger send:adv
proc adv:timer {} {
global adv_timer
if {[timerexists adv:do] == ""} { timer $adv_timer adv:do }
}
adv:timer
proc send:adv {nick chan host handle text} {
global adv_chans header
set schan [string trim $chan "#+&!"]
set msg "[advmsg]"
if {[string tolower $adv_chans] == "all"} {
foreach channel [channels] {
if {![string match *[lindex $channel 0]* $no_adv]} {
if {$header == ""} {
putserv "PRIVMSG $channel :$msg"
} else { putserv "PRIVMSG $channel :$header $msg" }
}
}
} else {
foreach channel $adv_chans {
if {![string match *[lindex $channel 0]* $no_adv]} {
if {$header == ""} {
putserv "PRIVMSG $channel :$msg"
} else { putserv "PRIVMSG $channel :$header $msg" }
}
}
}
}
proc adv:do {} {
global adv_chans adv_timer adv_time no_adv header
set msg "[advmsg]"
if {[string tolower $adv_chans] == "all"} {
foreach channel [channels] {
if {![string match *[lindex $channel 0]* $no_adv]} { putserv "PRIVMSG $channel :$header $msg" }
}
} else {
foreach channel $adv_chans {
if {![string match *[lindex $channel 0]* $no_adv]} { putserv "PRIVMSG $channel :$header $msg" }
}
}
adv:timer
}
proc advmsg {} {
global adv_file adv_from adv_to adv_time
set first "[lindex [split "$adv_time"] 0]"
set second "[lindex [split "$adv_time"] 1]"
set time [strftime %H%M]
if {$time <= "[string map {{:} {}} $second]" || $time >= "[string map {{:} {}} $first]"} {
set x ""
while {$x == ""} {
set f [open $adv_file]
set l [split [read $f] \n]
close $f
set n [rand [llength $l]]
if {[set x [lindex $l $n]]!=""} {return "$x"}
}
}
}
putlog "\002//-- Advertise script by DeeJay loaded successfully --//\002