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.
Old posts that have not been replied to for several years.
Spirit
Voice
Posts: 15 Joined: Sat Oct 11, 2003 5:57 am
Post
by Spirit » Sun Oct 12, 2003 9:07 am
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
Thx for your help!
it's not a bug - it's a feature!
Darkj
Halfop
Posts: 86 Joined: Sun Jul 06, 2003 9:58 pm
Post
by Darkj » Sun Oct 12, 2003 9:35 am
that is way off, should be something like
Spirit
Voice
Posts: 15 Joined: Sat Oct 11, 2003 5:57 am
Post
by Spirit » Sun Oct 12, 2003 9:42 am
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!
Darkj
Halfop
Posts: 86 Joined: Sun Jul 06, 2003 9:58 pm
Post
by Darkj » Sun Oct 12, 2003 9:56 am
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.
Spirit
Voice
Posts: 15 Joined: Sat Oct 11, 2003 5:57 am
Post
by Spirit » Sun Oct 12, 2003 9:58 am
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!
Darkj
Halfop
Posts: 86 Joined: Sun Jul 06, 2003 9:58 pm
Post
by Darkj » Sun Oct 12, 2003 10:08 am
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
Darkj
Halfop
Posts: 86 Joined: Sun Jul 06, 2003 9:58 pm
Post
by Darkj » Sun Oct 12, 2003 10:10 am
oh and a close $fs at the end of that
Darkj
Halfop
Posts: 86 Joined: Sun Jul 06, 2003 9:58 pm
Post
by Darkj » Sun Oct 12, 2003 10:13 am
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....
Spirit
Voice
Posts: 15 Joined: Sat Oct 11, 2003 5:57 am
Post
by Spirit » Mon Oct 13, 2003 4:32 pm
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!
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Mon Oct 13, 2003 5:00 pm
try [join [lrange $data 0 end]] ; just and idea.
Spirit
Voice
Posts: 15 Joined: Sat Oct 11, 2003 5:57 am
Post
by Spirit » Mon Oct 13, 2003 5:09 pm
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!
egghead
Master
Posts: 481 Joined: Mon Oct 29, 2001 8:00 pm
Contact:
Post
by egghead » Mon Oct 13, 2003 5:14 pm
Spirit wrote: Thx, but i didn't help. [snip]
But then again, you need to include a ":" when using a PRIVMSG.
Spirit
Voice
Posts: 15 Joined: Sat Oct 11, 2003 5:57 am
Post
by Spirit » Mon Oct 13, 2003 5:17 pm
Oh man, that did it!
Sorry ..i took it out *slapmyself*
Thx very much!!!
it's not a bug - it's a feature!
CrazyCat
Revered One
Posts: 1359 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Tue Oct 14, 2003 4:24 am
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:
Spirit
Voice
Posts: 15 Joined: Sat Oct 11, 2003 5:57 am
Post
by Spirit » Wed Oct 15, 2003 3:53 am
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
) 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!