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 

Help with getting info from site

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


Joined: 27 Mar 2006
Posts: 25

PostPosted: Tue Sep 19, 2006 11:58 am    Post subject: Help with getting info from site Reply with quote

Ok I got this so far:

Code:
bind pub - !stats stats:private

proc stats:private {nick uhost hand chan text} {
  set rsname [lindex $text 0]
  set site "http://*/stats2.php?name=$rsname"
  set token [::http::geturl $site]
  set content [::http::data $token]
  ::http::cleanup $content
  foreach line [split $content \n] {
    putserv "NOTICE $nick :Runescape hiscores lookup for $rsname"
    putserv "NOTICE $nick :$line"
  }
}


I get this error:

Quote:
-Bot- Runescape hiscores lookup for hamish150
-Bot- Overall: 970 Attack: 64 Defence: 60 Strength: 59 Hitpoints: 61 Ranged: 51 Prayer: 41 Magic: 50 Cooking: 62 Woodcutting: 56 Fletching: 34 Fishing: 61 Firemaking: 41 Crafting: 49 Mining: 55 Agility: 40 Thieving: 37 Slayer: 31
-Bot- Runescape hiscores lookup for hamish150


The site it connects is a single line containing the stats as shown in the second notice. What I need to do is, get rid of the third notice (the repeat of the the first one). I also need to know how to put it into colour, and, for the second notice to put all the words in darkred (5,0) and the numbers in darkblue (2,0).

I also need it so that if there are no numbers in $line it will return that the user's hiscores aren't ranked.

Also how would I be able to make it so that if the user types two words or more as a name, for example:

!stats jim bob jones

It will set $rsname as jim_bob_jones?

Thanks!
_________________
Thanks, Hamish.
Back to top
View user's profile Send private message Send e-mail
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Tue Sep 19, 2006 2:54 pm    Post subject: Reply with quote

Move the
Quote:

putserv "NOTICE $nick :Runescape hiscores lookup for $rsname"

before (outside) the loop (foreach) and should say that just once.
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
Hamish
Voice


Joined: 27 Mar 2006
Posts: 25

PostPosted: Wed Sep 20, 2006 3:00 am    Post subject: Reply with quote

Cool, thanks. Smile

Do you think you could help me with colours too?
_________________
Thanks, Hamish.
Back to top
View user's profile Send private message Send e-mail
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Wed Sep 20, 2006 9:00 am    Post subject: Reply with quote

Hamish wrote:
Cool, thanks. Smile

Do you think you could help me with colours too?

Colour and formatting codes
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
Hamish
Voice


Joined: 27 Mar 2006
Posts: 25

PostPosted: Wed Sep 20, 2006 11:10 am    Post subject: Reply with quote

Ok, rockon thanks.

I now have this, I have added some stuff for design reasons:

Code:
bind pub - !stats stats:private

proc stats:private {nick uhost hand chan text} {
  set rsname [lindex $text 0]
  set site "http://*/stats2.php?name=$rsname"
  set token [::http::geturl $site]
  set content [::http::data $token]
  ::http::cleanup $content
    putserv "NOTICE $nick :\0032,0(\0035,0Runescape hiscores lookup for\0032,0 $rsname)\003"
  foreach line [split $content \n] {
    putserv "NOTICE $nick :\0032,0(\0035,0$line\0032,0)\003"
  }
}


Ok, so now it looks nice but:

Quote:
-Bot- (Runescape Hiscores Lookup for hamish150)
-Bot- (Overall: 970 Attack: 64 Defence: 60 Strength: 59 Hitpoints: 61 Ranged: 51 Prayer: 41 Magic: 50 Cooking: 62 Woodcutting: 56 Fletching: 34 Fishing: 61 Firemaking: 41 Crafting: 49 Mining: 55 Agility: 40 Thieving: 37 Slayer: 31 )
-Bot- ()


What's with the extra ()?
_________________
Thanks, Hamish.
Back to top
View user's profile Send private message Send e-mail
Nara
Halfop


Joined: 23 Jul 2006
Posts: 40

PostPosted: Fri Sep 22, 2006 7:17 am    Post subject: Reply with quote

Cancel out the ( using a \ and the ) with a \. That should do it.

~Nara
Back to top
View user's profile Send private message
Hamish
Voice


Joined: 27 Mar 2006
Posts: 25

PostPosted: Fri Sep 22, 2006 3:00 pm    Post subject: Reply with quote

Ok, fixed up that (used string trim).
Now I have this code, it doesn't work, please tell me whats wrong with it.

Code:
proc stats:private {nick uhost hand chan text} {
  if {![lindex $text 0]} {
    set rsname $nick
  }
  else {
    set rsname [lindex $text 0]
  }
  set site "http://kewlbot.us.jerrcs.net/stats2.php?name=$rsname"
  set token [::http::geturl $site]
  set content [::http::data $token]
  ::http::cleanup $content
  putserv "NOTICE $nick :\0035,0Runescape\00314,0 Hiscores Lookup for \0035,0$rsname\00314,0:\003"
  set line [string trim $content]
  putserv "NOTICE $nick :\00314,0$line\003"
}


Basically if the user doesn't specify a name (!stats NAME) it just uses there nickname instead. Please help. Smile
_________________
Thanks, Hamish.
Back to top
View user's profile Send private message Send e-mail
rosc2112
Revered One


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

PostPosted: Fri Sep 22, 2006 4:45 pm    Post subject: Reply with quote

Hamish wrote:

Code:
proc stats:private {nick uhost hand chan text} {
  if {![lindex $text 0]} {
    set rsname $nick
  } else {
    set rsname [lindex $text 0]
  }


Basically if the user doesn't specify a name (!stats NAME) it just uses there nickname instead. Please help. Smile


That's because you have "set rsname $nick" there. If you want it to return an error msg or help msg, I'd change "if {[$lindex $text 0]}" to
Code:

if {$text == ""} {
    puthelp "PRIVMSG $nick :Please supply a name!";return
} else {

I would also suggest that you [split $text] to prevent problems with tcl special chars.
Back to top
View user's profile Send private message
Hamish
Voice


Joined: 27 Mar 2006
Posts: 25

PostPosted: Sun Sep 24, 2006 2:59 pm    Post subject: Reply with quote

Sorry I didn't explain very well, I need it to return the statistics for the persons nickname if they don't specify a name, for example:

Quote:
<RandomGuy> !stats
-Bot- Stats for RandomGuy
-Bot- Blablabla


Thanks.
_________________
Thanks, Hamish.
Back to top
View user's profile Send private message Send e-mail
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Mon Sep 25, 2006 1:41 am    Post subject: Reply with quote

Code:
proc stats:private {nick uhost hand chan text} {
  if {[set target [lindex [split $text] 0]] == ""} {
    set target $nick
  }
  set site "http://kewlbot.us.jerrcs.net/stats2.php?name=$target"
  set token [::http::geturl $site]
  set content [::http::data $token]
  ::http::cleanup $content
  putserv "NOTICE $nick :\0035,0Runescape\00314,0 Hiscores Lookup for \0035,0$target\00314,0:\003"
  set line [string trim $content]
  putserv "NOTICE $nick :\00314,0$line\003"
}
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