derfy
07-24-2005, 06:07 AM
This code is now deprecated. The design is horrible and I need to find a better way to handle this. For now, use the old code, instead.
This will not work unless you change winamp to send '%l %s %f' to mIRC. Also, you need to manually make a hash table and assign it with /hmake -s <hash table name> 1000 and /set %mp3.hash <that name>. Also, /set %mp3.num 1 would help greatly.
This makes a hash table for lusers to lookup full file pathnames on your mp3 spews:
In aliases:
pwamp {
return $right($gettok($1-,1,58),1) $+ $chr(58) $+ $gettok($1-,2,58)
}
udur { return $remove($replace($replace($replace($replace($repla ce($replace($replace($replace($replace($replace($d uration($1),secs,s),mins,m),hrs,h),min,m),hrs,h),h r,h),sec,s),days,d),day,d),wks,w),$chr(32)) }
dmp3-n {
if ($2 == [Connecting] || $2 == prebuffering || $2 == [Buffer: || $1 < 1) {
.halt
}
if (%mp3.lastplay == $2-) {
if (%mp3.lastlen != $1) {
set %mp3.lastlen $1
.halt
}
}
if (%mp3.lastplay = $2-) { halt }
if ($1 < 30) { halt }
set %mp3.lastplay $2-
set %mp3.lastlen $1
if ($hfind(%mp3.hash,$pwamp($2-)).data = $null) {
; we found no entry, go on and add it
hadd %mp3.hash %mp3.num $pwamp($2-)
inc %mp3.num
}
{
if ($read(%mp3.recent,s,$pwamp($2-))) {
msg #derfy Recently played( $+ $readn of 40): %derf.front .;: $left($gettok($2-,1,58),$calc($len($gettok($2-,1,58))-1)) :;. L: $+ $udur($1) P: $+ %mp3.played - Type '!mp3info $hfind(%mp3.hash,$pwamp($2-),1).data $+ ' for file info.
return
}
var %i = 0
while (%i < $chan(0)) {
inc %i
if ((#mp3 iswm $chan(%i)) || (#playmp3 iswm $chan(%i)) || (#derfy iswm $chan(%i))) { msg $chan(%i) %derf.front .;: $left($gettok($2-,1,58),$calc($len($gettok($2-,1,58))-1)) :;. L: $+ $udur($1) P: $+ %mp3.played - Type '!mp3info $hfind(%mp3.hash,$pwamp($2-),1).data $+ ' for file info. }
}
}
$addrecent($pwamp($2-))
inc %mp3.played 1
inc %mp3.totaltime $1
}
displast {
msg $active %derf.front .;: $pwamp(%mp3.lastplay) :;. L: $+ $udur(%mp3.lastlen) P: $+ %mp3.played - Type '!mp3info $hfind(%mp3.hash,$pwamp(%mp3.lastplay),1).data $+ ' for detailed info.
}
playwmp {
if ($1) {
run %winamp " $+ $hget(%mp3.hash,$1) $+ "
}
}
createnewalias {
write -c %mph menu channel $chr(123)
write %mph mp3s
set %cna.hashnum 1
set %cna.popmin 1
set %cna.hashmax %cna.hashmaxadd + 1
:loop
; i could only think of using a loop to pull this off!
write %mph . $+ %cna.popmin $+ - $+ %cna.hashmax
while (%cna.hashnum <= %cna.hashmax) {
if (%cna.hashnum > $hget(%mp3.hash,0).item) { break }
; we reached the max item in the hash; abort!
if ($exists($hget(%mp3.hash,%cna.hashnum)) == $false) {
write %mph .. $+ %cna.hashnum - $chr(32) $+ $chr(58) $+ nothing
inc %cna.hashnum
continue
}
write %mph .. $+ %cna.hashnum - $nopath($hget(%mp3.hash,%cna.hashnum)) $+ $chr(58) $+ playwmp %cna.hashnum
inc %cna.hashnum
}
if (%cna.hashnum <= $hget(%mp3.hash,0).item) {
; if there's more data to be gotten...
set %cna.hashmax $calc(%cna.hashnum + %cna.hashmaxadd)
set %cna.popmin $calc(%cna.popmin + %cna.popminadd)
; set the max to %hashmax more than the current number and...
goto loop
; do it better!
}
write %mph $chr(125)
.reload -rs %mph
}
addrecent {
if (%mp3.recentcount > 40) {
set %mp3.recentcount 1
}
write -l $+ %mp3.recentcount %mp3.recent $1-
inc %mp3.recentcount
}
reindex {
unset %mp3x.*
%mp3x.reindex = 1
%mp3x.orighash = $hget(%mp3.hash,0).item
while (%mp3x.reindex <= %mp3x.orighash) {
if ($exists($hget(%mp3.hash,%mp3x.reindex)) == $true) {
inc %mp3x.reindex
continue
}
else {
%mp3x.stepping = %mp3x.reindex
while ($exists($hget(%mp3.hash,%mp3x.stepping)) == $false) {
if (%mp3x.stepping > %mp3x.orighash) {
set %mp3.num %mp3x.reindex
return
}
inc %mp3x.stepping
}
hadd %mp3.hash %mp3x.reindex $hget(%mp3.hash,%mp3x.stepping)
hdel %mp3.hash %mp3x.stepping
}
}
set %mp3.num %mp3x.reindex
}
In remotes:
#mp3info on
on *:text:!mp3info*:#:{
if ($2 && $hget(%mp3.hash,$2)) {
.write -c $nick $+ -mp3inforeq.txt .notice $nick Info for song number $2 $+ :
.write $nick $+ -mp3inforeq.txt .notice $nick Filename: $hget(%mp3.hash,$2)
.write $nick $+ -mp3inforeq.txt .notice $nick Size: $size($file($hget(%mp3.hash,$2)).size)
.write $nick $+ -mp3inforeq.txt .notice $nick Type '!get $2 $+ ' to have me DCC you this file.
.play -c $nick $nick $+ -mp3inforeq.txt 2000
}
}
#mp3info end
This will not work unless you change winamp to send '%l %s %f' to mIRC. Also, you need to manually make a hash table and assign it with /hmake -s <hash table name> 1000 and /set %mp3.hash <that name>. Also, /set %mp3.num 1 would help greatly.
This makes a hash table for lusers to lookup full file pathnames on your mp3 spews:
In aliases:
pwamp {
return $right($gettok($1-,1,58),1) $+ $chr(58) $+ $gettok($1-,2,58)
}
udur { return $remove($replace($replace($replace($replace($repla ce($replace($replace($replace($replace($replace($d uration($1),secs,s),mins,m),hrs,h),min,m),hrs,h),h r,h),sec,s),days,d),day,d),wks,w),$chr(32)) }
dmp3-n {
if ($2 == [Connecting] || $2 == prebuffering || $2 == [Buffer: || $1 < 1) {
.halt
}
if (%mp3.lastplay == $2-) {
if (%mp3.lastlen != $1) {
set %mp3.lastlen $1
.halt
}
}
if (%mp3.lastplay = $2-) { halt }
if ($1 < 30) { halt }
set %mp3.lastplay $2-
set %mp3.lastlen $1
if ($hfind(%mp3.hash,$pwamp($2-)).data = $null) {
; we found no entry, go on and add it
hadd %mp3.hash %mp3.num $pwamp($2-)
inc %mp3.num
}
{
if ($read(%mp3.recent,s,$pwamp($2-))) {
msg #derfy Recently played( $+ $readn of 40): %derf.front .;: $left($gettok($2-,1,58),$calc($len($gettok($2-,1,58))-1)) :;. L: $+ $udur($1) P: $+ %mp3.played - Type '!mp3info $hfind(%mp3.hash,$pwamp($2-),1).data $+ ' for file info.
return
}
var %i = 0
while (%i < $chan(0)) {
inc %i
if ((#mp3 iswm $chan(%i)) || (#playmp3 iswm $chan(%i)) || (#derfy iswm $chan(%i))) { msg $chan(%i) %derf.front .;: $left($gettok($2-,1,58),$calc($len($gettok($2-,1,58))-1)) :;. L: $+ $udur($1) P: $+ %mp3.played - Type '!mp3info $hfind(%mp3.hash,$pwamp($2-),1).data $+ ' for file info. }
}
}
$addrecent($pwamp($2-))
inc %mp3.played 1
inc %mp3.totaltime $1
}
displast {
msg $active %derf.front .;: $pwamp(%mp3.lastplay) :;. L: $+ $udur(%mp3.lastlen) P: $+ %mp3.played - Type '!mp3info $hfind(%mp3.hash,$pwamp(%mp3.lastplay),1).data $+ ' for detailed info.
}
playwmp {
if ($1) {
run %winamp " $+ $hget(%mp3.hash,$1) $+ "
}
}
createnewalias {
write -c %mph menu channel $chr(123)
write %mph mp3s
set %cna.hashnum 1
set %cna.popmin 1
set %cna.hashmax %cna.hashmaxadd + 1
:loop
; i could only think of using a loop to pull this off!
write %mph . $+ %cna.popmin $+ - $+ %cna.hashmax
while (%cna.hashnum <= %cna.hashmax) {
if (%cna.hashnum > $hget(%mp3.hash,0).item) { break }
; we reached the max item in the hash; abort!
if ($exists($hget(%mp3.hash,%cna.hashnum)) == $false) {
write %mph .. $+ %cna.hashnum - $chr(32) $+ $chr(58) $+ nothing
inc %cna.hashnum
continue
}
write %mph .. $+ %cna.hashnum - $nopath($hget(%mp3.hash,%cna.hashnum)) $+ $chr(58) $+ playwmp %cna.hashnum
inc %cna.hashnum
}
if (%cna.hashnum <= $hget(%mp3.hash,0).item) {
; if there's more data to be gotten...
set %cna.hashmax $calc(%cna.hashnum + %cna.hashmaxadd)
set %cna.popmin $calc(%cna.popmin + %cna.popminadd)
; set the max to %hashmax more than the current number and...
goto loop
; do it better!
}
write %mph $chr(125)
.reload -rs %mph
}
addrecent {
if (%mp3.recentcount > 40) {
set %mp3.recentcount 1
}
write -l $+ %mp3.recentcount %mp3.recent $1-
inc %mp3.recentcount
}
reindex {
unset %mp3x.*
%mp3x.reindex = 1
%mp3x.orighash = $hget(%mp3.hash,0).item
while (%mp3x.reindex <= %mp3x.orighash) {
if ($exists($hget(%mp3.hash,%mp3x.reindex)) == $true) {
inc %mp3x.reindex
continue
}
else {
%mp3x.stepping = %mp3x.reindex
while ($exists($hget(%mp3.hash,%mp3x.stepping)) == $false) {
if (%mp3x.stepping > %mp3x.orighash) {
set %mp3.num %mp3x.reindex
return
}
inc %mp3x.stepping
}
hadd %mp3.hash %mp3x.reindex $hget(%mp3.hash,%mp3x.stepping)
hdel %mp3.hash %mp3x.stepping
}
}
set %mp3.num %mp3x.reindex
}
In remotes:
#mp3info on
on *:text:!mp3info*:#:{
if ($2 && $hget(%mp3.hash,$2)) {
.write -c $nick $+ -mp3inforeq.txt .notice $nick Info for song number $2 $+ :
.write $nick $+ -mp3inforeq.txt .notice $nick Filename: $hget(%mp3.hash,$2)
.write $nick $+ -mp3inforeq.txt .notice $nick Size: $size($file($hget(%mp3.hash,$2)).size)
.write $nick $+ -mp3inforeq.txt .notice $nick Type '!get $2 $+ ' to have me DCC you this file.
.play -c $nick $nick $+ -mp3inforeq.txt 2000
}
}
#mp3info end