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.

Sending text from a file to a channel

Help for those learning Tcl or writing their own scripts.
Post Reply
b
blake
Master
Posts: 201
Joined: Mon Feb 23, 2009 9:42 am
Contact:

Sending text from a file to a channel

Post by blake »

Hey

I wrote this some time back with a little help here on the forums i want to change it slightly

Currently I have to type !next line number in pm with the bot id like to get it so I only have to type !next and it will output the next line of text

Code: Select all

set out_chan "#Trainingroom" 
set txt_file "training.txt" 
bind msg SA|SA !next next_proc 
bind msg SA|SA !back back_proc 

proc tr_proc { nick uhost hand arg } { 
  global out_chan txt_file 
  set line [lindex [split $arg] 0] 
  if {$line == ""} { 
    putserv "PRIVMSG $chan :Usage: !next <line number>" 
    return 
  } 
  set take_me [open $txt_file r] 
  set take_all [split [read $take_me] "\n"] 
  close $take_me 
  set data [lindex $take_all [expr $line - 1]] 
  putquick "PRIVMSG $out_chan :$data" 
} 

proc back_proc { nick uhost hand arg } { 
  global out_chan txt_file 
  set line [lindex [split $arg] 0] 
  if {$line == ""} { 
    putserv "PRIVMSG $chan :Usage: !back <line number>" 
    return 
  } 
  set take_me [open $txt_file r] 
  set take_all [split [read $take_me] "\n"] 
  close $take_me 
  set data [lindex $take_all [expr $line - 1]] 
  putquick "PRIVMSG $out_chan :$data" 
} 
Many Thanks
Post Reply