aIRC — File Browser
aIRCv0.8.69 / aIRCv0.8.69 / addons / xdcc1.mrc
xdcc1.mrc — 28.26 KB — Download this file
;/**********************************************************************
; *
; * aIRC
; * XDCC file 1
; *
; **********************************************************************/
;
;
ON *:CONNECT:{ _xdcc.init }
ON *:DISCONNECT:{ .timer_xdccadvert.* off }
#_xdcc off
ON *:JOIN:#:{
if ($nick == $me) { _xdcc.ad.chan $chan }
elseif ($_xdcc.rini(advertonjoin)) && ($_xdcc.isadvertchan($chan)) && ($_xdcc.ad.msg($nick) != $null) { _automsghtchan $chan $nick _puthelp $nick & notice $nick $ifmatch }
}
CTCP !*:CDCC:*:{ _xdcc.remote $2- }
CTCP !*:XDCC:*:{ _xdcc.remote $2- }
ON *:FILESENT:*:{ _xdcc.filesent }
#_xdcc end
alias _xdcc.filesent {
var %size = $file($filename).size,%sendnum = $send($nick,0),%ttf,%cps = 0
while (%sendnum) {
%ttf = $send($nick,%sendnum).path $+ $send($nick,%sendnum).file
if (%ttf = $filename) { %cps = $send($nick,%sendnum).cps }
dec %sendnum
}
if (%cps > $_xdcc.getrecordcps) {
_xdcc.wini recordcps %cps
_xdcc.wini recordby $nick
}
}
alias _xdcc.getrecordcps { return $_fixint($_xdcc.rini(recordcps)) }
alias _xdcc.getrecordby {
if ($_xdcc.rini(recordby) != $null) { return $ifmatch }
return ???
}
alias xdcc {
var %alias = _xdcc.local. $+ $1
unset %XDCC.D.NONONO
if ($1 == $null) {
if ($_xdcc.totalpacks) { _xdcc.local.list }
else { info.a [xdcc] You have no packs offered }
info.a XDCC is [ $+ $iif($_xdcc.rini(xdcc),ON,OFF) $+ ]. Use /xdcc help to get help with xdcc
}
elseif ($isalias(%alias)) {
%alias $2-
return $result
}
else { error.a Unknown XDCC Command $^'($1) }
}
alias cdcc {
xdcc $1-
return $result
}
alias _xdcc.init {
$iif($_xdcc.rini(xdcc),.enable,.disable) #_xdcc
_xdcc.ad.allchans
}
; /_xdcc.advert <#channel> <1 if auto>
alias _xdcc.advert {
var %validauto = 0
if ($_xdcc.rini(advertimerstatus)) && ($_xdcc.isadvertchan($1)) { %validauto = 1 }
.timer_xdccadvert. $+ $1 off
if ($me ison $1) {
if ($_not($2)) || (%validauto) { ._xdcc.sendnotice $1 }
if (%validauto) { .timer_xdccadvert. $+ $1 1 $calc($_xdcc.rini(advertimertime) * 60) _xdcc.advert $1 1 }
}
}
alias _xdcc.isadvertchan {
if ($_xdcc.rini(advertall)) { return 1 }
if ($istok($_fixchans($_xdcc.rini(advertchannels)),$1,44)) { return 1 }
return 0
}
alias _xdcc.local.setup { _dialog -m _xdcc _xdcc }
alias _xdcc.localhelp.setup { info.a Syntax: '/XDCC setup' XDCC Setup dialog }
;;
;
; $_xdcc.file
;
alias _xdcc.file { return $_chfile($_usrdir(xdccpacks.ini)) }
alias _xdcc.rini { return $_getsetup(xdcc,$1) }
alias _xdcc.wini { _setsetup xdcc $1- }
;;
;
; $_xdcc.read(<pack>,<item>)
;
alias _xdcc.read {
var %file = $_xdcc.file,%t = $1 $2,%line
%line = $read -ns" $+ %t $+ " $"(%file)
if ($gettok(%line,2-,32) != $null) { return $ifmatch }
}
;;
;
; /_xdcc.write <pack> <item> [text]
;
alias _xdcc.write {
var %file = $_xdcc.file,%t = $1 $2,%line
write -ds" $+ %t $+ " $"(%file)
if ($3- != $null) { write $"(%file) $1- }
}
; $_xdcc.packgets(pack)
alias _xdcc.packgets {
if ($_isint($_xdcc.read($1,gets))) { return $ifmatch }
return 0
}
; $_xdcc.packsize(pack)
alias _xdcc.packsize {
var %packfiles = $_xdcc.read($1,files),%i = $numtok(%packfiles,34),%total = 0
while (%i) {
inc %total $file($_fixfilename($gettok(%packfiles,%i,34))).size
dec %i
}
return %total
}
; $_xdcc.packfiles(pack)
alias _xdcc.packfiles {
var %packfiles = $_xdcc.read($1,files)
%packfiles = $replace(%packfiles,$chr(44),_,$chr(32),_,$chr(34),$chr(44))
if (%packfiles != $null) { return $ifmatch }
}
; $_xdcc.totalgets
alias _xdcc.totalgets {
var %i = $_xdcc.totalpacks,%total = 0
while (%i) {
inc %total $_xdcc.packgets(%i)
dec %i
}
return %total
}
; $_xdcc.totalsgets
alias _xdcc.totalsgets {
var %i = $_xdcc.totalpacks,%total = 0
while (%i) {
inc %total $calc($_xdcc.packgets(%i) * $_xdcc.packsize(%i))
dec %i
}
return %total
}
; $_xdcc.totalfiles
alias _xdcc.totalfiles {
var %i = $_xdcc.totalpacks,%total = 0
while (%i) {
if ($_xdcc.read(%i,files) != $null) { inc %total $numtok($ifmatch,34) }
dec %i
}
return %total
}
; $_xdcc.totalsize
alias _xdcc.totalsize {
var %i = $_xdcc.totalpacks,%total = 0
while (%i) {
inc %total $_xdcc.packsize(%i)
dec %i
}
return %total
}
;;
;
; /xdcc addfile [pack] [file]
; Adds a file to an existing pack
;
alias _xdcc.local.addfile {
var %xdccfile = $_xdcc.file,%total = $_xdcc.totalpacks,%pack,%tfile,%file,%type = isnum 1- $+ %total,%text = Pack number [[ $+ 1- $+ %total $+ ]],%packfiles
if ($_not(%total)) {
error.a [xdcc] No packs defined
return 1
}
if ($_isint($1)) {
var %pack = $1,%tfile = $2-
if (%pack > %total) {
error.a [xdcc] Pack $^'(%pack) not defined
return 1
}
}
else { %tfile = $1- }
if (%tfile != $null) {
if ($_fixfilename(%tfile,em) != $null) { %file = $ifmatch }
else {
error.a [xdcc] File invalid/not found - $^'(%tfile)
return 1
}
}
if ($_not($_isint(%pack))) {
if (%total == 1) { %pack = 1 }
%pack = $_parameter(%pack,0,XDCC [/xdcc],%type,$null,%text)
if ($_not($_isint(%pack))) || (%pack > %total) { return 1 }
}
if (%file == $null) { %file = $dir="Select file to add to pack [ $chr(35) $+ [ %pack ] ] " }
if (%file == $null) { return 1 }
%file = $_fixfilename(%file,em)
%packfiles = $_xdcc.read(%pack,files)
if (%packfiles != $null) {
if ($istok(%packfiles,%file,34)) {
error.a [xdcc] Already in pack $chr(35) $+ %pack $+ : $^'(%file)
return 1
}
%packfiles = $addtok(%packfiles,%file,34)
}
else { %packfiles = %file }
_xdcc.write %pack files %packfiles
if ($show) { info.a [xdcc] Added $^'(%file) to pack $chr(35) $+ %pack }
return 0
}
alias _xdcc.localhelp.addfile { info.a Syntax: '/XDCC addfile [pack] [file]' - Adds a file to an existing pack }
;;
;
; /xdcc delfile [pack] <file|filenum>
; Removes a file from an existing pack
;
alias _xdcc.local.delfile {
var %xdccfile = $_xdcc.file,%total = $_xdcc.totalpacks,%pack,%tfile,%result,%delfiles = 0,%packfiles
if ($1- == $null) { goto syntax }
_xdcc.askpack %total $1-
%result = $result
if (%result == $null) { return 1 }
var %pack = $gettok(%result,1,32),%tfile = $gettok(%result,2-,32)
if (%tfile == $null) {
:syntax
error.a Syntax: /xdcc delfile [pack] <file|filenum>
return 1
}
%packfiles = $_xdcc.read(%pack,files)
if ($_isint(%tfile)) && (%tfile <= $numtok(%packfiles,34)) { %tfile = $gettok(%packfiles,%tfile,34) }
elseif ($wildtok(%packfiles,%tfile,0,34)) { }
else {
error.a [xdcc] Wrong $iif($_isint(%tfile),filenumber,file) $+ : $^'(%tfile)
return 1
}
while ($wildtok(%packfiles,%tfile,1,34) != $null) {
%packfiles = $remtok(%packfiles,$ifmatch,1,34)
inc %delfiles
}
if (%packfiles == $null) {
xdcc doffer %pack
return 0
}
_xdcc.write %pack files %packfiles
if ($show) { info.a [xdcc] Removed $_nsingoplur(%delfiles,file,files) from pack $chr(35) $+ %pack }
return 0
}
alias _xdcc.localhelp.delfile { info.a Syntax: '/XDCC delfile [pack] <file|filenum>' - Removes a file from an existing pack }
;;
;
; /xdcc describe [pack] [description]
; Modifies description to an existing pack
;
alias _xdcc.local.desc {
_xdcc.local.describe $1-
return $result
}
alias _xdcc.local.describe {
var %xdccfile = $_xdcc.file,%total = $_xdcc.totalpacks,%pack,%desc,%result
_xdcc.askpack %total $1-
%result = $result
if (%result == $null) { return 1 }
var %pack = $gettok(%result,1,32),%desc = $gettok(%result,2-,32)
_xdcc.write %pack desc %desc
if ($show) { info.a [xdcc] Modified description for pack $chr(35) $+ %pack }
return 0
}
alias _xdcc.localhelp.desc { _xdcc.localhelp.describe }
alias _xdcc.localhelp.describe { info.a Syntax: '/XDCC describe [pack] [description]' - Modifies description to an existing pack }
;;
;
; /xdcc doffer [pack|*]
; Removes a pack
;
alias _xdcc.local.doffer {
var %xdccfile = $_xdcc.file,%total = $_xdcc.totalpacks,%pack,%result,%win = @__xdcclocaldoffer
if ($1 == *) {
write -c $"(%xdccfile)
if ($show) { info.a [xdcc] Removed $^b(all) packs }
return 0
}
_xdcc.askpack %total $1-
%result = $result
if (%result == $null) { return 1 }
%pack = $gettok(%result,1,32)
_openwins %win
filter -fwx " $+ %xdccfile $+ " %win %pack *
savebuf %win %xdccfile
close -@ %win
_xdcc.fixfile
if ($show) { info.a [xdcc] Removed pack $chr(35) $+ %pack }
return 0
}
alias _xdcc.localhelp.doffer { info.a Syntax: '/XDCC doffer [pack|*]' - Removes a pack }
;;
;
; /xdcc echo [on|off] [active|status|@xdcc]
; Echo remote requests
;
alias _xdcc.local.echo {
var %tog = $1,%twin = $2,%echo,%win
if ($istok(on off,%tog,32)) { _xdcc.wini echo $iif(%tog == on,1,0) }
else { %twin = $1 }
%echo = $_xdcc.rini(echo)
if (%echo) {
if (a* iswm %twin) { %win = 0 }
elseif (s* iswm %twin) { %win = 1 }
elseif (@* iswm %twin) || (x* iswm %twin) { %win = 2 }
if (%win == $null) { %win = $_xdcc.rini(echowin) }
if ($istok(0 1 2,%win,32) == $false) { %win = 0 }
_xdcc.wini echowin %win
if ($show) { info.a [xdcc] Echo remote requests: ON ( $+ $gettok(Active Status @XDCC,$calc(%win + 1),32) Window) }
}
elseif ($show) { info.a [xdcc] Echo remote requests: OFF }
}
alias _xdcc.localhelp.echo { info.a Syntax: '/XDCC echo [on|off] [active|status|@xdcc]' - Echo remote requests }
;;
;
; /xdcc help [command]
; Help
;
alias _xdcc.local.help {
var %alias = _xdcc.local. $+ $1,%helpalias = _xdcc.localhelp. $+ $1
if ($1- == $null) {
info.a $upper(setup addfile delfile desc describe doffer echo list minspeed note notice off on offer plist queue secure send type)
info.a Usage: /XDCC help [command] to get help on specific commands
return 0
}
elseif ($isalias(%helpalias)) {
%helpalias $2-
return 0
}
elseif ($isalias(%alias)) { error.a [xdcc] No help available on that }
else { error.a [xdcc] Unknown command: $2- }
return 1
}
alias _xdcc.localhelp.help { info.a Syntax: '/XDCC help [command]' }
;;
;
; /xdcc list
; Lists your packs
;
alias _xdcc.local.list {
var %i,%n,%echo = echo2 $colour(info) $_actwin(it) $^***,%gets
_xdcc.fixfile
%i = 1
%n = $_xdcc.totalpacks
if (%n) {
linesep $_actwin
%echo XDCC List:
%echo $_filleft(3, ,$chr(35)) files $_filleft(13, ,size) gets description
while (%i <= %n) {
%gets = $_xdcc.packgets(%i)
if ($_not(%gets)) { %gets = 0 }
%echo $_filleft(3, ,%i) $_filleft(5, ,$numtok($_xdcc.read(%i,files),34)) $_filleft(13, ,$_size($_xdcc.packsize(%i))) $_filleft(4, ,%gets) $_xdcc.read(%i,desc)
inc %i
}
}
else {
error.a [xdcc] You have no packs offered
return 1
}
}
alias _xdcc.localhelp.list { info.a Syntax: '/XDCC list' - Lists your packs }
;;
;
; /xdcc minspeed [kb/s]
; sets the minspeed for DCC sends (0 to disable)
;
alias _xdcc.local.minspeed {
._dccminspeed $1-
var %s = $gettok($result,1,32),%n = $gettok($result,2,32),%line
%line = [xdcc] DCC Send Minspeed is $iif(%s,ON,Off)
if (%s) { %line = %line ( $+ %n kb/s) }
if ($show) { info.a %line }
}
alias _xdcc.localhelp.minspeed { info.a Syntax: '/XDCC minspeed [kb/s]' - sets the minspeed for DCC sends (0 to disable) }
;;
;
; /xdcc note [pack] [note]
; Modifies notes to an existing pack
;
alias _xdcc.local.note {
var %xdccfile = $_xdcc.file,%total = $_xdcc.totalpacks,%pack,%note,%result
_xdcc.askpack %total $1-
%result = $result
if (%result == $null) { return 1 }
var %pack = $gettok(%result,1,32),%note = $gettok(%result,2-,32)
_xdcc.write %pack note %note
if ($show) { info.a [xdcc] Modified note for pack $chr(35) $+ %pack }
return 0
}
alias _xdcc.localhelp.note { info.a Syntax: '/XDCC note [pack] [note]' - Modifies notes to an existing pack }
;;
;
; /xdcc notice [nick|channel]
; Sends a notice to nick|channel that you are offering
;
alias _xdcc.local.notice {
var %target = $1,%packs = $_xdcc.totalpacks
if ($_disconnected) { return 1 }
if ($_not(%packs)) {
error.a [xdcc] You have no packs offered
return 1
}
if (%target == $null) {
if ($_ischan($active)) || ($query($active)) { %target = $active }
else { %target = $_parameter($null,1,XDCC [/xdcc],1,$null,Send notice to [nick|channel]) }
}
_xdcc.sendnotice %target
return 0
}
; /_xdcc.sendnotice <target>
alias _xdcc.sendnotice {
var %target = $1,%packs = $_xdcc.totalpacks
if (%target != $null) && (%packs) { notice %target $_xdcc.evaltext($_xdcc.premsg(notice,0),%target,%packs) }
}
alias _xdcc.localhelp.notice { info.a Syntax: '/XDCC notice [nick|channel]' - Sends a notice to nick|channel that you are offering }
;;
;
; /xdcc on/off
;
alias _xdcc.local.off { _xdcc.turn 0 }
alias _xdcc.local.on { _xdcc.turn 1 }
alias _xdcc.turn {
_xdcc.wini xdcc $iif($1,1,0)
if ($show) { info.a XDCC is $iif($_xdcc.rini(xdcc),ON,OFF) }
_xdcc.init
}
alias _xdcc.localhelp.on { info.a Syntax: '/XDCC on' - Turns xdcc on }
alias _xdcc.localhelp.off { info.a Syntax: '/XDCC off' - Turns xdcc off }
;;
;
; /xdcc offer [file]
; Creates a new pack
;
alias _xdcc.local.offer {
var %xdccfile = $_xdcc.file,%pack = $_xdcc.totalpacks + 1,%result,%cp = $chr(35) $+ %pack
_xdcc.write %pack ispack 1
_xdcc.local.addfile %pack $1-
%result = $result
_xdcc.write %pack ispack
if ($_not(%result)) {
_xdcc.write %pack time $ctime
xdcc describe %pack $_parameter($null,0,XDCC [/xdcc],$null,$gettok($_xdcc.read(%pack,files),1,46),Description for pack [ %cp ] )
xdcc note %pack $_parameter($null,0,XDCC [/xdcc],$null,$null,Note for pack [ %cp ] )
}
return %result
}
alias _xdcc.localhelp.offer { info.a Syntax: '/XDCC offer [file]' - Creates a new pack }
;;
;
; /xdcc plist [nick|channel]
; Lists your packs to nick|channel
;
alias _xdcc.local.plist {
var %target = $1,%packs = $_xdcc.totalpacks
if ($_disconnected) { return 1 }
if ($_not(%packs)) {
error.a [xdcc] You have no packs offered
return 1
}
if (%target == $null) {
if ($_ischan($active)) || ($query($active)) { %target = $active }
else { %target = $_parameter($null,1,XDCC [/xdcc],1,$null,Send list to [nick|channel]) }
}
if ($show) { info.a [xdcc] Sending list to %target $+ ... }
_xdcc.sendlist %packs %target
return $result
}
alias _xdcc.localhelp.plist { info.a Syntax: '/XDCC plist [nick|channel]' - Lists your packs to nick|channel }
;;
;
; /xdcc queue <list|cancel> [*|nick|n1,n2-n3...] [file mask]
;
alias _xdcc.local.queue {
var %result,%parms
._dccqueue $1-
var %result = $gettok($result,1,32),%parms = $gettok($result,2-,32)
if (%result == ERR_noqueues) { error.a [xdcc] There are no queue entries }
elseif (%result == ERR_nomatch) { error.a [xdcc] No queues matching $^'(%parms) }
elseif (%result == ERR_syntax) { error.a [xdcc] Syntax: /xdcc queue <list|cancel> [*|nick|n1,n2-n3...] [file mask] }
elseif (%result == CANCEL) { info.a [xdcc] Removed $_nsingoplur(%parms,file,files) from the send queue }
}
alias _xdcc.localhelp.queue { info.a Syntax: '/XDCC queue <list|cancel> [*|nick|n1,n2-n3...] [file mask]' }
;;
;
; /xdcc secure [pack] [password]
; Modifies password for an existing pack
;
alias _xdcc.local.secure {
var %xdccfile = $_xdcc.file,%total = $_xdcc.totalpacks,%pack,%pass,%result
_xdcc.askpack %total $1-
%result = $result
if (%result == $null) { return 1 }
var %pack = $gettok(%result,1,32),%pass = $gettok(%result,2,32)
if (%pass != $null) { _xdcc.write %pack pass $_crypt(%pass) }
else { _xdcc.write %pack pass }
if ($show) { info.a [xdcc] Modified password for pack $chr(35) $+ %pack }
return 0
}
alias _xdcc.localhelp.secure { info.a Syntax: '/XDCC secure [pack] [password]' - Modifies password for an existing pack }
;;
;
; /xdcc send <nick> [pack]
; Sends a pack
;
alias _xdcc.local.send {
var %nick,%pack,%total = $_xdcc.totalpacks,%(send),%(queue),%i,%n,%cp,%packfiles,%file,%npfile,%queue,%reply,%remoteget = %XDCCREMOTEGET,%clearqueueonnochan = $_getsetup(dcc,clearqueueonnochan)
unset %XDCCREMOTEGET
if ($1 != $null) {
if ($_isint($1)) { %pack = $1 }
else { var %nick = $1,%pack = $2 }
}
%nick = $_parameter(%nick,1,XDCC [/xdcc],1,$_activequery,Nick:)
if ($_not($_isint(%pack))) { %pack = $_xdcc.askpack(%total,$null) }
if ($_isint(%pack)) && (%pack <= %total) {
%cp = $chr(35) $+ %pack
%packfiles = $_xdcc.read(%pack,files)
%reply = _puthelp %nick & _qnotice %nick
%i = 1
%n = $numtok(%packfiles,34)
if (%remoteget) {
.timer -o 1 0 _setsetup dcc clearqueueonnochan %clearqueueonnochan
_setsetup dcc clearqueueonnochan 0
}
while (%i <= %n) {
%file = $_fixfilename($gettok(%packfiles,%i,34))
%npfile = $nopath(%file)
%queue = $_dccsend(%nick,%file)
%(send) = ( $+ $_dcctotal.send $+ / $+ $_getsetup(dcc,maxStotal) $+ )
%(queue) = ( $+ $_sendqueue.queues $+ / $+ $_getsetup(dcc,maxQtotal) $+ )
if (%queue == ERR_nofile) { %reply File not found: $^'(%npfile) }
elseif (%queue == ERR_insend) { %reply You are already getting: $^'(%npfile) }
elseif (%queue == ERR_inqueue) { %reply You already have $^'(%npfile) in my queue }
elseif (%queue == ERR_nocomchan) { %reply Send slots full %(send) $+ . Queue slots available %(queue) but you must be in one of my channels in order to queue. }
elseif (%queue == ERR_maxQtotal) { %reply Queue slots full %(queue) }
elseif (%queue == ERR_maxQuser) { %reply You can't queue any more files. Your queues: ( $+ $_sendqueue.queues(%nick) $+ / $+ $_getsetup(dcc,maxQuser) $+ ) }
elseif (%queue == ERR_maxStotal) { %reply There are too many get sessions %(send) }
elseif (%queue == ERR_maxSuser) { %reply You have too many get sessions ( $+ $_dcctotal.send(%nick) $+ / $+ $_getsetup(dcc,maxSuser) $+ ) }
elseif (ERR_* iswm %queue) { %reply Unknown Error. Can't send you $^'(%npfile) }
elseif (%queue) { %reply Your request is now in my queue ( $+ %queue $+ / $+ $_getsetup(dcc,maxQtotal) $+ ) }
else { %reply Sending file: $^'(%npfile) $^p($_size($file(%file).size)) }
inc %i
}
_setsetup dcc clearqueueonnochan %clearqueueonnochan
}
}
alias _xdcc.local.send { info.a Syntax: '/XDCC send <nick> [pack]' - Sends a pack }
;;
;
; /xdcc type [[priv]msg|notice]
; privmsg or notice ?
;
alias _xdcc.localhelp.type { info.a Syntax: '/XDCC type [[priv]msg|notice]' - privmsg or notice ? }
alias _xdcc.local.type {
if (p* iswm $1) || (m* iswm $1) { _xdcc.wini type 1 }
elseif (n* iswm $1) { _xdcc.wini type 0 }
if ($istok(0 1,$_xdcc.rini(type),32) == $false) { _xdcc.wini type 0 }
var %s = $_xdcc.rini(type)
if ($show) { info.a [xdcc] Type of output for offer set to [[ $+ $iif(%s,Privmsg,Notice) $+ ]] }
}
alias _xdcc.remote {
if ($nick == $me) { return }
var %alias = _xdcc.remote. $+ $1
if ($1 == $null) || ($_not($_xdcc.rini(xdcc))) || ($_flood2(3,__XDCCnoXDCC)) { return }
elseif ($isalias(%alias)) {
%alias $nick $fulladdress $2-
return $result
}
}
;;
;
; XDCC get [[#]pack] [password]
;
alias _xdcc.remote.send {
_xdcc.remote.get $1-
return $result
}
alias _xdcc.remote.get {
var %xdccfile = $_xdcc.file,%nick = $1,%fulladdress = $2,%pack = $3,%pass = $4,%total,%spass,%reply = _puthelp %nick & _qnotice %nick,%packfiles,%cp
if (#* iswm %pack) && ($count(%pack,$chr(35)) == 1) { %pack = $remove(%pack,$chr(35)) }
if ($_isint(%pack)) {
%cp = $chr(35) $+ %pack
%packfiles = $_xdcc.read(%pack,files)
if (%packfiles == $null) {
_xdcc.echo Denied pack %cp to %nick $^bp($gettok(%fulladdress,2,33)) (no files!!)
return 1
}
if ($_xdcc.read(%pack,pass) != $null) { %spass = $_decrypt($ifmatch) }
if (%spass != $null) && (%spass !=== %pass) {
%close
%reply [xdcc] Incorrect password for pack $chr(35) $+ %pack
_xdcc.echo Denied pack %cp to %nick $^bp($gettok(%fulladdress,2,33)) (Incorrect password)
return 1
}
_xdcc.write %pack gets $calc($_xdcc.packgets(%pack) + 1)
_xdcc.echo %nick $^bp($gettok(%fulladdress,2,33)) requests pack %cp
%XDCCREMOTEGET = 1
.xdcc send %nick %pack
return $result
}
return 1
}
;;
;
; XDCC help [topic]
;
alias _xdcc.remote.help {
var %nick = $1,%fulladdress = $2,%topic = $upper($3),%reply = _puthelp %nick & _qnotice %nick XDCC:
_xdcc.echo %nick $^bp($gettok(%fulladdress,2,33)) asks for help $iif(%topic,on [ %topic ] )
if (%topic == $null) { %reply HELP GET LIST INFO QUEUE }
elseif (%topic == help) { %reply HELP - help on XDCC commands }
elseif (%topic == get) || (%topic == send) { %reply %topic - have XDCC send pack #N }
elseif (%topic == list) { %reply LIST - list of offered packs }
elseif (%topic == info) { %reply INFO - info on pack #N }
elseif (%topic == queue) { %reply QUEUE - queue status for us }
else { return 1 }
return 0
}
;;
;
; XDCC list
;
alias _xdcc.remote.list {
var %nick = $1,%fulladdress = $2,%packs = $_xdcc.totalpacks
_xdcc.echo %nick $^bp($gettok(%fulladdress,2,33)) requests list
_xdcc.sendlist %packs %nick
return $result
}
;;
;
; XDCC info <[#]pack>
;
alias _xdcc.remote.info {
var %nick = $1,%fulladdress = $2,%pack = $3,%total = $_xdcc.totalpacks,%reply = _puthelp %nick & _qnotice %nick,%nf,%gets,%size
if (#* iswm %pack) && ($count(%pack,$chr(35)) == 1) { %pack = $remove(%pack,$chr(35)) }
if ($_isint(%pack)) && (%pack <= %total) {
%nf = $numtok($_xdcc.read(%pack,files),34)
%gets = $_xdcc.packgets(%pack)
%size = $_xdcc.packsize(%pack)
%reply $_xdcc.evaltext($_xdcc.premsg(info,0),%nick,%total,%pack)
_xdcc.echo %nick $^bp($gettok(%fulladdress,2,33)) requests info on pack $chr(35) $+ %pack
return 0
}
_xdcc.echo Denied info request to %nick $^bp($gettok(%fulladdress,2,33)) (Invalid pack: %pack $+ )
return 1
}
;;
;
; XDCC queue
;
alias _xdcc.remote.queue {
var %nick = $1,%fulladdress = $2,%reply = _puthelp %nick & _qnotice %nick
if ($_sendqueue.queues(%nick) != $null) { %reply You have $_nsingoplur($ifmatch,file,files) queued at $_sendqueue.pos(%nick) }
else { %reply You have no files queued. }
_xdcc.echo %nick $^bp($gettok(%fulladdress,2,33)) requests queue info
return 0
}
; $_xdcc.totalpacks
alias _xdcc.totalpacks {
var %file = $_xdcc.file,%win = @__xdcctotalpacks,%last
_openwins %win
filter -fwtu 1 32 " $+ %file $+ " %win *
%last = $gettok($line(%win,$line(%win,0)),1,32)
close -@ %win
if ($_not($_isint(%last))) { %last = 0 }
return %last
}
;;
;
; _xdcc.fixfile
;
; Fixes XDCC packs file
; returns number of packs
;
alias _xdcc.fixfile {
var %file = $_xdcc.file,%win = @__xdccfixfile,%i,%n,%lastn,%currn,%chng1,%chng2,%number
_openwins %win
filter -fwtu 1 32 " $+ %file $+ " %win *
%n = $line(%win,0)
%i = 1
%chng2 = 1
while (%i <= %n) {
%currn = $gettok($line(%win,%i),1,32)
if (%i == 1) && (%currn != 1) { %chng1 = %currn }
if (%i == %n) && ($_not($_isint(%currn))) { break }
if (%lastn != %currn) && (%lastn != $null) {
if ($calc(%currn - %chng2) > 1) { %chng1 = %currn }
%chng2 = %chng2 + 1
}
if (%chng1 == %currn) { rline %win %i %chng2 $gettok($line(%win,%i),2-,32) }
%lastn = %currn
inc %i
}
savebuf %win %file
close -@ %win
if ($_not($_isint(%chng2))) { %chng2 = 0 }
return %chng2
}
;;
;
; /_xdcc.askpack <totalpacks> <parms>
;
alias _xdcc.askpack {
var %pack,%parms = $2-,%total = $1,%type = isnum 1- $+ %total,%text = Pack number [[ $+ 1- $+ %total $+ ]]
if ($_not(%total)) {
error.a [xdcc] You have no packs offered
return
}
if ($_isint($2)) {
var %pack = $2,%parms = $3-
if (%pack > %total) {
error.a [xdcc] Pack $^'(%pack) not defined
return
}
}
else { %parms = $2- }
if ($_isint(%pack)) { return %pack %parms }
elseif (%total == 1) { return 1 %parms }
else { return $_parameter(%pack,1,XDCC [/xdcc],%type,$null,%text) %parms }
}
;;
;
; $_xdcc.evaltext(text,target,totalpacks,[pack#])
;
alias _xdcc.evaltext {
var %text = $1,%target = $2,%totalpacks = $3,%pack = $4,%packsize,%gets,%packfiles,%desc,%note,%time,%pass,%totalgets,%totalfiles,%totalsize
if (%pack) {
var %packsize = $_xdcc.packsize(%pack),%gets = $_xdcc.packgets(%pack),%packfiles = $_xdcc.packfiles(%pack),%desc = $_xdcc.read(%pack,desc),%note = $_xdcc.read(%pack,note),%time = $_xdcc.read(%pack,time),%pass = $_decrypt($_xdcc.read(%pack,pass))
%text = $replace(%text,<PACK>,%pack,<PACKSIZE>,%packsize,<PACKGETS>,%gets,<PACKDESC>,%desc,<PACKNOTE>,%note,<PACKFILES>,%packfiles,<PACKNUMFILES>,$numtok(%packfiles,34),<TIMEADDED>,%time,<PACKPASS>,%pass)
}
if (<TOTALGETS> isin %text) { %text = $replace(%text,<TOTALGETS>,$_xdcc.totalgets) }
if (<TOTALFILES> isin %text) { %text = $replace(%text,<TOTALFILES>,$_xdcc.totalfiles) }
if (<TOTALSIZE> isin %text) { %text = $replace(%text,<TOTALSIZE>,$_xdcc.totalsize) }
if (<TOTALSGETS> isin %text) { %text = $replace(%text,<TOTALSGETS>,$_xdcc.totalsgets) }
return $_evaltext($replace(%text,<TARGET>,%target,<TOTALPACKS>,%totalpacks,<RECORDCPS>,$_xdcc.getrecordcps,<RECORDBY>,$_xdcc.getrecordby))
}
;;
;
; /_xdcc.sendlist <totalpacks> <nick|channel>
;
alias _xdcc.sendlist {
var %target = $2,%packs = $1,%reply,%i,%desc,%note
%reply = _puthelp %target $iif($_ischan(%target),c&,&) $iif($_xdcc.rini(type),_qprivmsg,_qnotice) %target
%reply $_xdcc.evaltext($_xdcc.premsg(header,0),%target,%packs)
%i = 1
while (%i <= %packs) {
%desc = $_xdcc.read(%i,desc)
%note = $_xdcc.read(%i,note)
if (%note != $null) { %reply $_xdcc.evaltext($_xdcc.premsg(packn,0),%target,%packs,%i) }
else { %reply $_xdcc.evaltext($_xdcc.premsg(packd,0),%target,%packs,%i) }
inc %i
}
if ($_xdcc.premsg(lstend,0) != $null) {
if ($_xdcc.evaltext($ifmatch,%target,%packs,%i) != $null) { %reply $ifmatch }
}
return 0x
}
alias _xdcc.echo {
if ($_xdcc.rini(echo)) {
var %twin = $_xdcc.rini(echowin),%win = @XDCC,%line = [xdcc] $1-
if (%twin == 2) && ($_not($window(%win))) {
window -nk @XDCC $_window.conf(@XDCC)
_window.font.reset @XDCC @XDCC
if ($_fixfilename($_logdir(@xdcc.log),em) != $null) { loadbuf -c $+ $colour(info) %win $"($ifmatch) }
timestamp on @XDCC
}
if ($window(%win)) { echo $colour(info) -i @XDCC $timestamp $^*** $1- }
elseif (%twin) { info.s %line }
else { info.a %line }
}
}
; $_xdcc.premsg(topic,don't read from file)
alias _xdcc.premsg {
if ($istok(notice header packd packn lstend info,$1,32) == $false) { return }
if ($_not($2)) {
var %f = _xdcctext_ $+ $1,%text = $_rinitxt(%f)
if (%text != $null) { return $ifmatch }
}
return $_xdcc.txtpreset.default($1)
}
menu menubar {
&xdcc
.$`ifmm($_xdcc.rini(xdcc)) &turn $iif($_xdcc.rini(xdcc),off,on):{ xdcc $iif($_xdcc.rini(xdcc),off,on) }
.&setup:{ xdcc setup }
.-
.&packs
..&add:{ xdcc offer }
..&remove:{ xdcc doffer }
.&files
..&add:{ xdcc addfile }
..&remove:{ xdcc delfile }
.&modify
..&description:{ xdcc desc }
..¬e:{ xdcc note }
..&password:{ xdcc secure }
.&list:{ xdcc list }
.&queue:{ xdcc queue }
.-
.&help:{ xdcc help }
}
menu channel,query {
$iif($_connected,&xdcc)
.¬ice:{ xdcc notice }
.send &list:{ xdcc plist }
.-
.$iif($active ischan || $query($active),&requests)
..&list:{ ctcp $active xdcc list }
..&help:{ ctcp $active xdcc help }
}
menu @XDCC {
$`ifmm($_xdcc.rini(xdcc)) &turn $iif($_xdcc.rini(xdcc),off,on):{ xdcc $iif($_xdcc.rini(xdcc),off,on) }
&setup:{ xdcc setup }
-
&packs
.&add:{ xdcc offer }
.&remove:{ xdcc doffer }
.files
.&add:{ xdcc addfile }
.&remove:{ xdcc delfile }
&modify
.&description:{ xdcc desc }
.¬e:{ xdcc note }
.&password:{ xdcc secure }
&list:{ xdcc list }
&queue:{ xdcc queue }
&help:{ xdcc help }
}
alias _windowsize.XDCC { return C C 478 161 }
alias _windowopts.XDCC { return 0 1 1 }
alias _onclosewin.XDCC { .savebuf @XDCC $_fixfilename($_logdir(@xdcc.log),m) }
alias _xdcc.load { xdcc setup }
alias _xdcc.unload { }