The file looks like this. http://hearthstonejson.com/json/AllSets.enUS.json
Code: Select all
,{"id":"EX1_116","name":"Leeroy Jenkins","type":"Minion","faction":"Alliance","rarity":"Legendary","cost":4,"attack":6,"health":2,"text":"<b>Charge</b>. <b>Battlecry:</b> Summon two 1/1 Whelps for your opponent.","flavor":"At least he has Angry Chicken.","artist":"Gabe from Penny Arcade","collectible":true,"elite":true,"mechanics":["Battlecry","Charge"]},{"id":"EX1_029","name":"Leper Gnome","type":"Minion","faction":"Neutral","rarity":"Common","cost":1,"attack":2,"health":1,"text":"<b>Deathrattle:</b> Deal 2 damage to the enemy hero.","flavor":"He really just wants to be your friend, but the constant rejection is starting to really get to him.","artist":"Glenn Rane","collectible":true,"mechanics":["Deathrattle"]},
Code: Select all
putlog "\[\0032hscard.tcl\003\] loaded"
bind pub - !hs hscard
# !hs leeroy
proc hscard {nick uhost hand chan hscard} {
if {$hscard == ""} { putserv "NOTICE $nick :!hs card" ;return 0 }
set fd [open "scripts/cards.json" r]
set cont [read $fd]
close $fd
foreach line [split $cont "\n"] {
if {[string match -nocase "*$hscard*" $line]} {
#regexp {.*?\"name\":\"$hscard\",(.*?)} $line - hs(name)
#putlog "$hs(name)"
putserv "PRIVMSG $chan :'$hscard' is in the file!"
set found 1 ; break
}
}
if {![info exists found]} {
putserv "PRIVMSG $chan :Text is not found.."
}
}
<bot> [Leeroy Jenkins]: 6/2: Cost: 4 - Usable by all classes - Charge. Battlecry: Summon two 1/1 Whelps for your opponent.[/code]
I don't know how to regexp/lsearch or whatever to read that one complete line that contains what i need.