| View previous topic :: View next topic |
| Author |
Message |
Hamish Voice
Joined: 27 Mar 2006 Posts: 25
|
Posted: Tue Sep 19, 2006 11:58 am Post subject: Help with getting info from site |
|
|
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 |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue Sep 19, 2006 2:54 pm Post subject: |
|
|
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 |
|
 |
Hamish Voice
Joined: 27 Mar 2006 Posts: 25
|
Posted: Wed Sep 20, 2006 3:00 am Post subject: |
|
|
Cool, thanks.
Do you think you could help me with colours too? _________________ Thanks, Hamish. |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Wed Sep 20, 2006 9:00 am Post subject: |
|
|
| Hamish wrote: | Cool, thanks.
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 |
|
 |
Hamish Voice
Joined: 27 Mar 2006 Posts: 25
|
Posted: Wed Sep 20, 2006 11:10 am Post subject: |
|
|
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 |
|
 |
Nara Halfop
Joined: 23 Jul 2006 Posts: 40
|
Posted: Fri Sep 22, 2006 7:17 am Post subject: |
|
|
Cancel out the ( using a \ and the ) with a \. That should do it.
~Nara |
|
| Back to top |
|
 |
Hamish Voice
Joined: 27 Mar 2006 Posts: 25
|
Posted: Fri Sep 22, 2006 3:00 pm Post subject: |
|
|
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.  _________________ Thanks, Hamish. |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Fri Sep 22, 2006 4:45 pm Post subject: |
|
|
| 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.  |
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 |
|
 |
Hamish Voice
Joined: 27 Mar 2006 Posts: 25
|
Posted: Sun Sep 24, 2006 2:59 pm Post subject: |
|
|
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 |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Mon Sep 25, 2006 1:41 am Post subject: |
|
|
| 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 |
|
 |
|