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 

What Pulse script

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


Joined: 09 Jan 2006
Posts: 14

PostPosted: Sat Dec 01, 2007 9:43 pm    Post subject: What Pulse script Reply with quote

Trying to get this old Whatpulse script working again with the new web API but i can't seem to be able to fix it. The problem is that the old API was a txt output and the new one is an XML. This is the site where it needs to get the data from :
http://whatpulse.org/api/user.php?UserID=223348

This is the original version of the script -> http://pastebin.com/f35b6b778
Then i fiddled a bit with info from this forum and tutorials. I got it to to read the xml file and output something. But i can't seem to refine the output.

Working script till now -> http://pastebin.com/m34521008
Which outputs this -> http://pastebin.com/m53c44d46
But i can't figure out how i can get the output ^^ in to a nice format so i can deliver it to IRC how i want.

And below here is my try in getting something but that only messed up me script and makes it output errors in DCC instead of some nice output..

Code:

package require http
bind pub - !test pulse_get
proc pulse_get {n u h c t} {
  set x [::http::geturl http://whatpulse.org/api/user.php?UserID=223348]
     foreach line [split [::http::data $x] \n] {
       
    regsub -line {<AccountName>} set $AccountName {} AccountName
    regsub -line {<Country>} set $Country {} Country
    regsub -line {<DateJoined>} set $DateJoined {} DateJoined
    regsub -line {<Homepage>} set $Homepage {} Homepage
    regsub -line {<LastPulse>} set $LastPulse {} LastPulse
    regsub -line {<Pulses>} set $Pulses {} Pulses
    regsub -line {<TotalKeyCount>} set $TotalKeyCount {} TotalKeyCount
    regsub -line {<TotalMouseClicks>} set $TotalMouseClicks {} TotalMouseClicks
    regsub -line {<AvKeysPerPulse>} set $AvKeysPerPulse {} AvKeysPerPulse
    regsub -line {<AvClicksPerPulse>} set $AvClicksPerPulse {} AvClicksPerPulse
    regsub -line {<AvKPS>} set $AvKPS {} AvKPS
    regsub -line {<AvCPS>} set $AvCPS {} AvCPS
    regsub -line {<Rank>} set $Rank {} Rank
    regsub -line {<TeamID>} set $TeamID {} TeamID
    regsub -line {<TeamName>} set $TeamName {} TeamName
    regsub -line {<TeamMembers>} set $TeamMembers {} TeamMembers
    regsub -line {<TeamKeys>} set $TeamKeys {} TeamKeys
    regsub -line {<TeamClicks>} set $TeamClicks {} TeamClicks
    regsub -line {<TeamDescription>} set $TeamDescription {} TeamDescription
    regsub -line {<TeamDateFormed>} set $TeamDateFormed {} TeamDateFormed

       puthelp "privmsg $c :AccountName"   
       puthelp "privmsg $c :Country"
       puthelp "privmsg $c :DateJoined"
       puthelp "privmsg $c :Homepage"
       puthelp "privmsg $c :LastPulse"
       puthelp "privmsg $c :Pulses"
       puthelp "privmsg $c :TotalKeyCount"
       puthelp "privmsg $c :TotalMouseClicks"
       puthelp "privmsg $c :AvKeysPerPulse"
       puthelp "privmsg $c :AvClicksPerPulse"
       puthelp "privmsg $c :AvKPS"
       puthelp "privmsg $c :AvCPS"
       puthelp "privmsg $c :Rank"
       puthelp "privmsg $c :TeamID"
       puthelp "privmsg $c :TeamName"
       puthelp "privmsg $c :TeamMembers"
       puthelp "privmsg $c :TeamKeys"
       puthelp "privmsg $c :TeamClicks"
       puthelp "privmsg $c :TeamDescription"
       puthelp "privmsg $c :TeamDateFormed"
  }
}


I'm a total noob and i tried to read on about regsub an regexp the entire day but i still don't get any result so if anyone is able to help me, it would be greatly appreciated. Or gives me a few pointers in the right direction with how to separate each data field into its own variable.

Greetz ]x[
Back to top
View user's profile Send private message
tsukeh
Voice


Joined: 20 Jan 2005
Posts: 31

PostPosted: Sun Dec 02, 2007 6:41 am    Post subject: Reply with quote

Code:

package require http
bind pub - !test pulse_get
proc pulse_get {n u h c t} {
  set x [::http::geturl http://whatpulse.org/api/user.php?UserID=223348]
  set data [::http::data $x]

  regexp -- {<AccountName>([^<]+)} $data {} AccountName
  regexp -- {<Country>([^<]+)} $data {} Country
  regexp -- {<DateJoined>([^<]+)} $data {} DateJoined

  puthelp "privmsg $c :AccountName: $AccountName"   
  puthelp "privmsg $c :Country: $Country"
  puthelp "privmsg $c :DateJoined: $DateJoined"
}
Back to top
View user's profile Send private message
]x[
Voice


Joined: 09 Jan 2006
Posts: 14

PostPosted: Sun Dec 02, 2007 2:05 pm    Post subject: Reply with quote

OMG its working, thank you really much man. Now i can continue to fiddle and hopefully finish this script Smile a bit more.

Thanks again and i really appreciate this.
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