Code: Select all
setudef flag allmusic
bind pubm -|- "*" allmusic:reply
proc allmusic:reply {nick uhand hand chan input} {
# simple channel flag return if turned off
if {[lsearch -exact [channel info $chan] +allmusic] == -1} { return 0 }
switch [string tolower [lindex [split $input] 0]] {
!artist { putserv "PRIVMSG $chan :Artist search: http://www.allmusic.com/cg/amg.dll?p=amg&sql=1:[string map -nocase {" " "%20"} [join [lrange [split $input] 1 end]]]" }
!album { putserv "PRIVMSG $chan :Album search: http://www.allmusic.com/cg/amg.dll?p=amg&sql=2:[string map -nocase {" " "%20"} [join [lrange [split $input] 1 end]]]" }
!song { putserv "PRIVMSG $chan :Song search: http://www.allmusic.com/cg/amg.dll?p=amg&sql=3:[string map -nocase {" " "%20"} [join [lrange [split $input] 1 end]]]" }
!style { putserv "PRIVMSG $chan :Style search: http://www.allmusic.com/cg/amg.dll?p=amg&sql=4:[string map -nocase {" " "%20"} [join [lrange [split $input] 1 end]]]" }
!label { putserv "PRIVMSG $chan :Label search: http://www.allmusic.com/cg/amg.dll?p=amg&sql=5:[string map -nocase {" " "%20"} [join [lrange [split $input] 1 end]]]" }
default { return 0 }
}
}
#deny-word-wrap###############################################################################################################################################################
In and of itself, this is a very very basic beginning for you. You will still need to validate input and formulate some kind of flood protection.
What you have is the string map to change spaces to %20's which also works like your pipe's | do.. %20 is more logical to use in this case. Keep in mind you will more than likely need to trap bad user input (think people purposely trying to break your bot giving it invalid or special characters) during your input validation part and maybe lengthen the string map i've used in each switch to control them as well. You also have your switch for the different triggers. I used a single bind to * because it's easier to sort triggers with one proc, than to build several seperate ones. Not tested but should work, albeit with the minor problems mentioned above because I'm leaving some of the fun up to you in creating the script.
Edit: Added a simple chanset flag +/-allmusic. This way you can beter refine where this actually produces an output so as your tailoring this script it isn't possible for others to trigger it elsewhere if your bot resides in several channels. A helpful addition.
Remember to
1 source scripts/this-script.tcl in your eggdrop.conf,
2 .rehash,
3 then finally .chanset #yourchan +allmusic for this to work at all.