egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Simple allmusic.com trigger

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
liljim
Voice


Joined: 11 Dec 2007
Posts: 12

PostPosted: Tue Dec 11, 2007 7:18 pm    Post subject: Simple allmusic.com trigger Reply with quote

I would like a trigger script to return a search string for allmusic.com. The allmusic search string works as follows:

Artist: http://www.allmusic.com/cg/amg.dll?p=amg&sql=1:miles|davis
Album: http://www.allmusic.com/cg/amg.dll?p=amg&sql=2:kind|of|blue
Song: http://www.allmusic.com/cg/amg.dll?p=amg&sql=3:freddie|freeloader
Style: http://www.allmusic.com/cg/amg.dll?p=amg&sql=4:jazz
Label: http://www.allmusic.com/cg/amg.dll?p=amg&sql=5:columbia

As you can see, spaces need to be replaced by | and sql=# changes according to the search type. Ideally I'd like to have a trigger for each search type like this:

<user> !artist nine inch nails
<bot> Artist search: http://www.allmusic.com/cg/amg.dll?p=amg&sql=1:nine|inch|nails
<user> !song hurt
<bot> Song search: http://www.allmusic.com/cg/amg.dll?p=amg&sql=3:hurt

I've tried to learn how to do this myself and I'm sure it's very simple, but I just can't wrap my mind around it. Help would be greatly appreciated.
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Wed Dec 12, 2007 6:50 pm    Post subject: Reply with quote

Code:
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. Smile

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. Wink

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.


Last edited by speechles on Mon Dec 17, 2007 8:16 pm; edited 1 time in total
Back to top
View user's profile Send private message
liljim
Voice


Joined: 11 Dec 2007
Posts: 12

PostPosted: Thu Dec 13, 2007 12:14 am    Post subject: Reply with quote

Perfect. Thank you very much!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber