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.

Need help with ad script

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
c
crymsun
Voice
Posts: 33
Joined: Tue Nov 13, 2018 8:24 pm

Need help with ad script

Post by crymsun »

Below is the script I got from the tcl archive... and made adjustments for my channel. But for some reason, it loads fine but doesn't work.

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
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

The command isn't working because this line:

Code: Select all

bind pub $trigger send:adv 
is missing it's flags since the syntax is: bind pub <flags> <command> <proc>, so it should be:

Code: Select all

bind pub * $trigger send:adv
since you want to be triggered by everyone, meaning even people that don't have access to the bot.

I don't understand what's this line:

Code: Select all

if {![string match *[lindex $channel 0]* $no_adv]} { 
supposed to do since there's no no_adv variable.

I don't get it why loop over the adv_chans in:

Code: Select all

foreach channel $adv_chans {
      if {![string match *[lindex $channel 0]* $no_adv]} {
        if {$header == ""} {
          putserv "PRIVMSG $channel :$msg"
        } else { putserv "PRIVMSG $channel :$header $msg" }
      }
    }
when can use lsearch -nocase like:

Code: Select all

if {[lsearch -nocase $adv_chans $chan] > -1} {
... and the other stuff
I would honestly consider doing this from scratch to match your needs and make use of crontab (cron bind in eggdrop) instead of timers and whatever the author wanted to achieve in advmsg proc.
Once the game is over, the king and the pawn go back in the same box.
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

or usd ADV on Timer made by Jingyou on the tcl archive you can chooses which channels and picks random set advertisement lines from a txt file sounds perfect for your request :D
ComputerTech
Post Reply