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.

IF / ELSEIF Help??

Help for those learning Tcl or writing their own scripts.
Post Reply
C
CharlesZink
Voice
Posts: 12
Joined: Sun Feb 28, 2010 7:41 pm
Location: The Interweb
Contact:

IF / ELSEIF Help??

Post by CharlesZink »

Hi, this is what I have gotten so far and it doesn't say anything in chat, but I do get this error message in Telnet..
[20:22] Tcl error [website_disp]: syntax error in expression "$channel == #techhelpwithjeff": character not legal in expressions
So I guess the '#' is the problem, but how do I tell it what channel then?

Code: Select all

bind pub - !site website_disp


proc website_disp {nick host handle channel testes  } {

if {$channel == #techhelpwithjeff} {
putserv "PRIVMSG $channel :$nick, our website is http://www.techhelpwithjeff.com/"
} elseif {$channel == #sams-tech} {
putserv "PRIVMSG $channel :$nick, our website is http://www.smartysamscomputerbuilds.com/"
} elseif {$chanel == #thenerdtv} { 
putserv "PRIVMSG $channel :$nick, our website is http://www.thenerdtv.com/"
} else { putserv  "PRIVMSG $channel :$nick, I do not have a site defined for this channel yet"
}
return 0
}
Find Me: irc.tysonbrooks.net:6667 / #thenerdtv

Bots:
Nick: UniverseBot - Channels: #thenerdtv #sams-tech #bots #techhelpwithjeff
Nick: CitronBOT - Channel: #anatolie (GeekShedIRC)
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Re: IF / ELSEIF Help??

Post by speechles »

Code: Select all

bind pub - !site website_disp

proc website_disp {nick host handle channel testes} {
   switch -- $channel {
      "#techhelpwithjeff" { putserv "PRIVMSG $channel :$nick, our website is http://www.techhelpwithjeff.com/" } 
      "#sams-tech" { putserv "PRIVMSG $channel :$nick, our website is http://www.smartysamscomputerbuilds.com/" }
      "#thenerdtv" { putserv "PRIVMSG $channel :$nick, our website is http://www.thenerdtv.com/" }
      default { putserv "PRIVMSG $channel :$nick, I do not have a site defined for this channel yet" }
   }
   return 1
}
[switch] makes sense here, as those nested if/elseif/elseif/etc look horrible. You also want to make sure to return 1 from this "pub" procedure. If this were a glob matched "pubm" bind instead, a return of 0 would be used.
Post Reply