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.

reading a file into a "privmsg"

Old posts that have not been replied to for several years.
Locked
g
grinch157
Halfop
Posts: 42
Joined: Tue Nov 11, 2003 4:34 pm

reading a file into a "privmsg"

Post by grinch157 »

i'm trying to come up with a script that will read a text file into a privmsg. so when a user types lets say helpme, the text will be displayed in a privmsg box.. so far this is what i got..

bind -|- helpme proc_helpme
proc_helpme { nick uhost hand chan text } {
[open c:\test\test\test\test\tmp\filename.exe r] }
putserv "PRIVMSG %nick

but i do not think its right..
can someone help me?
User avatar
CrazyCat
Revered One
Posts: 1348
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: reading a file into a "privmsg"

Post by CrazyCat »

grinch157 wrote:

Code: Select all

bind -|- helpme proc_helpme
proc_helpme { nick uhost hand chan text } {
[open c:\test\test\test\test\tmp\filename.exe r] } 
putserv "PRIVMSG %nick 
First, I'm affraid you can't get a .exe....
Second: if your procedure ends before you send the PRIVMSG, it can't work
Third: You don't bind anything... I wonder you want to bind a pub
So try with a .txt and make this:

Code: Select all

bind pub - "helpme" proc_helpme
proc proc_helpme { nick uhost hand chan text } {
   set fo [open "c:\test\test\test\test\tmp\filename.txt r]
   while { ![eof $fo] } {
      gets $fo line
      putserv "PRIVMSG $nick :$line"
   }
   close $fo
}
Whith this, the eggdrop will read filename.txt to the user who begins his sentence with helpme in a channel.
g
grinch157
Halfop
Posts: 42
Joined: Tue Nov 11, 2003 4:34 pm

Post by grinch157 »

crazycat wrote

First, I'm affraid you can't get a .exe....
Second: if your procedure ends before you send the PRIVMSG, it can't work
Third: You don't bind anything... I wonder you want to bind a pub
So try with a .txt and make this:
Code:

bind pub - "helpme" proc_helpme
proc proc_helpme { nick uhost hand chan text } {

while { ![eof $fo] } {
gets $fo line
putserv "PRIVMSG $nick :$line"
}
close $fo
}
thats the idea i want a pub bind so the user just types the trigger and not in a phrase, so i took out the quotes there.

and i also got this error: Tcl error [proc_helpme]: extra characters after close-quote

which i figured it's because of :

Code: Select all

set fo [open "c:\test\test\test\test\tmp\filename.txt r]
so i put the end " at he end to finish but now i get this error:
Tcl error [proc_helpme]: couldn't open "c:testtesttesttesttmphelp.txt": no such file or directory.

why is this?
User avatar
]Kami[
Owner
Posts: 590
Joined: Thu Jul 24, 2003 2:59 pm
Location: Slovenia
Contact:

Post by ]Kami[ »

Try this:

Code: Select all

bind pub - !helpme proc_help
proc proc_help {nick uhost handle channel arg} { 
  set file file-name.txt
  if {![file exists $file]} {close [open $file w]} 
  set io [open $file r] 
  set list "" 
  while {![eof $io]} { 
    gets $io line 
    if {[string trim $line] == ""} {continue} 
    lappend list $line 
  } 
  close $io 
  set length [llength $list] 
  set message "$length match[expr {($length == "1")?"":"es"}] found:" 
  putserv "PRIVMSG $channel :$message" 
  foreach line $list { 
    putquick "PRIVMSG $channel :$line" 
  } 
}
If you will put like this, you must put file named file-name.txt in eggdrop directory..
User avatar
CrazyCat
Revered One
Posts: 1348
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

grinch157 wrote:

Code: Select all

set fo [open "c:\test\test\test\test\tmp\filename.txt r]
yes, \ is a special character, don't you know?
use \\ if you want a simple one :)
g
grinch157
Halfop
Posts: 42
Joined: Tue Nov 11, 2003 4:34 pm

Post by grinch157 »

well, i just wanted to know if i was missing somthing.

crazycat wrote :
yes, \ is a special character, don't you know?
use \\ if you want a simple one
i am new to this, but ???? i lost ya there.

the problem is that i guess it couldn't find the file.... and wanted to know what i did wrong....
User avatar
CrazyCat
Revered One
Posts: 1348
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Code: Select all

set fo [open "c:\test\test\test\test\tmp\filename.txt r]
must become:

Code: Select all

set fo [open "c:\\test\\test\\test\\test\\tmp\\filename.txt" r]
g
grinch157
Halfop
Posts: 42
Joined: Tue Nov 11, 2003 4:34 pm

Post by grinch157 »

okay,


if \ and \\ are special characters is there a place i can go to read on the and possibly other info on this sort, so i can get a better understanding of what i am doing here..??

and i really do appreciate the help(you have no idea) :)
User avatar
CrazyCat
Revered One
Posts: 1348
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

it may :)
try finding "escape characters" in perl or tcl/tk tutorials
g
grinch157
Halfop
Posts: 42
Joined: Tue Nov 11, 2003 4:34 pm

Post by grinch157 »

anyways the change to \\ worked!.. but is there a way to keep the the format of the file being read??
Locked