Skip to content

Instantly share code, notes, and snippets.

@rxw1
Created April 23, 2020 16:25
Show Gist options
  • Save rxw1/09760b3acc88fe8fb1f389e7def193d0 to your computer and use it in GitHub Desktop.
Save rxw1/09760b3acc88fe8fb1f389e7def193d0 to your computer and use it in GitHub Desktop.
#!/bin/zsh
# vi: ft=sh
name=$1
heroes=(
abaddon
alchemist
ancient-apparition
anti-mage
arc-warden
axe
bane
batrider
beastmaster
bloodseeker
bounty-hunter
brewmaster
bristleback
broodmother
centaur-warrunner
chaos-knight
chen
clinkz
clockwerk
crystal-maiden
dark-seer
dark-willow
dazzle
death-prophet
disruptor
doom
dragon-knight
drow-ranger
earth-spirit
earthshaker
elder-titan
ember-spirit
enchantress
enigma
faceless-void
grimstroke
gyrocopter
huskar
invoker
io
jakiro
juggernaut
keeper-of-the-light
kunkka
legion-commander
leshrac
lich
lifestealer
lina
lion
lone-druid
luna
lycan
magnus
mars
medusa
meepo
mirana
monkey-king
morphling
naga-siren
natures-prophet
necrophos
night-stalker
nyx-assassin
ogre-magi
omniknight
oracle
outworld-devourer
pangolier
phantom-assassin
phantom-lancer
phoenix
puck
pudge
pugna
queen-of-pain
razor
riki
rubick
sand-king
shadow-demon
shadow-fiend
shadow-shaman
silencer
skywrath-mage
slardar
slark
snapfire
sniper
spectre
spirit-breaker
storm-spirit
sven
techies
templar-assassin
terrorblade
tidehunter
timbersaw
tinker
tiny
treant-protector
troll-warlord
tusk
underlord
undying
ursa
vengeful-spirit
venomancer
viper
visage
void-spirit
warlock
weaver
windranger
winter-wyvern
witch-doctor
wraith-king
zeus
)
a=($(print -l $heroes | grep $1))
if [[ $#a -gt 1 ]]; then
echo "multiple matches:"
print -l $a
return 1
fi
lanes () {
(
echo "LANE,PRESENCE,WIN_RATE,KDA_RATIO,GPM,XPM";
paste -d ',' \
<(echo -e "safe\noff\njungle") \
<(curl -s https://www.dotabuff.com/heroes/$a |\
pup 'td attr{data-value}' | head -n15 | sed 'N;N;N;N;s/\n/,/g')) | column -s, -t
}
counters () {
if [[ ! $NOHEADER == 1 ]]; then
printf "%-18s %6s %-4s\n" ${a:u} DADV WRATE
fi
# ?date=patch_7.26
curl -s "https://www.dotabuff.com/heroes/$a/counters" |\
pup '.counter-outline td attr{data-value}' |\
uniq |\
sed 'N;N;s/\n/,/g' |\
awk -F, '{
if (i<5) {
c="\033[31m";
$2=$2*-1;
} else {
c="\033[32m"
}
}{
gsub(" ", "-", $1);
printf("%s%-18s %6.2f %6.2f%s\n", c, tolower($1), $2, $3, "\033[0m");
i++
}'
}
if [[ $SORT == 1 ]]; then
echo
counters | sort -gk2r
echo
lanes
echo
else
echo
counters
echo
lanes
echo
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment