This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

building a search feature... (part way there..)

Help for those learning Tcl or writing their own scripts.
Post Reply
d
dj-zath
Op
Posts: 134
Joined: Sat Nov 15, 2008 6:49 am
Contact:

building a search feature... (part way there..)

Post by dj-zath »

I know I'm probably biting off more than I can chew here, but here goes:

I'm basically trying to extract a line of text after a bind/call.. the text then is forewarded to an external application where its sorted and applied to a search..

for those who have been following my last posts.. I'm now trying to send a string to the RAC..

I have broken it down to the raw commands needed by the RAC that it looks for and can "parse" or insert the string in..

ROUGH code is as follows: mind you- its nowhere near complete or functioning but is included for the following discussion.

Code: Select all


bind pub - !find SrcPlay


proc    SrcPlay {args} {
          global RacIP RacPort Src input
          set Src [catch {[exec fetch -q -A -m -T 1 -o - "http://$RacIP:$RacPort/x/play.cgi?id=$input]}]
}

$input: an integer from the chat i.e. !find 25
Src playlist listing (not needed for this function but another one that goes with this (I haven't got that far yet!)

at the time of this posting, I'm sorta "swirled" on how I'm going to do the functions:

the feature will do 2 things:

1.. voiced chatters enter "!search line of text" and then will get a private window displaying the found results.. with numbers assigned to them (the RAC assigns numbers to the database entries based as an html sytle sheet.. parsing that will be a nightmare all in itself!) then they enter "!play number" to have their tune added to the playlist queue.. (of course I'll have to check the queue to make sure multiple entries are ignored)

again, this is a VERY rough layout.. open to discussion and changes!

-DjZ-
:) :)
Last edited by dj-zath on Fri Apr 10, 2009 3:34 pm, edited 1 time in total.
d
dj-zath
Op
Posts: 134
Joined: Sat Nov 15, 2008 6:49 am
Contact:

Post by dj-zath »

I sorta got this thing to work...

but I ran into a snag,

when I used a "!play" function in a pub bind, all worked properly..

when I changed it to a "bind msg" it bawked and dropped an error..

Tcl error [PlyReq]: wrong # args: should be "PlyReq nick uhost hand"

Code: Select all

bind msg - !play PlyReq
simple enough, no?

Code: Select all

proc  PlyReq {nick uhost hand chan arg} {
        global DetHI RacIP RacPort DetAP DetPY MyChan;
        putserv "PRIVMSG $nick :$arg submitted."
        #### more code here ####
}
My problem is I get flustered- then i get stupid!

I guess I'll sleep on this one perhaps and I'll then see the error of my ways!?

or maybe you can offer a suggestion or 2??

DjZ
:) :)
Last edited by dj-zath on Fri Apr 10, 2009 2:10 pm, edited 1 time in total.
r
raider2k
Op
Posts: 140
Joined: Tue Jan 01, 2008 10:42 am

Post by raider2k »

if you changed it from bind pub to bind msg, also according to the error you are getting, then you should change it since its your only way to go as stated in tcl-commands.doc ;)
(1) MSG
bind msg <flags> <command> <proc>
procname <nick> <user@host> <handle> <text>

Description: used for /msg commands. The first word of the user's
msg is the command, and everything else becomes the text argument.
Module: server
d
dj-zath
Op
Posts: 134
Joined: Sat Nov 15, 2008 6:49 am
Contact:

Post by dj-zath »

sorry, I couldn't quite follow your instructions...

thanks for the input in any event...

I changed "arg" to "text" in the proc token list.. about to test it now.. (booted the code as I'm writing this note)

and.....

same error!
  • Tcl error [PlyReq]: wrong # args: should be "PlyReq nick uhost hand chan arg"

I supose I shoud post the "problem" code... so, here goes...

Code: Select all

proc    PlyReq {nick uhost hand chan arg} {
        global DetHI RacIP RacPort DetAP DetPY MyChan;
        if {($arg == "")} {putquick "PRIVMSG $nick :Can't process \"nothing\" - aborting!"; return 0;};
        if {([regsub -nocase -all -- {[A-Z]} $arg "" arg] >= "1")} {putquick "PRIVMSG #$MyChan :Enter only numeric song identifiers - aborting!"; return 0;};
        if {($DetHI != "onair.gif")||($arg == "")||([catch {exec fetch -q  A -m -T 1 -o - "http://$RacIP:$RacPort/x/playlist.cgi?id=$arg"};])} {

        putquick "PRIVMSG $nick : Request query not submitted - Playout System is currently offline.";
        return 0;} else {if {($DetAP == "onair.gif")&&($DetPY == "offair.gif")} {catch {exec fetch -q -A -m -T 1 -o /dev/null "http://$RacIP:$RacPort/x/playing.cgi?c=play" >& /dev/null};};
        putquick "PRIVMSG $nick :Your request query: \#$arg has been submitted!";
        };
};
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Read a second time, msg bindings don't trigger within a channel, and thus has no channel. Remove the chan argument. text vs arg shouldn't matter (as long as you stay away from "args").
NML_375
d
dj-zath
Op
Posts: 134
Joined: Sat Nov 15, 2008 6:49 am
Contact:

Post by dj-zath »

hi NML:

yeah, I knew that much... hehe

I haven't got the error to go away (yet) for the meantime I just made the search list in a "notice" and then let them ise in-channel.. dirty, yeah.. but, unless, I can see what I'm doing WRONG here...

I actually got the first part working (to my surprise!) which was the HARDER side of this search thingy... the only thing I need to do is make it "see" the "ahead" playlist and then check that to make sure that a tune already qued isn't going to play..

okay I taken the "notice" out since it was not working too well.. back to the ssearch showing in a PM though they can't do anything in the PM itself..

DjZ
:) :)
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Right now, I'm not sure what you are asking help with..
Wasn't it the error of msg bindings not working due to improper argument list?

"Seeing ahead of playlist" - It's been quite a while since I played around with either icecast or shoutcast, but as I recall, the streaming server only knows what the sender tells it - which is what is currently playing.
NML_375
d
dj-zath
Op
Posts: 134
Joined: Sat Nov 15, 2008 6:49 am
Contact:

Post by dj-zath »

I found the problem to this error..

I was calling the proc "internally" using args...

in other words, you can't call a "bind" internally (since theres nothing to bind TO!)

the solution was to duplicate the proc - one with args and one without (the one without is caled by another proc internally, while the one with args was called by a bind pub)

I was a silly dork for not catching this one!

in either case, I abondoned that part of the idea.. but I have more issues.. like how to set a hand argument.. its easy, I'm sure and I'll have it figured out by the time you read this post! :-)


-DjZ-
:) :)
Post Reply