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 from a website

Help for those learning Tcl or writing their own scripts.
Post Reply
L
LiquidIce
Halfop
Posts: 48
Joined: Fri Jan 09, 2004 7:22 pm
Location: USA

reading from a website

Post by LiquidIce »

Is it possible to read a script from a website. Such as unreal ircd has remote includes function. can this be done by the bot or no?
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

yes

see any autoupdated script, for example spambuster
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
L
LiquidIce
Halfop
Posts: 48
Joined: Fri Jan 09, 2004 7:22 pm
Location: USA

Post by LiquidIce »

is it possible to read a tcl from website http://blah.net/somescript.tcl

source http://blah.net/somescript.tcl
???
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

not directly, but you could use http::geturl to get the script and eval its content.

Code: Select all

package require http 2.4

::http::geturl {http://blah.net/somescript.tcl} -command httploadscript

proc httploadscript {token} {
   if {[::http::ncode $token] == 200} {
       uplevel #0 [::http::data $token]
   } else {
       putlog "Failed to load file from website: [::http::error $token]"
   }
   ::http::cleanup $token
   return 0
}
use at your own risk, since if the content of the site changes and contains some bad code, someone might be able to takeover your bot.
Also note that the script will be loaded asyncron, meaning it will most likely be loaded at last (so put all source commands that require that script to be already loaded after the eval line).

Edit: eval -> uplevel like demond mentioned.
Last edited by De Kus on Sun Jan 08, 2006 10:25 am, edited 1 time in total.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

De Kus wrote:

Code: Select all

       eval [::http::data $token]
that won't work as intended, you are evaluating in a proc, not in the global context in which that script most likely expects to be evaluated; use [uplevel]
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
Post Reply