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.

Joke Script Wont reply to commands, help please

Help for those learning Tcl or writing their own scripts.
Post Reply
c
chaokusc
Voice
Posts: 18
Joined: Tue Apr 25, 2006 5:57 am

Joke Script Wont reply to commands, help please

Post by chaokusc »

Im not sure whats wrong with my script, only !jokes and !joke yomama work

Yes im new to tcl script but i would like to learn it, but im not sure what is wrong with this script... if anyone can tell me that would be great
( Jokes cut down to 2 jokes from the whole list in order to make script shorter )

Code: Select all

# !Jokes
bind pub - !jokes pub_jokes
bind pub - "!joke" pub:redneck
bind pub - "!joke" pub:annoy
bind pub - "!joke" pub:blonde
bind pub - "!joke" pub:computers
bind pub - "!joke" pub:condoms
bind pub - "!joke" pub:elevator
bind pub - "!joke" pub:misc
bind pub - "!joke" pub:thoughts
bind pub - "!joke" pub:yomama

proc pub_jokes {nick uhost hand chan text} {
putserv "NOTICE $nick : 4\[7»»4\] Joke Commands 4\[7««4\]"
putserv "NOTICE $nick : 4!joke 7Random Joke"
putserv "NOTICE $nick : 4!joke annoy 7 101 Ways To Annoy Someone"
putserv "NOTICE $nick : 4!joke blonde 7 Blonde Jokes"
putserv "NOTICE $nick : 4!joke computers 7 Computer Jokes"
putserv "NOTICE $nick : 4!joke elevator 7 52 Fun Things To Do In An Elevator"
putserv "NOTICE $nick : 4!joke condoms 7 Condom Jokes"
putserv "NOTICE $nick : 4!joke misc 7 Misc Jokes"
putserv "NOTICE $nick : 4!joke redneck 7 Redneck Jokes"
putserv "NOTICE $nick : 4!joke thoughts 7 Whats On Your Mind"
putserv "NOTICE $nick : 4!joke yomama 7 Yo Mama Jokes"
}

set redneckjokes {
"More than one living relative is named after a Southern Civil War general"
"You think the stock market has a fence around it"
}

proc pub:redneck { nick uhost handle channel text } {
global redneckjokes
if {$text == "redneck"} {
	set respond [lindex $redneckjokes [rand [llength $redneckjokes]]]
	putserv "PRIVMSG $channel :\002$nick\002 You Might Be A Redneck If: $respond"
	}
}

set annoyjokes {
"Get to know a friends bookie and place bets for them. Insist on keeping half of any money they win."
"Accuse people of \"glue sniffing addictions\" in public."
}

proc pub:annoy { nick uhost handle channel text } {
global annoyjokes
if {$text == "annoy"} {
	set respond [lindex $annoyjokes [rand [llength $annoyjokes]]]
	putserv "PRIVMSG $channel :101 Ways To Annoy People: $respond"
	}
}

set blonejokes {
"Q: How do blonde brain cells die ? A: Alone."
"Q: How do you change a blonde's mind? A: Blow in her ear."
}

proc pub:blone { nick uhost handle channel text } {
global blonejokes
if {$text == "blone"} {
	set respond [lindex $blonejokes [rand [llength $blonejokes]]]
	putserv "PRIVMSG $channel :$respond"
	}
}

set computersjokes {
"Your stationery is more cluttered than Warren Beatty's address book. The letterhead lists a fax number, e-mail addresses for two on-line services, and your Internet address, which spreads across the breadth of the letterhead and continues to the back. In essence, you have conceded that the first page of any letter you write *is*letterhead"
"You have never sat through an entire movie without having at least one device on your body beep or buzz"
}

proc pub:computers { nick uhost handle channel text } {
global computersjokes
if {$text == "computers"} {
	set respond [lindex $computersjokes [rand [llength $computersjokes]]]
	putserv "PRIVMSG $channel :You Know Your a Computer Addict When: $respond"
	}
}

set condomsjokes {
"Nike Condoms: Just do it."
"Toyota Condoms: Oh what a feeling."
}

proc pub:condoms { nick uhost handle channel text } {
global condomsjokes
if {$text == "condoms"} {
	set respond [lindex $condomsjokes [rand [llength $condomsjokes]]]
	putserv "PRIVMSG $channel : $respond"
	}
}

set elevatorjokes {
"#1: Make race car noises when anyone gets on or off."
"#2: Blow your nose and offer to show the contents of your kleenex to other passengers."
}

proc pub:elevator { nick uhost handle channel text } {
global elevatorjokes
if {$text == "elevator"} {
	set respond [lindex $elevatorjokes [rand [llength $elevatorjokes]]]
	putserv "PRIVMSG $channel :52 Fun Things To Do In An Elevator $respond"
	}
}

set miscjokes {
"How come wrong numbers are never busy?"
"Do people in Australia call the rest of the world \"up over\"?"
}

proc pub:misc { nick uhost handle channel text } {
global miscjokes
if {$text == "misc"} {
	set respond [lindex $miscjokes [rand [llength $miscjokes]]]
	putserv "PRIVMSG $channel :$respond"
	}
}

set thoughtsjokes {
"Hackers: We're explorers, not criminals"
"In the realm of the blind, the one-eyed man is king"
}

proc pub:thoughts { nick uhost handle channel text } {
global thoughtsjokes
if {$text == "thoughts"} {
	set respond [lindex $thoughtsjokes [rand [llength $thoughtsjokes]]]
	putserv "PRIVMSG $channel :$respond"
	}
}

set yomamajokes {
"Fat, That when the casier at KFC asked her what size bucket of chicken she wanted, she said the one on the roof"
"Fat, That she has more rolls than the bakery"
}

proc pub:yomama { nick uhost handle channel text } {
global yomamajokes
if {$text == "yomama"} {
	set respond [lindex $yomamajokes [rand [llength $yomamajokes]]]
	putserv "PRIVMSG $channel :\002$nick\002 Yo Mama So $respond"
	}
}


putlog "* Jokes Loaded."
Last edited by chaokusc on Tue Apr 25, 2006 10:34 am, edited 1 time in total.
G
GeeX
Voice
Posts: 29
Joined: Mon Sep 19, 2005 4:29 am

Post by GeeX »

You bind !joke with 9 different procs? :shock:
c
chaokusc
Voice
Posts: 18
Joined: Tue Apr 25, 2006 5:57 am

Post by chaokusc »

yes but all procs have a different name such as annoy would bring up the annoy list

Code: Select all

if {$text == "annoy"} { 
I want !joke * for all of them
such as !joke annoy would pull up the post for the annoy jokes

I have tried to do this

Code: Select all

bind pub - "!joke annoy" pub:annoy
But this did not work

Another thing i tried was

Code: Select all

bind pub - !jokes pub_jokes 
bind pub - "!joke1" pub:redneck 
bind pub - "!joke2" pub:annoy 
bind pub - "!joke3" pub:blonde 
bind pub - "!joke4" pub:computers 
bind pub - "!joke5" pub:condoms 
bind pub - "!joke6" pub:elevator 
bind pub - "!joke7" pub:misc 
bind pub - "!joke8" pub:thoughts 
bind pub - "!joke9" pub:yomama
But that also did not work
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

Code: Select all

bind pub - !joke pub:jokesort

proc pub:jokesort {n u h c t} {
   switch -nocase $t {
      redneck {pub:redneck $n $u $h $c $t}
      annoy {pub:annoy $n $u $h $c $t}
      blonde {pub:blonde $n $u $h $c $t}
      computers {pub:computers $n $u $h $c $t}
      condoms {pub:condoms $n $u $h $c $t}
      elevator {pub:elevator $n $u $h $c $t}
      misc {pub:misc $n $u $h $c $t}
      thoughts {pub:thoughts $n $u $h $c $t}
      yomama {pub:yomama $n $u $h $c $t}
      default {pub_jokes $n $u $h $c $t}
   }
}
switch can very effective for things like this
c
chaokusc
Voice
Posts: 18
Joined: Tue Apr 25, 2006 5:57 am

Post by chaokusc »

DragnLord i now get this error message in party chat when i try a command in channel

Code: Select all

[17:08] <testbot> [12:07] Tcl error [pub:jokesort]: bad option "-nocase": must be -exact, -glob, -regexp, or --
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

chaokusc wrote:DragnLord i now get this error message in party chat when i try a command in channel

Code: Select all

[17:08] <testbot> [12:07] Tcl error [pub:jokesort]: bad option "-nocase": must be -exact, -glob, -regexp, or --
Then remove the nocase switch. Common sense says to remove an option that is not supported by installed tcl. The -nocase option is not really needed, it only helps when "Yomama" is used instead of "yomama". To get the same effect you can set $t to all lowercase before the switch evaluation.
c
chaokusc
Voice
Posts: 18
Joined: Tue Apr 25, 2006 5:57 am

Post by chaokusc »

DragnLord Thank You So Much ^^ I luv u :roll:
Post Reply