Peace & Protection 4.00 — File Browser
PeaceProtection4.00v4.0 / PeaceProtection4.00v4.0 / ADDONS / SOUND2.MRC
SOUND2.MRC — 23.64 KB — Download this file
; #= ppsound -rs
; ########################################
; Peace & Protection
; Sound (standard addon) part 2
; ########################################
; sound type config
alias scfg _dialog -am stypes stypes
dialog stypes {
title "Sound Types"
size -1 -1 250 178
text "Double-click on a sound type to edit settings, or add and remove types as needed.", 1, 10 10 220 30
list 2, 10 45 150 135, sort
button "Settings", 10, 170 46 70 25, default
button "Add type", 11, 170 78 70 25
button "Remove", 12, 170 110 70 25
button "Close", 13, 170 142 70 25, cancel
}
on *:DIALOG:stypes:init:*:_freshenst $dname 2
alias _freshenst {
did -r $1 $2
if ($exists($_cfg(sound.ini)) == $false) return
window -hl @.stypes
filter -fw $_cfg(sound.ini) @.stypes [*]
if ($fline(@.stypes,[reverse],1,0)) dline @.stypes $ifmatch
if ($fline(@.stypes,[opt],1,0)) dline @.stypes $ifmatch
var %type,%num = 1
:loop
if ($line(@.stypes,%num)) {
%type = $right($left($ifmatch,-1),-1)
did -a $+ $iif(%type == $3,c) $1 $2 $_desc(%type) ( $+ $_s2cs($_scfg(%type,ext)) $+ )
inc %num | goto loop
}
window -c @.stypes
}
alias _selstype var %line = $did($1,$did($1).sel) | if ($chr(32) !isin %line) { if ($2) return | $$$ } | %line = $remove($gettok(%line,$numtok(%line,32),32),$chr(40),$chr(41),$chr(44)) | if ($_scfg(reverse,%line)) return $ifmatch | _error Error locating sound type for %line Your sound.ini may be corrupted
on *:DIALOG:stypes:dclick:2:_juryrig _stype s $_selstype(2) $dname
on *:DIALOG:stypes:sclick:10:_juryrig _stype s $_selstype(2) $dname
on *:DIALOG:stypes:sclick:11:{
if (($_scfg(mp3,ext)) && ($_scfg(wav,ext)) && ($_scfg(mid,ext))) _juryrig _stype a - $dname
else _juryrig _stype a $$!dialog(deftypes,deftypes,-4) $dname
}
on *:DIALOG:stypes:sclick:12:_juryrig _stype r $_selstype(2) $dname
alias _stype {
if ($1 == r) {
_okcancel 0 Delete sound type ' $+ $2 $+ '? This cannot be undone.
var %ext = $_scfg($2,ext),%num = $numtok(%ext,32)
:loop
remini $_cfg(sound.ini) reverse $gettok(%ext,%num,32)
if (%num > 1) { dec %num | goto loop }
remini $_cfg(sound.ini) $2
.remove $_cfg($2_indx.dat)
did -d $3 2 $did($3,2).sel
}
else {
if ($dialog(scfg)) { dialog -v scfg | return }
var %type = $2,%fresh = $3
dialog -am scfg scfg
}
}
dialog deftypes {
title "Add Sound Type"
size -1 -1 400 68
text "Select a default file type or 'other' to create your own:", 201, 14 12 280 20
button "&MP3", 101, 13 40 65 25
button "&Wave", 102, 88 40 65 25
button "Mi&di", 103, 163 40 65 25
button "&Other", 104, 238 40 65 25, OK
button "&Cancel", 105, 313 40 65 25, cancel
edit "-", 1, 1 1 1 1, result hide
}
on *:DIALOG:deftypes:init:*:{
if ($_scfg(mp3,ext)) did -b $dname 101
if ($_scfg(wav,ext)) did -b $dname 102
if ($_scfg(mid,ext)) did -b $dname 103
}
on *:DIALOG:deftypes:sclick:*:if ($did isnum 101-103) { did -o $dname 1 1 $gettok(mp3 wav mid,$calc($did - 100),32) | dialog -k $dname }
dialog scfg {
title "Sound Configuration"
size -1 -1 430 235
check "Options", 203, 10 10 80 25, push
check "Directories", 204, 100 10 80 25, push
check "Player", 205, 190 10 80 25, push
box "Options:", 1, 10 44 410 144, hide
text "Sound type:", 2, 10 64 85 16, right hide
edit "", 3, 100 60 190 22, autohs hide result
text "Extensions:", 4, 10 89 85 16, right hide
edit "", 5, 100 85 190 22, autohs hide
text "Default action:", 8, 10 114 85 16, right hide
edit "", 9, 100 110 310 22, autohs hide
text "With desc.:", 10, 10 139 85 16, right hide
edit "", 11, 100 134 310 22, autohs hide
check "Always ask for description", 12, 40 161 170 20, hide disable
check "Use ID3 tags for description", 13, 220 161 200 20, hide
box "Directories:", 14, 10 44 410 141, hide
list 15, 20 64 310 90, sort hide
button "Add", 16, 338 66 70 25, hide
button "Remove", 17, 338 106 70 25, hide
check "Index files (requires preparation but speeds searching)", 18, 30 155 300 20, hide
button "Auto find...", 19, 338 146 70 25, hide disable
box "Player:", 20, 10 44 410 148, hide
check "Use mIRC's built-in wave / midi playing", 21, 20 63 200 20, hide
button "", 22, 20 89 390 25, hide
check "Minimize player", 23, 20 119 140 20, hide
check "Have mIRC grab focus after playing", 24, 180 119 200 20, hide
check "Use short (8.3) filenames", 25, 20 139 140 20, hide
check "Use playlist even for single files", 26, 180 139 200 20, hide
check "Play sounds when others play them", 29, 180 162 200 20, hide
button "OK", 201, 50 200 80 25, OK default
button "Cancel", 202, 200 200 80 25, cancel
edit "", 100, 1 1 1 1, hide autohs
edit %type, 101, 1 1 1 1, hide autohs
edit %fresh, 102, 1 1 1 1, hide autohs
check "", 103, 1 1 1 1, hide
}
on *:DIALOG:scfg:init:*:{
var %type = $did(101),%player,%num = 1
if ($_scfg(%type,ext) == $null) {
if ((%type == wav) || (%type == mid)) %player = /splay
if (%type == mp3) {
var %extra = &time& (&bitrate&kbps &khz&kHz &stereo&)
did -c $dname 13,23
}
else {
var %extra = &size&
if (%type == wav) did -a $dname 15 $wavedir
elseif (%type == mid) did -a $dname 15 $mididir
did -c $dname 29
}
did -a $dname 9 &play& $!_u() &file& $!_u() %extra $!_u()
did -a $dname 11 &play& $!_u() &desc& $!_u() %extra $!_u()
if ($findtok(wav mid mp3,%type,1,32)) {
did -a $dname 3 $gettok(Wave MIDI MPEG,$ifmatch,32)
did -a $dname 5 $gettok(wav.mid.mp2 mp3,$ifmatch,46)
if (%type == mp3) did -a $dname 26 m3u
}
did -c $dname 18
}
else {
%player = $_scfg(%type,player)
did -a $dname 3 $_scfg(%type,desc)
did -a $dname 5 $_scfg(%type,ext)
did -a $dname 9 $_readprep($_scfg(%type,msg))
did -a $dname 11 $_readprep($_scfg(%type,msgdesc))
if ($_scfg(%type,index)) did -c $dname 18
if ($_scfg(%type,minimize)) did -c $dname 23
if ($_scfg(%type,jukebox)) did -c $dname 29
}
if ((%type != wav) && (%type != mid)) did -b $dname 21
if (%type != mp3) did -b $dname 13
elseif ($_scfg(%type,autodesc)) did -c $dname 13
did -a $dname 22 (windows default)
if (%player == /splay) { did -c $dname 21 | did -b $dname 22,23,24,25,26 }
elseif (%player) did -a $dname 22 %player
if ($_scfg(%type,grabfocus)) did -c $dname 24
if ($_scfg(%type,shortfn)) did -c $dname 25
if ($_scfg(%type,listone)) did -c $dname 26
:loop
if ($_scfg(%type,dir [ $+ [ %num ] ] )) {
did -a $dname 15 $ifmatch
inc %num | goto loop
}
if ($_dlgi(scfg) isnum 203-205) _scfgsec $ifmatch
else _scfgsec 203
}
on *:DIALOG:scfg:sclick:21:did $iif($did(21).state,-b,-e) $dname 22,23,24,25,26
on *:DIALOG:scfg:sclick:22:if ($did(22) == (windows default)) _juryrig _scfgpls $did(22) | else did -a $dname 22 (windows default)
alias _scfgpls did -a scfg 22 $$dir="Select player" c:\*.exe
on *:DIALOG:scfg:dclick:15:_juryrig _scfgad -co $$did(15,$did(15).sel)
on *:DIALOG:scfg:sclick:16:_juryrig _scfgad -ca c:\
on *:DIALOG:scfg:sclick:17:if ($did(15).sel) { did -d $dname 15 $did(15).sel | did -c scfg 103 }
alias _scfgad did $1 scfg 15 $iif($1 == -co,$did(scfg,15).sel) $$sdir="Directory to add?" $2- | did -c scfg 103
alias _scfgw if ($3 == $null) remini %.file $1 $2 | else writeini %.file $1 $2 $3-
on *:DIALOG:scfg:sclick:201:{
set -u %.file $_cfg(sound.ini)
if ($did(3) == $null) _error You must enter a sound type
var %old,%exts = $remove($replace($_c2s($did(5)),;,$chr(32)),.),%num = $numtok(%exts,32)
if (%exts == $null) _error You must enter at least one extension
if ((* isin %exts) || (? isin %exts)) _error Cannot use wildcards in extensions
:loope
%old = $_scfg(reverse,$gettok(%exts,%num,32))
if ((%old != $null) && (%old != $did(101))) _error Extension $gettok(%exts,%num,32) is already usedIt is currently reserved for %old files
if (%num > 1) { dec %num | goto loope }
if ($did(101) == -) did -o $dname 101 1 $gettok(%exts,1,32)
else {
%old = $_scfg($did(101),ext)
%num = $numtok(%old,32)
:loopd
if (%num) { remini %.file reverse $gettok(%old,%num,32) | dec %num | goto loopd }
}
%num = $numtok(%exts,32)
:loopa
_scfgw reverse $gettok(%exts,%num,32) $did(101)
if (%num > 1) { dec %num | goto loopa }
_scfgw $did(101) desc $did(3)
_scfgw $did(101) ext %exts
_scfgw $did(101) msg $_writeprep($did(9))
_scfgw $did(101) msgdesc $_writeprep($did(11))
_scfgw $did(101) autodesc $did(13).state
if ($did(21).state) _scfgw $did(101) player /splay
elseif ($did(22) == (windows default)) _scfgw $did(101) player
else _scfgw $did(101) player $did(22)
_scfgw $did(101) minimize $did(23).state
_scfgw $did(101) grabfocus $did(24).state
_scfgw $did(101) shortfn $did(25).state
_scfgw $did(101) listone $did(26).state
_scfgw $did(101) jukebox $did(29).state
%num = 1
:loop
if ($did(15,%num)) {
_scfgw $did(101) dir $+ %num $ifmatch
inc %num | goto loop
}
:loop2
if ($_scfg($did(101),dir [ $+ [ %num ] ] )) {
_scfgw $did(101) dir $+ %num
inc %num | goto loop2
}
_freshenst $did(102) 2
; $_not used so that 1 and 1 match, 0 and 0 match, AND 0 and null match
if ($_not($did(18).state) != $_not($_scfg($did(101),index))) _juryrig _reqrei $did(101) $did(18).state
elseif (($did(18).state) && ($did(103).state)) _juryrig _reqrei $did(101) 2
_scfgw $did(101) index $did(18).state
_dlgw scfg $did(100)
}
alias _reqrei {
if ($_okcancel(1,$gettok(You have disabled indexing- delete index file?.You have enabled indexing- Index files now?.You have modified directories- Reindex now?.Creating filelists is done during indexing- Reindex now?,$calc($2 + 1),46))) {
if ($2) reindex $1
else .remove $_cfg($1_indx.dat)
}
}
on *:DIALOG:scfg:sclick:*:if ($did > 202) _scfgsec $did
alias -l _scfgsec {
var %sets
%sets = 1,2,3,4,5,8,9,10,11,12,13 14,15,16,17,18,19 20,21,22,23,24,25,26,29
; select radio btn
if ($did(scfg,100) isnum) {
did -u scfg $did(scfg,100)
did -h scfg $gettok(%sets,$calc($did(scfg,100) - 202),32)
}
did -o scfg 100 1 $1
did -c scfg $1
did -v scfg $gettok(%sets,$calc($1 - 202),32)
}
; /reindex type
; Reindexes sounds, retains ratings and descriptions
; indx_mp.dat (tabbed- filename, then rating as a color, then desc)
; alphabetical by filename
; also creates nick.txt in main dir if @nick is on
;;; 32-bit only
alias reindex {
; List all current files
var %ext = $_scfg($1,ext)
if (%ext == $null) _error Unrecognized sound file type- $1 $+ See sound configuration for recognized file types.
if ($_not($_scfg($1,index))) _error You do not have $_desc($1) files indexed.See sound configuration if you want to enable indexing.
_resetleech
writeini " $+ $scriptdir $+ reindex.ini" script n1 % $+ .fext = %ext $chr(124) % $+ .trig.type = %`sound.trigtype $chr(124) % $+ .type = $1 $chr(124) % $+ .userdir = $mircdir $+ $_cfg $chr(124) % $+ .sdesc = $_desc($1) $chr(124) % $+ .textlist = $mircdir $+ $_repl.fn($me) $+ - $+ $1 $+ .txt $chr(124) % $+ .leechcmd = $gettok(%!leechcmds,1,32)
writeini " $+ $scriptdir $+ reindex.ini" rfiles n0 $scriptdir $+ reindex.ini
writeini " $+ $scriptdir $+ reindex.ini" rfiles n1 $scriptdir $+ reindex.ini
writeini " $+ $scriptdir $+ reindex.ini" rfiles n2 $scriptdir $+ reindex.ini
if (%`sound.textfile) .remove %`sound.textfile
if (%`sound.trigtype == $1) `set sound.textfile $_repl.fn($me) $+ - $+ $1 $+ .txt
run $mircexe -i" $+ $scriptdir $+ reindex.ini"
.timer.grabfocus 4 1 if ($appactive == $!false) $chr(123) showmirc -s $chr(124) .timer.grabfocus off $chr(125)
}
; Queueing
; /squeue [file.ext|n|next|prev|start|stop|close|-n]
alias squeue {
if (($1- == close) || ($1- == close @Queue)) {
.timer.squeue off
window -c @Queue
if ($dialog(sndpanel)) {
did -u sndpanel 9
did -ra sndpanel 10 Continuous play
}
return
}
if ($window(@Queue) == $null) {
if (($1- == next) || ($1- == prev) || ($1- == stop)) return
if ($1- isnum) _error Queue is not running.Cannot select a line to play.
_validsta
_window 2 $iif($1- == -n,-nl,-l) -t7,13 @Queue $_winpos(8,12,10,10) @Queue
_windowreg @Queue squeue close
if ($dialog(sndpanel)) {
did -c sndpanel 9
did -ra sndpanel 10 Repeat queue
}
}
if (($1- == $null) || ($1- == -n)) return
if (($1- == next) || ($1- == prev)) {
if ($fline(@Queue,(play)*,1,0)) {
if (($ifmatch == $line(@Queue,0)) && ($1 == next) && (%_s.cont)) _recurse squeue 1
else _recurse squeue $calc($fline(@Queue,(play)*,1,0) + $iif($1 == next,1,-1))
}
elseif ($1 == next) _recurse squeue 1
else .timer.squeue off
return
}
if (($1- == stop) || ($1- isnum)) {
.timer.squeue off
var %oldext
if ($fline(@Queue,(play)*,1,0)) {
%oldext = $_sext($gettok($line(@Queue,$ifmatch),3,9))
rline $colour(not) @Queue $ifmatch $puttok($line(@Queue,$ifmatch),(done),1,9)
}
if (($1 isnum) && ($numtok($line(@Queue,$1),9) > 2)) {
if ((%oldext) && (%oldext != $_sext($gettok($line(@Queue,$1),3,9)))) loc %oldext stop
rline $colour(c) @Queue $1 $puttok($line(@Queue,$1),(play),1,9)
_validst -a
sound %`soundtarg " $+ $gettok($line(@Queue,$1),3,9) $+ " -
var %time = $gettok($line(@Queue,$1),2,9)
if (: isin %time) .timer.squeue -o 1 $calc($gettok(%time,2,58) + 60 * $gettok(%time,1,58) + 3) squeue next
else .timer.squeue -o 0 3 if (($inmidi == $!false) && ($inwave == $!false)) squeue next
}
elseif (%oldext) loc %oldext stop
return
}
if ($1- == start) {
if ($fline(@Queue,(play)*,1,0)) return
if ($fline(@Queue,(done)*,0,0) == $line(@Queue,0)) _recurse squeue 1
else _recurse squeue $fline(@Queue, *,1,0)
return
}
if ($exists($1-) == $false) _error File not found- $1- $+ Cannot queue.
var %type = $_sext($1-)
if (%type == $null) _error Can't queue $1- $+ Filetype is unrecognized.
if (%type == mp3) { mp3.prep $1- | aline @Queue $+ $_stime($mp3.time($1-)) $+ $+ $1- }
elseif (((%type == wav) || (%type == mid)) && ($_scfg(%type,player) == /splay)) aline @Queue $+ $1-
else _error Can't queue $1- $+ Only MPs, wavs, and midis are queueable.
window -b @Queue
}
menu @Queue {
dclick:if ($gettok($line($active,$1),1,9) == (play)) squeue stop | else squeue $1
$_isstype:{ }
Play...:loc *
Random...:loc -c * *
Find...:loc * "* $+ $replace($_entry(0,$null,Find song(s) containing what words?),$chr(32),*) $+ *"
-
Options
.$_dynpop(%_s.cont) Continuous play:scont *
.$_dynpopf Playing to... %.isstarg:starg
Type
.%.isstype1:_isstype 1
.%.isstype2:_isstype 2
.%.isstype3:_isstype 3
.%.isstype4:_isstype 4
.%.isstype5:_isstype 5
.%.isstype6:stype
.-
.$_dynpopf Reindex current:_validstp | reindex %`soundtype
-
Previous:squeue prev
Next:squeue next
$iif($fline($active,(play)*,1,0),Stop,Resume):if ($fline($active,(play)*,1,0)) squeue stop | else squeue start
-
Edit
.$iif($sline($active,1).ln,Remove):_pldo $active -r
.-
.$iif($sline($active,1).ln,Up):_doslideup $active 1
.$iif($sline($active,1).ln,Down):_doslidedn $active
.$iif($sline($active,0).ln > 1,Shuffle selected):_doshuffle $active 1
.$iif($sline($active,0).ln < 2,Shuffle all):_doshufflea $active 1
.-
.Create playlist:{
var %num = 1,%win = $_newwin(@Playlist),%old = $active
_window 2.4 -l -t1,46 %win $_winpos(8,12,10,10) @Playlist
_plban %win
:loop
if ($line(%old,%num)) {
aline %win $gettok($ifmatch,3,9)
inc %num | goto loop
}
_plupdt %win
}
}
dialog stype {
title "Sound Type"
size -1 -1 140 155
text "Play sounds of type:", 1, 3 3 130 20
list 2, 0 24 140 110, sort
button "Select", 3, 21 131 97 21, default OK
edit "", 4, 1 1 1 1, hide result autohs
}
on *:DIALOG:stype:init:*:_freshenst $dname 2
on *:DIALOG:stype:dclick:2:dialog -k $dname
on *:DIALOG:stype:sclick:3:did -o $dname 4 1 $_selstype(2)
alias stype {
if ($1) {
if ($_scfg(reverse,$1)) `set soundtype $ifmatch
elseif ($_scfg($1,ext)) `set soundtype $1
else _error Unrecognized sound file type- $1 See sound configuration for details.
}
else `set soundtype $$dialog(stype,stype,-4)
disp Now playing sounds of type $:t($_desc(%`soundtype))
if ($dialog(sndpanel)) did -ar sndpanel 1 $_desc(%`soundtype) $+ :
}
; checks if %`soundtype is still valid
alias _validstp if ($_scfg(%`soundtype,ext) == $null) stype | elseif ($dialog(sndpanel)) did -ar sndpanel 1 $_desc(%`soundtype) $+ :
alias playlist {
_validsta
var %win = $_newwin(@Playlist)
_window 2.4 -l -t1,46 %win $_winpos(8,12,10,10) @Playlist
titlebar %win (0 files)
_plban %win
}
menu channel,menubar {
$_isstype:{ }
Sound
.Play...:loc *
.Random...:loc -c * *
.Find...:_validsta | loc * "* $+ $replace($_entry(0,$null,Find song(s) containing what words?),$chr(32),*) $+ *"
.-
.Type
..%.isstype1:_isstype 1
..%.isstype2:_isstype 2
..%.isstype3:_isstype 3
..%.isstype4:_isstype 4
..%.isstype5:_isstype 5
..%.isstype6:stype
..-
..$_dynpopf Reindex current:_validstp | reindex %`soundtype
.Recent
..$_rec(sound,1):_tsound " $+ %=sound.1 $+ " -
..$_rec(sound,2):_tsound " $+ %=sound.2 $+ " -
..$_rec(sound,3):_tsound " $+ %=sound.3 $+ " -
..$_rec(sound,4):_tsound " $+ %=sound.4 $+ " -
..$_rec(sound,5):_tsound " $+ %=sound.5 $+ " -
..$_rec(sound,6):_tsound " $+ %=sound.6 $+ " -
..$_rec(sound,7):_tsound " $+ %=sound.7 $+ " -
..$_rec(sound,8):_tsound " $+ %=sound.8 $+ " -
..-
..%=sound.clr:_recclr sound | .remove $_cfg(recent.pls)
..$iif((%=sound.clr) && ($exists($_cfg(recent.pls))),Recents playlist...):_validsta | loc -sl * $_cfg(recent.pls)
.-
.Playlist
..Create:playlist
..Open...:_validsta | loc -sl *
..Play...:_validsta | loc -s *
.Options
..$_dynpop(%_s.cont) Continuous play:scont *
..$_dynpop($window(@Queue)) Queue sounds:if ($window(@Queue)) squeue close | else squeue
..-
..$_dynpopf Playing to... %.isstarg:starg
.-
.$iif($menu == menubar,Configure)
..Sound types...:scfg
..Sound options...:sopt
..-
..F5:_error Sorry, this isn't done yet
..Shift F5:_error Sorry, this isn't done yet
..Ctrl F5:_error Sorry, this isn't done yet
$iif($mid(%`sound.grab,2,1) == 2,Grab)
.$_grabrec(sgrab,1):msg $_refsufn(sgrab,1) $_f2s($_grabrec(sgrab,1))
.$_grabrec(sgrab,2):msg $_refsufn(sgrab,2) $_f2s($_grabrec(sgrab,2))
.$_grabrec(sgrab,3):msg $_refsufn(sgrab,3) $_f2s($_grabrec(sgrab,3))
.$_grabrec(sgrab,4):msg $_refsufn(sgrab,4) $_f2s($_grabrec(sgrab,4))
.$_grabrec(sgrab,5):msg $_refsufn(sgrab,5) $_f2s($_grabrec(sgrab,5))
.$_grabrec(sgrab,6):msg $_refsufn(sgrab,6) $_f2s($_grabrec(sgrab,6))
.$_grabrec(sgrab,7):msg $_refsufn(sgrab,7) $_f2s($_grabrec(sgrab,7))
.-
.$iif(%>sgrab,Clear this list):unset %>sgrab
}
;;; clean up grab popups- &&, shorten..., numbers
alias _isstype {
unset %.isstype?
if ($exists($_cfg(sound.ini)) == $false) return
window -hl @.stypes
filter -fw $_cfg(sound.ini) @.stypes [*]
if ($fline(@.stypes,[reverse],1,0)) dline @.stypes $ifmatch
if ($fline(@.stypes,[opt],1,0)) dline @.stypes $ifmatch
var %num = 1,%type
:loop
if ($line(@.stypes,%num)) {
%type = $right($left($ifmatch,-1),-1)
if (%num == $1) stype %type
elseif ($1 == $null) set -u %.isstype [ $+ [ %num ] ] $_dynpop($iif(%`soundtype == %type,1)) $_desc(%type)
inc %num | goto loop
}
if (%num > 6) set -u %.isstype6 $_dynpopf More...
window -c @.stypes
_isstarg
}
alias _isstarg {
_validst 0
if (-* iswm %`soundtarg) set -u %.isstarg ( $+ $gettok(self.all channels.current window.quietly,$findtok(-s -c -a -q,%`soundtarg,32),46) $+ )
elseif (%`soundtarg) set -u %.isstarg ( $+ $replace($ifmatch,&,&&) $+ )
else unset %.isstarg
}
; sound playing/grabbing
ctcp &*:SOUND:_snd.ctcp $1-
ctcp &*:SLOTS:halt
ctcp &*:*:if (($len($1) == 3) && ($right($2-,3) == $1) && (*.??? iswm $2-)) _snd.ctcp $1-
alias -l _snd.ctcp {
if ($2 == $null) return
if ($chan) { _snd.play $chan $_snd.extract($2-) | <show.sound> $chan $nick $result %.action }
else {
_snd.play $nick $_snd.extract($2-)
if ($query($nick)) <show.sound> $nick $nick $result %.action
else <show.sound> -s $nick $result %.action
}
halt
}
on &^*:CHAT:SOUND *:_snd.chat $1-
on &^*:CHAT:??? *:if ($right($remove($2-,),3) == $1) if (*.??? iswm $remove($2-,)) _snd.chat $1-
alias -l _snd.chat {
_snd.play =$nick $_snd.extract($left($2-,-1))
if (* iswm $1-) <show.sound> =$nick $nick $result %.action
else <show.sound> =$nick $nick $result %.action
halt
}
; puts filename in %.file and returns remaining action
alias _snd.extract {
var %tok,%num = 1
:loop
if ($wildtok($1-,?*.?*,%num,32) != $null) {
%tok = $ifmatch
if ($len($gettok(%tok,$numtok(%tok,46),46)) isnum 1-3) {
%num = $findtok($1-,%tok,1,32)
%tok = 1- $+ %num
var %rest = $calc(%num + 1) $+ -
set -u1 %.file $gettok($1-,%tok,32)
set -u1 %.action $gettok($1-,%rest,32)
return %.action
}
inc %num | goto loop
}
set -u1 %.file $1
set -u1 %.action $2-
return $2-
}
; play sound/etc; returns 1 if sound found
alias -l _snd.play {
; if /sound is off...
if ($_optn(3,19) == 0) return
if (* isin %.file) return 0
var %type = $_sext(%.file)
if (%type == $null) return 0
var %file = $replace(%.file,-,?,_,?,$chr(32),?)
if ($count(%file,?) > $calc($len(%file) / 3)) return 0
._sfind %type 0 %file
var %found = $result
if ($_scfg(%type,jukebox)) {
if (%found) ._plsound %type $gettok(%found,2,9)
}
if ((%found == $null) && ($mid(%`sound.grab,1,1))) {
if (($target ischan) && (%`sound.grabchan)) {
if ($_searchtok($ifmatch,$chan,44) == 0) return
}
if (%`sound.grabmatch) {
if ($_searchtok($ifmatch,%file,44) == 0) return
}
if ($wildtok($strip($2-),!*,1,32)) var %trig = $ifmatch
elseif ($mid(%`sound.grab,3,1) == 0) goto done
else var %trig = ! $+ $nick
goto $mid(%`sound.grab,2,1)
:0
msg $1 %trig $replace(%.file,?,$chr(32))
goto done
:1
if ($window(@SoundGrab) == $null) {
_window 2.5 -ln -t13,30 @SoundGrab -1 -1 -1 -1 @SoundGrab
aline @SoundGrab Double-click on a file to grab it. (right-click for options)
aline @SoundGrab
aline @SoundGrab (where) Nickname Filename
aline @SoundGrab $_ultab(7,8,8)
}
if ($1 != $nick) var %pref = ( $+ $lower($1) $+ )
else var %pref
if (%trig != ! [ $+ [ $nick ] ] ) %trig = ( $+ %trig $+ )
else var %trig
var %match = * $replace(%.file,?,$chr(32))
if ($fline(@SoundGrab,%match,1)) dline @SoundGrab $ifmatch
iline @SoundGrab 5 %pref $nick %trig $replace(%.file,?,$chr(32))
goto done
:2
_recseen sgrab %trig $+ $chr(160) $+ $replace(%.file,?,$chr(160),$chr(32),$chr(160)) $1 7
}
:done
if (%found) return 1
return 0
}
menu @SoundGrab {
dclick:if ($1 > 4) _sndgrab $1 $line(@SoundGrab,$1)
Grab:if ($sline(@SoundGrab,1).ln > 4) _sndgrab $ifmatch $sline(@SoundGrab,$1)
Remove::loop | if ($sline(@SoundGrab,1).ln > 4) { dline @SoundGrab $ifmatch | goto loop }
-
Configure...:sopt
}
alias -l _sndgrab {
var %loc,%nick = $gettok($gettok($2-,2,9),1-,32)
if ($chr(40) isin $2) %loc = $right($left($gettok($2-,1,9),-2),-1)
if ((=* !iswm %loc) && ((%loc == $null) || ($mid(%`sound.grab,4,1)))) %loc = $gettok(%nick,1,32)
if ($gettok(%nick,2,32)) var %trig = $mid($ifmatch,2,$calc($len($ifmatch) - 2))
else var %trig = ! $+ $gettok(%nick,1,32)
msg %loc %trig $right($gettok($2-,3-,9),-1)
cline $colour(not) @SoundGrab $1
}