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.

hmm i know it is on here somewhere .. ? just can't find it.

Old posts that have not been replied to for several years.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

hmm i know it is on here somewhere .. ? just can't find it.

Post by Ofloo »

hmm i got a question i want to perform from the channel a command so i can send a privmsg to someone

!msg <nick> statictext <var>

i know it can be done by spliting [lindex $args 0] i saw it somewhere on the from i think just can't seem to find it no more it was like

set arg1 ...
set arg2 ...

but was mutch simpler could be done mutch easyer with {a b c or something any one ?? or am i wrong ?? if so what must i do .. ?
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

First of all..using 'args' as a variable name is probably a bad idea for the script you're making. 'args' is treated in a special way when used as the last argument name in a proc. It will let your proc be called with zero to infinite number of arguments from that point and all the args are stuffed into a list in the variable inside the proc. So for your proc called by a pub bind (i'm guessing here) with a fixed number of arguments this will only lead to having to strip of a layer of list before you start working with the contents.

Short version: find another variable name than 'args'.

The command you're looking for is probably 'lrange'. Like 'lindex' it is a list command and requires a list to work properly, so make sure you 'split' the string before using any of those commands. You'll probably want to 'join' the list returned by lrange before you send the message btw :)
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

i tryed this .. ?

Code: Select all

proc send:msg {nick uhost hand chan arg} { 
global msg send:msg
  set usr [lindex $arg 0]
  set text [lindex $arg 1]
  putquick "NOTICE $nick : Sending msg.."
  putserv "PRIVMSG $usr: mybot is sending you this text #$text"
  putserv "NOTICE $nick : Succesfully send msg to [lindex $arg 0]"
}
if i do this
putserv "NOTICE $nick : Succesfully send msg to [lindex $arg 0] test tes test [lindex $arg 0]"
it puts the notice ok but ..
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

But what? Did you read my post?
putserv "PRIVMSG $usr: mybot is sending you this text #$text"
The space should be BEFORE the :, not after it :)

btw: try !msg {bla {bla
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

stupid me it works no need for the "{" ;) tnx man
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

is there anyway i can relay the notice that is been send to the dcc window or pm reply for that mather back to me ?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Heh, I think he said to try the { because it will create an error. Your script uses set usr [lindex $arg 0], but if $arg isn't a proper list (like {blah {blah) then it will cause a tcl error. You should put:

set arg [split $arg]

at the top of the proc.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

hmm but ill never it use like that .. ?? like i don't know a nick {..

but how do i use this
[split $arg]
show me in script so i can see it ..
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

I already showed you, at the top of your proc put

set arg [split $arg]

exactly like that hehe
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

like this ??

Code: Select all

proc send:msg {nick uhost hand chan arg} { 
global msg send:msg 
  set arg [split $arg] 
  set usr [lindex $arg 0] 
  set text [lindex $arg 1] 
  putquick "NOTICE $nick :Sending msg.." 
  putserv "PRIVMSG $usr :mybot is sending you this text #$text" 
  putserv "NOTICE $nick :Succesfully send msg to [lindex $arg 0]" 
}
User avatar
ReaLz
Op
Posts: 121
Joined: Sat Oct 19, 2002 5:33 am
Location: Athens, Greece

Post by ReaLz »

try using

Code: Select all

set text [lrange $args 1 end]
instead of

Code: Select all

set text [lindex $arg 1]
to make the bot tell whole the text and not only the first word after the nick.
«A fantastic spaghetti is a spaghetti that does not exist»
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

Could you plz change it in the script... i am realy new to this and realy want to understand it well

Code: Select all

proc send:msg {nick uhost hand chan arg} { 
global msg send:msg 
  set arg [split $arg] 
  set usr [lindex $arg 0] 
  set text [lindex $arg 1] 
  putquick "NOTICE $nick :Sending msg.." 
  putserv "PRIVMSG $usr :mybot is sending you this text #$text" 
  putserv "NOTICE $nick :Succesfully send msg to [lindex $arg 0]" 
} 
for example next question would be
set arg [split $arg] #do i remove this if i add what you say
set usr [lindex $arg 0] #what about this arg ?? do i change anything about it
if you just add it to the script i see probably understand if i don't understand ill ask again .. :) and it only takes a second ..
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

just change

Code: Select all

set text [lindex $arg 1]
to

Code: Select all

set text [lrange $arg 1 end]
Elen sila lúmenn' omentielvo
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

i see hehe nice it adds an \ before the { tnx man probably won't use it ever but nice to know for futur scripting hehe ;)
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

The { is there because lrange returns a list. In Tcl, when you print a list as text, it puts { } around it so you know it's a list. To make it into a proper string, you have to use the 'join' command (which joins the elements into a string). Note, lindex also returns a string, because this is a list of strings (words). So, it should look like this:

set arg [split $arg]
set usr [lindex $arg 0]
set text [join [lrange $arg 1 end]]
Locked