/* MCF_SOUND.AMIRX
// $VER: MCF_SOUND.AMIRX 4.1 (29.07.96)
\\ Written by Donald T. Becker (dtbecker@prolog.net) IRC: StarDustr
// Please mail any bug reports/comments to the above address with a subject
\\ header of MCF.AMIRX.
//
\\ ** What to do with this file?
// Put this script in REXX:		It will be used by MCF.AMIRX.
*/

parse arg MCFenv Unick SoundPlayer SoundDir junk wavfile morejunk

xx = pos('01'x, wavfile)

if xx > 0						then
	wavfile = strip(left(wavfile, xx - 1), "B")

if wavfile = ""						then exit

FN = SoundDir || wavfile

address value(MCFenv)
xl       = pos(".", MCFenv) +1
Client   = substr(MCFenv, xl)
clipname = "NOSOUNDS." || Client
response = getclip(clipname)

if exists(FN)						then do
	if response < 5					then do
		"echo P="d2c(27)"««MCF»"  " "d2c(2)Unick d2c(2)"requests that you play"d2c(2) wavfile"."
		address command SoundPlayer ">nil:" FN
	end
	exit
end
trace
if response > 4			then response = response - 5

select
	when response = 4	then call FindUser()
	when response = 3	then "RAW PRIVMSG "Unick" :" || '01'x || "GETSOUND "wavfile || '01'x
	when response = 2	then "echo P="d2c(27)"««MCF»"  "Sound file"d2c(2) wavfile d2c(2)"not found!"
	when response = 1	then "RAW PRIVMSG "Unick" :Sound file"d2c(2) wavfile d2c(2)"not found!"
	otherwise		exit
end

exit

FindUser:

options results

getmynick
MyNick = upper(result)
ToNick = upper(Unick)

channels
ChList = upper(result)
if ChList = ""			then return

do chcnt = 1 by 1		until ChList = ""
	parse value ChList with chan ChList
	getusers chcnt
	ChUs = " " || upper(result) || " "
	
	if 0 = pos(MyNick, ChUs)		then iterate
	if 0 = pos(ToNick, ChUs)		then iterate

	"RAW PRIVMSG "chan" :!"Unick wavfile
	ChList = ""
end

return
