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.

Variable issue

Old posts that have not been replied to for several years.
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

If you want every greeting different for every channel. Then you will need to increase the code. Set new greeting variables, which contain different greeting messages for every different channel, which would require them to work on their respective channels.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
]Kami[
Owner
Posts: 590
Joined: Thu Jul 24, 2003 2:59 pm
Location: Slovenia
Contact:

Post by ]Kami[ »

awyeah wrote:Here you go.
Use this:

Code: Select all

#If you want greeting to read from greeting.txt set this to 0 
#If you want it to read from the variable, set this to 1 
set greetvar "1"

#Set this to your channel greeting
set greeting "Welcome to the channel.  If you can see this message you are in the channel!"

#Set this to your greeting channels
set greetchans "#funchat #cyberparty #chatterz #beginner #allnitecafe"


bind join - * proc:greet 

proc:greet {nick uhost hand chan} { 
 global greetvar greetchans 
 if {([lsearch -exact [split [string tolower $greetchans]] [string tolower $chan]] == -1)} { 
 if {([string equal $greetvar "0"])} {
  regsub -all "\t" [split [exec [lindex "cat greeting.txt" 0] [join [lrange "cat greeting.txt" 1 end]]] \n] " " results 
  foreach line $results {
   puthelp "Notice $nick :$line"
   } 
  } 
  if {([string equal $greetvar "1"])} { 
   putquick "NOTICE $nick :$greeting" 
  } 
 } 
}
Whats was wrong with my code? It was the simple way to make it and he only would need to edit greet message in tcl, he could enable it in partyline...And also you forgot to make variable greeting global :P
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Here's a little greet thing i made a while back...it has individual messages for each channel and is fairly compact.
Most of the code deals with preparing the array names/messages to allow people who don't know tcl to change the settings without screwing things up :) If you want to be able to remove channels without having to restart, add 'array unset greetem' to the top of the script (before the first 'set')

Code: Select all

# some examples - simple one line message
set greetem(#Chan1) {You just joined $chan...duh :P}
# multiline message with formatting (whitespace is trimmed off by init)
set greetem(#cHaN2) {
	Welcome to $chan, $nick!
	Enjoy your stay
	oh...and please behave.
}
# global message used for channels that don't have their own message
# (comment out or leave blank to disable)
set greetem(*) {Hi $nick, my admin is lazy or stupid :/}


bind join - * greetem:join
proc greetem:join {nick uhost hand chan} {
	global greetem
	set c [string tolower $chan]
	if {[info exists greetem($c)]||([info exists greetem(*)]&&[set c *]!={})} {
		foreach line $greetem($c) {
			putserv "NOTICE $nick :[subst -nob -noc $line]"
		}
	}
}
proc greetem:init {} {
	variable greetem
	set names {}
	foreach {key val} [array get greetem] {
		unset greetem($key)
		foreach line [split $val[set val {}] \n] {
			if {[string len [set line [string trim $line]]]} {
				lappend val $line
			}
		}
		if {[llength $val]} {
			set greetem([string tolower $key]) $val
			lappend names $key
		}
	}
	if {[array size greetem]} {
		putlog "greetem loaded - I'll greet people in [join $names {, }]."
	} {
		putlog "greetem loaded - wtf? no messages?"
	}
}
greetem:init;# clean up array and display "loaded"-message
Have you ever read "The Manual"?
Locked