How do i fix my reply on word script ?

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

How do i fix my reply on word script ?

Post by chaokusc »

I got this simple reply script written out so if somone says brb my bot says $nick says Be Right Back

Code: Select all

bind pub - brb pub_brb
proc pub_brb {nick uhost hand chan $brb_msg} {
putchan $chan "\002$nick\002 says Be Right Back" 
}
My question is, how can i make the bot not reply to anything after the brb ?
<FoX> brb
<testbot> FoX says Be Right Back
<FoX> brb im going out
<testbot> FoX says Be Right Back
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Re: How do i fix my reply on word script ?

Post by DragnLord »

chaokusc wrote: My question is, how can i make the bot not reply to anything after the brb ?
<FoX> brb
<testbot> FoX says Be Right Back
<FoX> brb im going out
<testbot> FoX says Be Right Back
Try this:

Code: Select all

bind pub - brb pub_brb
proc pub_brb {nick uhost hand chan args} {
  if {$args == ""} {
    putchan $chan "\002$nick\002 says Be Right Back"
  }
}
c
chaokusc
Voice
Posts: 18
Joined: Tue Apr 25, 2006 5:57 am

Post by chaokusc »

It still does it DragnLord, is there any other way ?
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

You shouldn't use args, instead use arg.
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

oops, that's why I usually use the simpler variable form

Code: Select all

bind pub - brb pub_brb
proc pub_brb {n u h c t} {
  if {$t == ""} {
    putchan $c "\002$n\002 says Be Right Back"
  }
}
c
chaokusc
Voice
Posts: 18
Joined: Tue Apr 25, 2006 5:57 am

Post by chaokusc »

^^ Thank You
c
chaokusc
Voice
Posts: 18
Joined: Tue Apr 25, 2006 5:57 am

Post by chaokusc »

Sorry for the double post but can anyone help me with the reply on this?
I just wish to know why $nick is not replaced with the nick of the person who typed superm4n

Code: Select all

set superm4nreply {
"Its a Bird, Its a Plane, No Its \0024Superm4n\002"
"\0024Superm4n\002 i think \002$nick\002 wants you"
"\002$nick\002 do you know why \0024Superm4n\002 wears his underwear on the outside ?"
"\002$nick\002 do you know why \0024Superm4n\002 wears \002red\002 underwear ?"
}

bind pub - superm4n pub_superm4n
proc pub_superm4n {nick u h chan t} {
global superm4nreply
if {$t == ""} {
set output [lindex $superm4nreply [rand [llength $superm4nreply]]]
putchan $chan "$output"
  }
}
If your not interested in giving me the full help thats fine, clues are welcome :D
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

1) use putlog to show variables in dcc as the script runs

Code: Select all

proc pub_superm4n {nick u h chan t} {
putlog "got $nick in $chan"
global superm4nreply
if {$t == ""} {
set output [lindex $superm4nreply [rand [llength $superm4nreply]]]
putlog "output: $output"
putchan $chan "$output"
  }
}
(btw, for this to work as written "superm4n" has to be the only word said)

2) search a lot more about rand and expr
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

he will have to double evaluate it, like:

eval "putchan $chan \"$output\""
or
eval "puthelp \"PRIVMSG $chan :$output\""
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
c
chaokusc
Voice
Posts: 18
Joined: Tue Apr 25, 2006 5:57 am

Post by chaokusc »

I managed to fix it with this code

Code: Select all

# Superm4n
set bigmanreply {
"Its a Bird, Its a Plane, No Its \0024Superm4n\002"
"\0024Superm4n\002 i think \002$nick\002 wants your attention"
"\002$nick\002 do you know why \0024Superm4n\002 wears his underwear on the outside ?"
"\002$nick\002 do you know why \0024Superm4n\002 wears red underwear ?"
}
bind pub - superm4n pub_bigman
proc pub_bigman {nick u h chan t} {
global bigmanreply
if {$t == ""} {
set output [lindex $bigmanreply [rand [llength $bigmanreply]]]
regsub -all {\$nick} $output $nick output
putchan $chan "$output"
  }
}
This also let me allow $nick in bigmanreply

Thanks for all of your reply, and DragnLord i will look into rand and expr
Post Reply