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.

php text grabbing tcl

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
spithash
Master
Posts: 249
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

php text grabbing tcl

Post by spithash »

let's say we have a www.example.com/test.php file on a website including the following, that randomly shows texts

Code: Select all

<html>

<head>
<title>mew mew mew moo</title>
</head>

<body>

<p style="background-color: #eeeeff; border: thin dashed; font-family: monospace; font-size: 115%; margin-left: 25%; padding: 1em; text-align: justify; width: 50%;">

Yo! First off I love the Lord Jesus. My name is Ron. I am a Freshman at 
Winona State. My family is really important to me. I'm not doing this to 
find a g/f. I just thought it would be funny and I like to meet new people. 
Peace out!
</p>

<p style="font-size: 70%; text-align: right;">

45ms

</p>

</body>

</html>
any help around to grab this using a !trigger?:

Code: Select all

Yo! First off I love the Lord Jesus. My name is Ron. I am a Freshman at 
Winona State. My family is really important to me. I'm not doing this to 
find a g/f. I just thought it would be funny and I like to meet new people. 
Peace out!
Last edited by spithash on Mon Jan 31, 2011 6:59 pm, edited 2 times in total.
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
User avatar
username
Op
Posts: 196
Joined: Thu Oct 06, 2005 9:20 am
Location: Russian Federation, Podolsk
Contact:

Post by username »

Try this:

Code: Select all

bind pub - !trigger parce
proc parce {nick uhost hand chan text} {
::http::config -urlencoding utf-8 -useragent "Mozilla/5.0 (X11; U; Linux i686; ru-RU; rv:1.8.1) Gecko/2006101023 Firefox/2.0"
set url [::http::geturl "http://www.example.com/test.php" -timeout 15000]
set data [::http::data $url]
::http::cleanup $url
regsub -all -- {\n} $data "" data;
regexp -nocase -- {<p .*?>(.*?)</p>} $data -> info
putserv "PRIVMSG $chan :$info"
}
Архив TCL скриптов для ботов Eggdrop/Windrop:
http://egghelp.ru/
User avatar
spithash
Master
Posts: 249
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

Post by spithash »

yo @username :)

it works awesomely, thing is (i just noticed, sorry) that some words randomly are bolded in a few quotes like this:

Code: Select all

<html>

<head>
<title>mew mew mew moo</title>
</head>

<body>

<p style="background-color: #eeeeff; border: thin dashed; font-family: monospace; font-size: 115%; margin-left: 25%; padding: 1em; text-align: justify; width: 50%;">

yo think if i got a real doll and had a voodoo priest do<strong style="color: #a00;"> [censored] </strong>to it, and 
attached lindsay lohan's soul to it, that if poke it she'd feel it and <strong style="color: #a00;">
[censored]?</strong>

</p>

<p style="font-size: 70%; text-align: right;">

1ms
</p>

</body>

</html>
so it fetches the bolding.coloring code aswell :(

considering [censored] are the bolded/colored words...
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
User avatar
spithash
Master
Posts: 249
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

Post by spithash »

[censored] can be any word.. it was just filtered by egghelp's forum bad word filter :P
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

regexp -nocase -- {<p .*?>(.*?)</p>} $data -> info 
Change this part above, to the part below.. :)

Code: Select all

regsub -all {<strong.*?>|</strong>} [regexp -nocase -- {<p .*?>(.*?)</p>} $data] "" info
If instead, you'd like to leave these words in bold. Change it to look like it is below this:

Code: Select all

regsub -all {<strong.*?>|</strong>} [regexp -nocase -- {<p .*?>(.*?)</p>} $data] "\002" info
User avatar
spithash
Master
Posts: 249
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

Post by spithash »

speechles, I got this:
[00:14:29] <@spithash> !test
[00:14:31] <@nagger> 1
after adding this

Code: Select all

regsub -all {<strong.*?>|</strong>} [regexp -nocase -- {<p .*?>(.*?)</p>} $data] "\002" info
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
User avatar
spithash
Master
Posts: 249
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

Post by spithash »

also I got another problem,

when the text is too long, it just cuts it off, it doesn't continue on a new line.. it just cuts it off :?
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
User avatar
username
Op
Posts: 196
Joined: Thu Oct 06, 2005 9:20 am
Location: Russian Federation, Podolsk
Contact:

Post by username »

Use this:

Code: Select all

bind pub - !trigger parce
proc parce {nick uhost hand chan text} {
::http::config -urlencoding utf-8 -useragent "Mozilla/5.0 (X11; U; Linux i686; ru-RU; rv:1.8.1) Gecko/2006101023 Firefox/2.0"
set url [::http::geturl "http://www.example.com/test.php" -timeout 15000]
set data [::http::data $url]
::http::cleanup $url
regsub -all -- {\n} $data "" data;
regexp -nocase -- {<p .*?>(.*?)</p>} $data -> info
regsub -all -- {<strong.*?>|</strong>} $info "\002" info;
while { $info != "" } { 
    putserv "PRIVMSG $chan :[string range $info 0 399]"
    set info [string range $info 400 end]
}
}
Архив TCL скриптов для ботов Eggdrop/Windrop:
http://egghelp.ru/
User avatar
spithash
Master
Posts: 249
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

Post by spithash »

...and it works awesomely!

I really thank you a LOT :D
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
User avatar
spithash
Master
Posts: 249
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

Post by spithash »

I just realized that it bolds EVERYTHING AFTER the bolded word on the website and the bolded word won't even appear... :?

The website I'm trying to fetch quotes from, is this:

http://rolloffle.churchburning.org/troll_me.php

not all quotes are word-bolded. if you refresh you will understand
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
User avatar
spithash
Master
Posts: 249
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

Post by spithash »

The code looks like this:

Code: Select all

setudef flag troll
bind pub - !troll parce
proc parce {nick uhost hand chan text} {
    if {[channel get $chan troll]} {
::http::config -urlencoding utf-8 -useragent "Mozilla/5.0 (X11; U; Linux i686; ru-RU; rv:1.8.1) Gecko/2006101023 Firefox/2.0"
set url [::http::geturl "http://rolloffle.churchburning.org/troll_me.php" -timeout 15000]
set data [::http::data $url]
::http::cleanup $url
regsub -all -- {\n} $data "" data;
regexp -nocase -- {<p .*?>(.*?)</p>} $data -> info
regsub -all -- {<strong.*?>|</strong>} $info "\002" info;
while { $info != "" } {
    puthelp "PRIVMSG $chan :[string range $info 0 399]"
    set info [string range $info 400 end]
    }
  }
}
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
User avatar
spithash
Master
Posts: 249
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

Post by spithash »

uhm,
for some reason the bot gives me this error and ping timeouts...
Warning: over maximum server queue!
or
Warning: over maximum help queue!
depending on what i use.. puthelp or putserv.

I read old posts about it but I couldnt find anything that might help me avoid this...
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
User avatar
spithash
Master
Posts: 249
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

Post by spithash »

Code: Select all

[11:52:55] <spithash> .tcl queuesize
[11:52:55] <nagger> Tcl: 0
I get this after I use this script :?

Code: Select all

Warning: over maximum help queue! 
anyone to enlightment me ?
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
User avatar
spithash
Master
Posts: 249
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

Post by spithash »

ok so, this worked:

Code: Select all

regsub -all -- {(<strong[^>]*>)|(</strong>)} $info "\002" info;
:)
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
a
adi2247
Voice
Posts: 10
Joined: Tue Nov 30, 2010 12:45 am

Post by adi2247 »

This script is fantastic! how can i make it check the site and post to chat every X min between the hours of X and Y?
Post Reply