egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Bitto
Voice


Joined: 07 Aug 2007
Posts: 3

PostPosted: Tue Aug 07, 2007 10:00 am    Post subject: Script to call a php-script but not grabbing a parameter Reply with quote

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
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Tue Aug 07, 2007 12:51 pm    Post subject: Reply with quote

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
View user's profile Send private message
Bitto
Voice


Joined: 07 Aug 2007
Posts: 3

PostPosted: Tue Aug 07, 2007 1:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Wed Aug 08, 2007 11:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
Bitto
Voice


Joined: 07 Aug 2007
Posts: 3

PostPosted: Thu Aug 09, 2007 2:59 am    Post subject: Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Thu Aug 09, 2007 10:58 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber