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.

Script to call a php-script but not grabbing a parameter

Help for those learning Tcl or writing their own scripts.
Post Reply
B
Bitto
Voice
Posts: 3
Joined: Tue Aug 07, 2007 9:35 am

Script to call a php-script but not grabbing a parameter

Post by Bitto »

Hi,

after searching 4 days the forums and trying a few code-snippets, I am giving up and need some help on a tiny script.

1. I call a php-script:

http://mysite/irckey.php?nick=$nick&status=$userstatus

I got the nick but not the Status.

The Script:

Code: Select all


package require http

bind pub - !getkey get_key
set userstatus "0" 

proc getnick {nick host handle chan} {
 putquick "PRIVMSG nickserv :status $nick" 
}
proc get_key {nick host handle chan text} {
  global botnick getnick userstatus

  if {([string match -nocase "STATUS*3" $text])} {
  set userstatus "3" 
  }
  if {([string match -nocase "STATUS*1" $text])} {
  set userstatus "1" 
  }
  if {([string match -nocase "STATUS*0" $text])} {
  set userstatus "0" 
  }

set data [::http::geturl http://mysite/getkey.php?nick=$nick&status=$userstatus]

  foreach line [split [::http::data $data] \n] {
	 putquick "NOTICE $nick :$line"
	}
  ::http::cleanup $data
 } 

putlog "Key Announcer loaded"
It works without $userstatus but to prevent users for doing a simple nickchange, call !getkey before identify, I need to be shure, that the user is identified. STATUS 3 is that one, that provides the key, all other will just tell the user, that he has to identify before trigger.

I am absolute shure, that I have a mistake, because "set userstatus 'x'" seems to be empty. But I can't find it really...

can someone give me a hand with this please?
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

How are you getting the status before calling geturl? I'm assuming your php page is where you get the user status, but, the line you're using requires the var $userstatus before getting it from the webpage?

Otherwise, the status is always 0, as set in the global var "set userstatus"

The var $text will only contain whatever text you're passing along to the proc from the pub bind.

If your geturl only required a nick, then yeah you could get the status from that webpage and then do the other stuff in the proc to test it.
B
Bitto
Voice
Posts: 3
Joined: Tue Aug 07, 2007 9:35 am

Post by Bitto »

thx for answer..

so that means, I have nothing in $text...

I thinked, that proc getnick with the call putquick "PRIVMSG nickserv :status $nick" give me the response text where the "STATUS nick whatever" is in..I am wrong...

How do I get this response then into $text?

TCL is brandnew to me and while I am coding PHP since ages, I feel like a n00b to this..:-/
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

The question is, how are you getting the status at all? If you're trying to get the status from a webpage, obviously you cannot use a url requiring the status *beforehand*

http://mysite/irckey.php?nick=$nick&status=$userstatus

That expects you to already have the status when you make the geturl query.
B
Bitto
Voice
Posts: 3
Joined: Tue Aug 07, 2007 9:35 am

Post by Bitto »

rosc2112 wrote:The question is, how are you getting the status at all? If you're trying to get the status from a webpage, obviously you cannot use a url requiring the status *beforehand*

http://mysite/irckey.php?nick=$nick&status=$userstatus

That expects you to already have the status when you make the geturl query.
No.

I need the IRC-Status of the User, not from the Webpage (that would be much easier)

I try to get the Status from here:

proc getnick {nick host handle chan} {
putquick "PRIVMSG nickserv :status $nick"
}


because I need to know, if a user is registered AND identified. I pass this Information later to the http-call to sort out the correct response (what is later in $line)

The only thing I need to solve is the response from putquick "PRIVMSG nickserv :status $nick" for further use, but I did not get it :-/
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

You should be able to use the notc-binding to capture notices from your chanserv, I suppose.

Rough example to illustrate how to do it:

Code: Select all

bind notc - "*" notcproc
proc notcproc {nick uhost hand text {dest ""}} {
 if {$dest == ""} {set dest $::botnick}
 if {[string equal -nocase $nick "ChanServ"]} {
  #Got a reply from nickserv, response is within $text
  #Extract the relevant info, and insert it into your url..

 }
}
NML_375
Post Reply