| View previous topic :: View next topic |
| Author |
Message |
Bitto Voice
Joined: 07 Aug 2007 Posts: 3
|
Posted: Tue Aug 07, 2007 10:00 am Post subject: Script to call a php-script but not grabbing a parameter |
|
|
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: |
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? |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Tue Aug 07, 2007 12:51 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Bitto Voice
Joined: 07 Aug 2007 Posts: 3
|
Posted: Tue Aug 07, 2007 1:00 pm Post subject: |
|
|
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..:-/ |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Wed Aug 08, 2007 11:34 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Bitto Voice
Joined: 07 Aug 2007 Posts: 3
|
Posted: Thu Aug 09, 2007 2:59 am Post subject: |
|
|
| 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 :-/ |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu Aug 09, 2007 10:58 am Post subject: |
|
|
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: | 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, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|