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 

Want this script to work on ALL channels.

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
cache
Master


Joined: 10 Jan 2006
Posts: 306
Location: Mass

PostPosted: Fri Aug 11, 2006 1:48 pm    Post subject: Want this script to work on ALL channels. Reply with quote

Can someone help me set this to work in all channels the bot is in? I tried $chan with no luck, only lets script work in one room.

Code:
#############################################################
##                                                         ##
##           Words of Wisdom v2.01 TCL (WoW)               ##
##   Display funny nonsense to your irc friends/channel    ##
##                  by Phil (Admin)                        ##
##              Penthux.net - June 2005                    ##
##                                                         ##
## This script is not meant to do anything except make you ##
## smile. The text file can contain any plain text,        ##
## whether it be jokes, channel adverts or whatever. When  ##
## adding your own content just make sure you put each     ##
## item on a seperate line in the text file. There is no   ##
## limit to how large or small the text file must be.      ##
##                                                         ##
## Usage:                                                  ##
## [channel commands]                                      ##
## !wow               = displays a WoW line to channel     ##
## !wow [nick|chan]   = displays WoW line to nick or chan  ##
##                                                         ##
## ** NB - only ops, halfops and voices in the named       ##
## #channel can use the !wow [nick|chan] command which can ##
## be sent to any nickname or channel on the network which ##
## allows external messages. All other users get the WoW   ##
## line back in their own query window. Change the code if ##
## you like as this setup primarily stops lamer flooding   ##
## to nicks/chans.                                         ##
##                                                         ##
## Installation:                                           ##
## 1. Set the irc #channel to display the WoW lines        ##
## automatically and the timer intervals between output.   ##
## Edit your eggdrop filename.conf and add this line to    ##
## the end of the file:                                    ##
##                                                         ##
## source scripts/wow.tcl                                  ##
##                                                         ##
## 2. Copy the edited filename.conf file to your eggdrop   ##
## dir and copy both the wow.tcl & wow.txt files to the    ##
## SCRIPTS directory. Now reboot/restart your eggdrop bot. ##
##                                                         ##
## Please keep this header intact if you distribute or     ##
## modify this CGI script.               admin@penthux.net ##
#############################################################

## set the channel to display automatic WoW lines, include the '#' prefix
set wowchan "#your_channel"

## set the timer interval (in minutes) between WoW lines
set wowtime "30"


#######################################################
### don't change anything below if u don't know TCL ###
#######################################################

if { [info exists wowtime] } { timer $wowtime "timer:wow" }

set wowtxt "scripts/wow.txt"
set wowver "v2.01"

bind pub - !wow disp:wow

proc disp:wow {nick host handle chan text} {
  global wowchan wowtxt
  if { [isop $nick $wowchan] || [ishalfop $nick $wowchan] || [isvoice $nick $wowchan] } { 
    if { [lindex $text 0] != "" } {
        set wowto [lindex $text 0]
    } else {
        set wowto $wowchan
    }
      set wowfile [open $wowtxt r]
      set wowread [split [read $wowfile] \n]
      close $wowfile
      putserv "PRIVMSG $wowto :[lindex $wowread [rand [llength $wowread]]] "
  } else {
      set wowfile [open $wowtxt r]
      set wowread [split [read $wowfile] \n]
      close $wowfile
      putserv "PRIVMSG $nick :[lindex $wowread [rand [llength $wowread]]] "
  }
}

proc timer:wow {} {
  global botnick wowchan wowtime wowtxt
  if { [onchan $botnick $wowchan] } {
    set wowfile [open $wowtxt r]
    set wowread [split [read $wowfile] \n]
    close $wowfile
    putserv "PRIVMSG $wowchan :[lindex $wowread [rand [llength $wowread]]] "
    timer $wowtime "timer:wow"
  }
}

putlog "Words of Wisdom $wowver TCL (timer: $wowtime mins) - Loaded! "

#
#


Thanks
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Sat Aug 12, 2006 12:28 pm    Post subject: Reply with quote

Code:

################################################################################################################
## set the channel to display automatic WoW lines, include the '#' prefix
set wowchans "#your_channel #channel2 #chan3 #etc"

## set the timer interval (in minutes) between WoW lines
set wowtime "30"

if { [info exists wowtime] } { timer $wowtime "timer:wow" }

set wowtxt "scripts/wow.txt"
set wowver "v2.01"

bind pub - !wow disp:wow

proc disp:wow {nick host handle chan text} {

# Need to leave 'wowchan' in the global dec so it'll carry over to the timer
  global wowchans wowchan wowtxt

# test if the channel is in the wowchans list and set 'wowchan' accordingly.
if {[lsearch -exact $wowchans $chan] != -1} {
               set wowchan $chan         
     } else {
               # did not match a channel in the "wowchans list"
               return
     }


  if { [isop $nick $wowchan] || [ishalfop $nick $wowchan] || [isvoice $nick $wowchan] } {
    if { [lindex $text 0] != "" } {
        set wowto [lindex $text 0]
    } else {
        set wowto $wowchan
    }
      set wowfile [open $wowtxt r]
      set wowread [split [read $wowfile] \n]
      close $wowfile
      putserv "PRIVMSG $wowto :[lindex $wowread [rand [llength $wowread]]] "
  } else {
      set wowfile [open $wowtxt r]
      set wowread [split [read $wowfile] \n]
      close $wowfile
      putserv "PRIVMSG $nick :[lindex $wowread [rand [llength $wowread]]] "
  }
}

proc timer:wow {} {
  global botnick wowchan wowtime wowtxt
  if { [onchan $botnick $wowchan] } {
    set wowfile [open $wowtxt r]
    set wowread [split [read $wowfile] \n]
    close $wowfile
    putserv "PRIVMSG $wowchan :[lindex $wowread [rand [llength $wowread]]] "
    timer $wowtime "timer:wow"
  }
}

putlog "Words of Wisdom $wowver TCL (timer: $wowtime mins) - Loaded! "
#


That should do the trick.
Back to top
View user's profile Send private message
cache
Master


Joined: 10 Jan 2006
Posts: 306
Location: Mass

PostPosted: Sat Aug 12, 2006 3:21 pm    Post subject: Reply with quote

Thanks, works great so far Very Happy
Back to top
View user's profile Send private message
cache
Master


Joined: 10 Jan 2006
Posts: 306
Location: Mass

PostPosted: Sat Aug 12, 2006 6:38 pm    Post subject: Reply with quote

Ok the !wow part works in every room but when the 30 min timer is ready to send it gives me this error:

Code:
[18:34] Tcl error in script for 'timer6':
[18:34] can't read "wowchan": no such variable
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Sat Aug 12, 2006 6:55 pm    Post subject: Reply with quote

Ahh, I didn't completely analyze the timer thing.

I'll assume you want to have the timer go off in each of the wowchans, so change that proc like this:
Code:

proc timer:wow {} {
  global botnick wowchans wowchan wowtime wowtxt

foreach wowchan $wowchans {
   if { [onchan $botnick $wowchan] } {
      set wowfile [open $wowtxt r]
      set wowread [split [read $wowfile] \n]
      close $wowfile
      putserv "PRIVMSG $wowchan :[lindex $wowread [rand [llength $wowread]]] "
      timer $wowtime "timer:wow"
    }
  }
}


Should fix er.
Back to top
View user's profile Send private message
cache
Master


Joined: 10 Jan 2006
Posts: 306
Location: Mass

PostPosted: Sun Aug 13, 2006 1:16 am    Post subject: Reply with quote

It works but it sent the wow text 10 times in a row in each channel Embarassed
Back to top
View user's profile Send private message
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Sun Aug 13, 2006 8:34 am    Post subject: Reply with quote

because the timer repeats in every foreach loop.

rosc2112 should have paid attention.

Code:
proc timer:wow {} {
  global botnick wowchans wowchan wowtime wowtxt

  set wowfile [open $wowtxt r]
  set wowread [split [read $wowfile] \n]
  close $wowfile

  foreach wowchan $wowchans {
    if { [onchan $botnick $wowchan] } {
      putserv "PRIVMSG $wowchan :[lindex $wowread [rand [llength $wowread]]] "
    }
  }
  timer $wowtime "timer:wow"
}
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 Support & Releases 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