Command to fetch specific info

Hello guys
I wonder if it’s possible to create a command which can fetch the specific ranking of a tennis player from a pastebin list. For example this week’s top ten players are:

  1. Carlos Alcaraz
  2. Novak Djokovic
  3. Daniil Medvedev
  4. Holger Rune
  5. Casper Ruud
  6. Jannik Sinner
  7. Stefanos Tsitsipas
  8. Andrey Rublev
  9. Taylor Fritz
  10. Frances Tiafoe

and I would like a command called !rank player’s_last_name to respond in which ranking position the desired player is. Not only for the top ten though, I’d like to have one with the first 100 players in the world. Do you think it can be done? there’s a limit of characters in nighbot as you already know.

all at once, no… not just the limit in nightbot, but twitch has a 400 character limit too… 100 names could only be 4 characters long with no spaces in between…

The idea of the command is to bring up just one name, not the whole list.

sorry, i was hoping somebody else would jump in… i can try and mess with it, but i’m not really familiar with pastebin…but i would need a paste to play with, so pass one over and i’ll see what i can do ^^

Possible you can drop the pastebin that contains the data ?
I can give a shot.

Post reopened due to request

idk where this list is from, but is it possible to have the list with a special character after each name?
if u can get that i can do it, but as is, idk how i’d teach it to differentiate between players, if all names were only first and last i could do it by number of names, but some have 3 or 4 names for one player…

special character for example, how? maybe the number of the ranking and the name?
1 xplayer
2 xplayer and so on?

uh, could be any specific character… if u want it to look more natural maybe a comma or something… like…
name one,
name two,
etc…
or semicolon like…
name one ;
name two ;
etc…
as long as each line has the same one (the last line doesn’t need it, but not bad if it has it)

or even if the special character was before the name, that’d make a small part of the code easier actually… but the last one DOES need it if it’s before the name, like maybe…

#name one
#name two

as long as the character is the same on each line

something like this maybe? we could try it just with the top 10 players first
#1 Novak Djokovic
#2 Carlos Alcaraz
#3 Daniil Medvedev
#4 Jannik Sinner
#5 Andrey Rublev
#6 Stefanos Tsitsipas
#7 Alexander Zverev
#8 Holger Rune
#9 Hubert Hurkacz
#10 Taylor Fritz

sure, that will work ^^

Oh! I implemented this when you first asked, but my account was in jail so I couldn’t reply, and then I forgot.

Here’s some nightbot incantation to do what you want:

$(eval q="$(querystring)"; p=$(urlfetch json https://pastebin.com/raw/4tus3Z1H).split(","); i=p.findIndex(e => e.toLowerCase().includes(q.toLowerCase())); (i < 0) ? q + " is not in the top 100" : p[i] + " is in position " + (i + 1))

Right now it’s referencing a pastebin text at https://pastebin.com/raw/4tus3Z1H that I posted with quotes around your entire list, and commas between each player. It needs that format to split character names up effectively. If you replace the pastebin with updated standings, the command will still work.

Lookups could fail if the list has multiple players with the same last name! (It will always find the first player with that name in the list)

you’re a wizard, amazing command. One question, how many names can this list contain? is there a limit?

easily more than what you ever need.

I think each nightbot command has a time limit to run. if the text file gets too large, you might exceed the limit just by loading all the text. You can probably get a list of 1000 or more before hitting that time limit though!

it would just take to edit the pastebin list, not the actual command or am I wrong?

technically both, but the only thing u need to do to the command is update the pastebin link :wink:

yeah you’ll want to edit the pastebin link in the command when you first set the command in nightbot, to point to text that you control.

after that, updating the pastebin text is good enough!