Code: Select all
#nd script #
# Let your users search for artist and reply with genre and origin #
# Gets the data from metal-archives.com #
# Requirements: wget, iconv #
# Date: 2008-08-12 #
#####################################################################
bind pub - !band pub:band
proc pub:band {nick uhost hand chan arg} {
if {$arg == ""} {
putserv "PRIVMSG $chan :Usage : !band <name> | metal-archives.com"
return
}
#Take out the first letter
set letter [string range $arg 0 0]
set letter [string toupper $letter]
if {[string is digit $letter]} {
set letter "n"
}
#Get list of bands starting with that letter
if {[catch {exec wget -q -T 60 -t 1 -O - http://metal-archives.com/browseL.php?l=$letter} result]} {
putserv "PRIVMSG $chan :Error. couldn't reach metal-archives.com"
return
}
regsub -all -nocase {<br>} $result "\n" result2
set numberofartists 0
#Try to find the requested band
foreach line [split $result2 \n] {
if {[string match -nocase *\>$arg\<* $line]} {
set singleband $line
set numberofartists 1
} elseif {[string match -nocase *\>$arg\ \(*\<* $line]} {
regexp -nocase {<a(.*)>(.*)</a>} $line - donotcare line
lappend list $line
incr numberofartists
}
}
if {$numberofartists == 0} {
putserv "PRIVMSG $chan :Couldn't find that band"
} elseif {$numberofartists > 1} {
putserv "PRIVMSG $chan :There are several bands with that name. Type origin too."
set index 0
while {$index < $numberofartists} {
putserv "PRIVMSG $chan :[lindex $list $index]"
incr index
}
} elseif {$numberofartists == 1} { #Exactly one hit
regexp -nocase {<a href='(.*)'} $singleband - bandurl
if {[catch {exec wget -q -T 60 -t 1 -O - http://metal-archives.com/$bandurl} result]} {
putserv "PRIVMSG $chan :Error. couldn't reach metal-archives.com"
return
}
set list ""
regsub -all -nocase {<br>} $result "\n" result2
#Parse and extract the info we want
foreach line [split $result2 \n] {
if {[string match -nocase *</td* $line]} {
regsub -all {<([^<])*>} $line {} line
set line [string trim $line]
if {[string match (*) $line]} {
regexp -nocase {\((.*)\)} $line - town
set country "$country, $town"
set list [lreplace $list end end]
lappend list $country
} else {
if {[string match "" $line] != 1} {
lappend list $line
}
}
} elseif {[string match -nocase *browseC* $line]} {
regsub -all {<([^<])*>} $line {} line
set country [string trim $line]
lappend list $country
}
}
set endofinfo [lsearch $list Status*]
putserv "PRIVMSG $chan :\002[lindex $list 0]"
putserv "PRIVMSG $chan :[lindex $list 1]: [lindex $list 2]"
if {[string match -nocase *lyric* [lindex $list 3]]} {
putserv "PRIVMSG $chan :[lindex $list 3]: [lindex $list 4]"
set index 5
} else { #There's no info about lyrics. Skip it
set index 3
}
while {$index <= $endofinfo} {
putserv "PRIVMSG $chan :[lindex $list $index]: [lindex $list [expr $index+4]]"
incr index
}
#Find number of studio albums
set albums 0
foreach line [split $result2 \n] {
if {[string match -nocase *full-length* $line]} {
incr albums
}
}
if {$albums > 0} {
putserv "PRIVMSG $chan :Albums: $albums"
}
putserv "PRIVMSG $chan :URL: http://metal-archives.com/$bandurl"
}
}
putlog "Metal band script v1.0 loaded"
Code: Select all
if {[catch {exec wget -q -T 60 -t 1 -O - http://metal-archives.com/browseL.php?l=$letter} result]} {
Code: Select all
if {[catch {exec wget -q -T 60 -t 1 -O - http://metal-archives.com/$bandurl} result]} {
Code: Select all
# Metal v1.0 2013-04-07
# metal-archives.com script
# (cl)2013 speechles
#
# TO ENABLE IN YOUR CHANNEL:
# .chanset #yourchan +metal
#
# TO SEARCH:
# ( use -search )
# !metal *band -search
# !metal -search *band*
# !metal band* -search
# !metal -search band
#
# TO DISPLAY RESULTS:
# ( don't use -search )
# !metal *band
# !metal *band*
# !metal band*
# !metal band
#
# speechles was here :P
package require http
setudef flag metal
namespace eval metal {
variable metal
# ---> start config
# trigger character
set metal(pref) "!"
# command used to reply to user
# this can be a list of space delimited commands
set metal(commands) "metal m"
# amount user can issue before throttle
set metal(throttle) 2
# throttle time
set metal(throttle_time) 30
# how many max results to display in search
set metal(amount) 3
# how many max albums to show in results pages
set metal(albums) 3
# url to metal page
set metal(page) http://www.metal-archives.com/search/ajax-band-search/?field=name&query=
# display line for many results
set metal(many) "\002%total\002 bands (showing first %amount)"
# display line for a few results
set metal(few) "\002%total\002 bands"
# display line for search
set metal(search) "\002%name\002 - %genre (%location) @ %url"
# display for no results found in search
set metal(no_results) "Sorry %nick, there are no results for %search."
# display character for splitting things
set metal(split) " | "
# script version
set metal(version) "1.0"
# In the future, maybe more of the display will be customizable
# through the config, until then... dance like an robot ;)
# <--- config ends
}
Here's a replacement for that script. That one was clumsy, using exec and wget??!!. It isn't exactly portable that way, user friendly, nor is it economical. This one is platform independent. It also mixes ajax calls with html calls to be more efficient.from irc wrote:<speechles> !metal zoebea*
<bot> Zoebeast | Country of origin: Russia, Location: Saint Petersburg, Status: Active, Formed in: 2001, Genre: Death Metal/Grindcore, Lyrical themes: N/A, Current label: Coyote Records, Years active: 2001-present
<bot> Zoebeast | Members: ZDRCSD: Bass, Vocals; Professor: Drums; Enot: Guitars; Gorgonus: Guitars; Torden: Bass; Nik: Drums; Metallist: Drums; Kreator: Guitars (lead); Black Messiah: Guitars (lead); Dr. Death: Guitars (rhythm); Zaika: Vocals
<bot> Zoebeast | Albums: Incarnated Dreams; Full of Life; Unexpected Youth Pathology (...and 3 more)
<bot> Zoebeast | http://www.metal-archives.com/bands/Zoebeast/47781
<speechles> !metal zoebea* -search
<bot> 1 bands | Zoebeast - Death Metal/Grindcore (Russia) @ http://www.metal-archives.com/bands/Zoebeast/47781
<speechles> !metal zoebea*
<bot> 500 Ok ( http://www.metal-archives.com/search/aj ... =zoebea%2a )
<speechles> !metal zoebea* -search
<bot> speechles, you have been Throttled! You're going too fast and making my head spin!
I can't replicate that error. It works for me.Speechles can you try fix it?
http://ereader.kiczek.com/metal.tcl<speechles> !metal iron maiden
Iron Maiden | Country of origin: United Kingdom; Location: London, England; Status: Active; Formed in: 1975; Genre: Heavy Metal/NWOBHM; Lyrical themes: History, Literature, War, Mythology, Space; Current label: EMI Records; Years active: 1975-present
Iron Maiden | Members: Steve Harris: Bass, Keyboards (1975-present); Dave Murray: Guitars (1976-1977, 1977-present); Adrian Smith: Guitars (1980-1990, 1999-present); Bruce Dickinson: Vocals (1981-1993, 1999-present); Nicko McBrain: Drums (1982-present); Janick Gers: Guitars (1990-present); Ron "Rebel" Matthews: Drums (1975-1977); Dave Sullivan: Guitars (1975-1976); Terry Rance: Guitars (1975-1976); Paul Mario
Iron Maiden | Albums: The Soundhouse Tapes; Running Free; Iron Maiden (...and 107 more)
Iron Maiden | http://www.metal-archives.com/bands/Iron_Maiden/25
Code: Select all
Metal announcer.tcl v1.0 :: Http: 2.5.3;BotIsPatched: 0;EncodingSystem: iso8859-1;Tcl: 8.4;Eggdrop: 1.6.17;Suzi: NO
I did .rehash and i got this:If this _still_ isn't working. Please paste the "detail" line given to you when you sourced the script. Check your partyline for this line. If you just started the bot, get on partyline and .rehash and look for this line.
Code: Select all
metal announcer.tcl v1.0 loaded.