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.

Help: Topic -> PHP via URL-Call [Solved]

Help for those learning Tcl or writing their own scripts.
Post Reply
D
Dark_Lancer
Voice
Posts: 4
Joined: Wed Mar 01, 2006 1:34 pm

Help: Topic -> PHP via URL-Call [Solved]

Post by Dark_Lancer »

hi @ all

for first excuse my bad english. I'm very new in the TCL programming and I got a few Problems with my Windrop-Script.

Before I write down my code, here what I want the Script/Bot to do.

The Bot is sitting in a channel and wait for Topic-changes. If the Topic was changed he should catch it, build an URL to submit it to a PHP-module an makes an Simple URL-call. I got everything to work, only the URL-Call will not work. I added 2 "putlog"'s to see if the topic was catched correctly and if the http::formatQuery builds the end of the URL in the rigt way. Following my actual Script-Code.

Code: Select all

bind topc - * catch_topic

package require http

proc catch_topic {nick uhost handle chan topic} {
        global botnick url chantopic
		
        if {$chan == "#d2nsa.bt"} then {
 		set chantopic [topic #d2nsa.bt]
		set ::http(-useragent) {Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)}
		set url [::http::formatQuery "type" "topic" "info" $chantopic]
			
		set token [::http::geturl "http://www.allytool.d2nsa.de/submit.php" -query $url -timeout 5000]
			
		putlog "$url"
		::http::cleanup $token
		putlog "New topic: d2nsa.bt $chantopic"
		}
}
The URL i need to call look like this :

Code: Select all

http://www.allytool.d2nsa.de/submit.php?type=topic&info=$chantopic
Everythings works in an Test-channel, i get when I'm in a DCC-Chat with the Bot, the correct putlogs, but the logger for the PHP-modul shows me no URL-Call. Where s my mistake?

And there is another Question for me. The Topic in the Original Channel is Colored. When the Bot catch this i get an Error. I don't remember the complete Message, but it was like " Invalid Url". in the Putlog I see the coplete colored Topic. How can I strip the Colors out of the topic?

I know, these are a lot of questions, but maybe someone can help me.

Greets

Dark_Lancer
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

don't use the -query switch, it does POST and you need GET; so concatenate the result of [formatQuery] with your submit URL

see tcl-commands.doc for color-stripping proc; you can also use this:

Code: Select all

regsub -all {([\002\017\026\037]|[\003]{1}[0-9]{0,2}[\,]{0,1}[0-9]{0,2})} $text {} text
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
D
Dark_Lancer
Voice
Posts: 4
Joined: Wed Mar 01, 2006 1:34 pm

Post by Dark_Lancer »

Hi demond,

i made the changes you mentioned.

the part looks now like this:

Code: Select all

if {$chan == "#d2nsa.bt"} then {
 			set temptopic [topic #d2nsa.bt]
			set ::http(-useragent) {Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)}
			regsub -all {([\002\017\026\037]|[\003]{1}[0-9]{0,2}[\,]{0,1}[0-9]{0,2})} $temptopic {} chantopic
			set turl [::http::formatQuery "type" "topic" "info" $chantopic]
			set url "http://www.allytool.d2nsa.de/submit.php?$turl"
			set token [::http::geturl $url -timeout 10000]
			set status [::http::status $token]
			putlog "URL : $url"
			putlog "Status : $status"
			::http::cleanup $token
			putlog "New topic: d2nsa.bt $chantopic"
			}
The Putlog shows me the correct url now

Code: Select all

 URL : http://www.allytool.d2nsa.de/submit.php?type=topic&info=test2
but the putlog of $status gives me only a timeout

Code: Select all

Status : timeout
what i don't understand is, why i don't get the url-call showed in the PHP-logger. Could it be, because I'm sitting behind a proxy-server? Or do I need an other TCL-version or http.tcl?

Here the infos i got from windrop on startup

Code: Select all

Eggdrop v1.6.17 (C) 1997 Robey Pointer (C) 2004 Eggheads
[08:49] --- Loading eggdrop v1.6.17 (Thu Mar  2 2006)
[08:49] Modul geladen: dns
[08:49] Modul geladen: channels
[08:49] Modul geladen: server
[08:49] Modul geladen: ctcp
[08:49] Modul geladen: irc
[08:49] Modul geladen: notes            (mit Sprach-Unterstuetzung)
[08:49] Modul geladen: console          (mit Sprach-Unterstuetzung)
[08:49] Modul geladen: blowfish
[08:49] Modul geladen: uptime
[08:49] Script loaded: Catch_topics
[08:49] Userinfo TCL v1.07 loaded (URL BF GF IRL EMAIL DOB PHONE ICQ).
[08:49] use '.help userinfo' for commands.
[08:49] Identd: I don't know why you're using winident.tcl on your system, but i
t probably won't work on anything but Windows.
[08:49] winident.tcl v1.2 - by FireEgl@EFNet <FireEgl@Windrop.cjb.net> - Loaded.

[08:49] Userfile loaded, unpacking...
I think i'm gonna look for a newer TCL version.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

try to connect to your webserver from your shell via telnet on port 80

if you are unable to, so is your bot
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
D
Dark_Lancer
Voice
Posts: 4
Joined: Wed Mar 01, 2006 1:34 pm

Post by Dark_Lancer »

ok, i tried to connect via telnet, and it doesn't work.

How can I "recode" the script for Proxy use? In the Internet-options of internet-Explorer i have the settings for http/secure/ftp/gopher -proxy servers. http for example runs over port 8000.

Edit:

i think i found it.
http://tmml.sourceforge.net/doc/tcl/http.html
the http::config section, i think. i will try it on Monday
D
Dark_Lancer
Voice
Posts: 4
Joined: Wed Mar 01, 2006 1:34 pm

Post by Dark_Lancer »

so, i tried it.

and it works.

Thx for the help demond.

thread can be closed or [solved] ;)
Post Reply