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.

let the bot parse to channel the complete source of a page

Old posts that have not been replied to for several years.
Locked
f
floris

let the bot parse to channel the complete source of a page

Post by floris »

Hi there,

I am really confused at how simple this is and still not being able to process this.

What I want:


<user> !data 15

[bot now goes to http://site.com/file.php?data=15]
[bot reads the COMPLETE page result and pastes in the channel]

<bot> Date: 15 == <result>


I noticed with google.tcl you can search for some string and regex out the middle and paste that, but even if I modify that, it always returns a 0.

I think I am better of with a script that parses on the <user> variable and reads out the whole content of that page (which is blank with just one or a few lines of results).


Would be great if someone has a default script for this or can explain to me in n00b steps what to do.
H
Hansje

Post by Hansje »

guess im not the only noob here :)
anyway, took a look at google.tcl and news updaters tcl scripts, how they grab stuff from a html or php page, but looks so complicated.
Was wondering, what would the tcl be
if lets say... www.blablabla.com was just saying : Under Construction
on the frontpage, and when i do !blablabla , it will look at www.blablabla.com and gives as output in channel: Under Construction
as well :s
Any help like a simple example.tcl would be appreciated :s
thx in advance
regards,
hansje
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Here is an short example on fetching some information from an certain web page via the http package. It should be installed by default in TCL 8.3 (at least at me is).

Code: Select all

set myurl www.bla.com

package require http

bind pub - !news my:news

proc my:news {nick uhost hand chan text} {
  global myurl
  set token [::http::geturl $myurl]
  set content [::http::data $token]
  ::http::cleanup $content
  # and now extract from $content only the stuff you want and do whatever you want with it.
}
Once the game is over, the king and the pawn go back in the same box.
H
Hansje

Post by Hansje »

thx m8
appreciate it!
f
floris

Post by floris »

If I want the whole $content to be posted in the channel i just do a privmsg #channel :$content

?
H
Hansje

Post by Hansje »

floris wrote:If I want the whole $content to be posted in the channel i just do a privmsg #channel :$content

?

blablabla.....
http::cleanup $data

putserv "PRIVMSG $chan : $content"

}



i think :)
f
floris

Post by floris »

That works great, final question:

[03:06] <@floris> !argh 1
[03:06] <+network> startstop

How can I set the 1 ?

so it can do www.site.com/file.php?blah=1 (blah = $argh)

I hope you understand.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Can you be more precisly what you mean? I fail to understand.. :P
Once the game is over, the king and the pawn go back in the same box.
f
floris

Post by floris »

I figured it out

set token [::http::geturl $myurl?username=$text]

this would let me add the $args part and return a value to the channel based on !request input.
U
UnknownZ

Post by UnknownZ »

Hallo, how about without using trigger? Could someone tell me how? The bot will just randomly select 2 lines of text in the file within 20 or 30 minutes each...

Thanks in advance
Locked