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.

cant post text to a user

Old posts that have not been replied to for several years.
Locked
S
Spirit
Voice
Posts: 15
Joined: Sat Oct 11, 2003 5:57 am

cant post text to a user

Post by Spirit »

I want the bot to post a couple lines to a user.
But somehow, i cant get it to work:

Code: Select all

set msg_welcome {
  "Text"
  "more Text"
  "and more"
  "EOF"
}

proc bsd:main {nick uhost hand chan para} {
    global msg_welcome
    if {![string length $para] > 0} {
      foreach {data} $msg_welcome {
        putsrv "PRIVMSG $nick $data
      }
    }
}
bind msg - !bsd bsd:main
the error is:

Code: Select all

Tcl error [bsd:main]: wrong # args: should be "bsd:main nick uhost hand chan para"
But the args are ok :roll:

Thx for your help!
it's not a bug - it's a feature!
D
Darkj
Halfop
Posts: 86
Joined: Sun Jul 06, 2003 9:58 pm

Post by Darkj »

Code: Select all

putsrv "PRIVMSG $nick $data 
that is way off, should be something like

Code: Select all

putserv "PRIVMSG $nick :$data" 
S
Spirit
Voice
Posts: 15
Joined: Sat Oct 11, 2003 5:57 am

Post by Spirit »

Oh, but i found that before...it is already "putserv"

But after a little playing around, i almost got it!
Now the bot is posting only the last word of every sentence.

Code: Select all

set msg_welcome { 
  "Text" 
  "more Text" 
  "and more" 
  "EOF" 
}
and the bot posts:
"Text"
"Text"
"more"
"EOF"

looks like is can't handle the spaces between the words, but i don't know why.
it's not a bug - it's a feature!
D
Darkj
Halfop
Posts: 86
Joined: Sun Jul 06, 2003 9:58 pm

Post by Darkj »

So basically you want it to show up like this?

"text more text and more eof"

I don't quite understand what you are going for here.
S
Spirit
Voice
Posts: 15
Joined: Sat Oct 11, 2003 5:57 am

Post by Spirit »

No, i want it like this:

text
more text
and more
eof

It is suppose to be a list of commands
it's not a bug - it's a feature!
D
Darkj
Halfop
Posts: 86
Joined: Sun Jul 06, 2003 9:58 pm

Post by Darkj »

Instead of hardcoding that in, I would just suggest using a file

Then to output it, just

Code: Select all

set fs [open file.txt r]
while {[gets $fs line]>-1} { 
set command [lindex [split $para] 0]
putserv "PRIVMSG $nick :$command"
}
Then in your file.txt, just list them like this
Text
more Text
and more
EOF
D
Darkj
Halfop
Posts: 86
Joined: Sun Jul 06, 2003 9:58 pm

Post by Darkj »

oh and a close $fs at the end of that
D
Darkj
Halfop
Posts: 86
Joined: Sun Jul 06, 2003 9:58 pm

Post by Darkj »

Just re-read the post, and say you were having trouble with not reading spaces

In my example, instead of this

Code: Select all

set command [lindex [split $para] 0]
go

Code: Select all

set command [lrange [split $para] 0 end]
Think thats right....
S
Spirit
Voice
Posts: 15
Joined: Sat Oct 11, 2003 5:57 am

Post by Spirit »

You are right ..its better to use a textfile for that, but i still got the old problem!
The bot is just posting the last word of every sentence!

Code: Select all

set cmdhelp "file.txt"

proc bsd:main {nick uhost hand chan para} {
    global cmdhelp
    if {![string length $para] > 0} {
      set fs [open $cmdhelp r]
      while {[gets $fs line] != -1} {
        putserv "PRIVMSG $nick $line"
      }
      close $fs
    }
}
I couldn't see, why you were using the

Code: Select all

set command [lindex [split $para] 0]
line, because it didn't do anything.

Does anybody know, why the bot is "loosing" the first part of every line?
it's not a bug - it's a feature!
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

try [join [lrange $data 0 end]] ; just and idea.
S
Spirit
Voice
Posts: 15
Joined: Sat Oct 11, 2003 5:57 am

Post by Spirit »

Thx, but i didn't help. It is pretty unusual.. is TCL reading the files different, than other languages?
Usually it should read the complete line and the bot should post it completely :-?
it's not a bug - it's a feature!
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

Spirit wrote:Thx, but i didn't help. [snip] :-?
But then again, you need to include a ":" when using a PRIVMSG.
S
Spirit
Voice
Posts: 15
Joined: Sat Oct 11, 2003 5:57 am

Post by Spirit »

Oh man, that did it!
Sorry ..i took it out *slapmyself* :wink:
Thx very much!!!
it's not a bug - it's a feature!
User avatar
CrazyCat
Revered One
Posts: 1359
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: cant post text to a user

Post by CrazyCat »

Sorry, I'm back on the beggining of the thread, but I'm affraid that
Spirit wrote:foreach {data} $msg_welcome {
should be better with:

Code: Select all

foreach data $msg_welcome {
S
Spirit
Voice
Posts: 15
Joined: Sat Oct 11, 2003 5:57 am

Post by Spirit »

Yep, you are right.
My script at the beginning was working in the first place.
The problem is, that i was using a "msg"-bind, which does not work with a proc that contains the "chan" variable.

Here are the final (and hopefully working :wink: ) scripts:

With a list ...

Code: Select all

set msg_welcome { 
  "Text" 
  "more Text" 
  "and more" 
  "EOF" 
} 

proc bsd:main {nick uhost hand chan para} { 
  global msg_welcome 
    if {![string length $para] > 0} { 
      foreach data $msg_welcome { 
        putserv "PRIVMSG $nick :$data"
      } 
    } 
} 
bind pub - !bsd bsd:main
..and the same function with a textfile which posts the contents of the file line by line..

Code: Select all

set exFile "c:\file.txt"

proc bsd:main {nick uhost hand chan para} { 
  global exFile
    if {![string length $para] > 0} { 
      set fs [open $exFile r] 
      while {[gets $fs line]>-1} { 
        putserv "PRIVMSG $nick :$line" 
      }
    } 
} 
bind pub - !bsd bsd:main
Greets!
it's not a bug - it's a feature!
Locked