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 

Need help with ad script

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


Joined: 13 Nov 2018
Posts: 31

PostPosted: Sun Jan 06, 2019 5:41 pm    Post subject: Need help with ad script Reply with quote

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:
### 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
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3583
Location: Mint Factory

PostPosted: Mon Jan 07, 2019 2:45 am    Post subject: Reply with quote

The command isn't working because this line:
Code:

bind pub $trigger send:adv

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

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:

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:

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:

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.
_________________
I tawt I taw a puddy tat!
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