aIRC — File Browser
aIRCv0.8.69 / aIRCv0.8.69 / script / script1.mrc
script1.mrc — 28.85 KB — Download this file
;/**********************************************************************
; *
; * aIRC
; * Version checker
; *
; **********************************************************************/
alias checkver { _airchttp $_aircsite 80 /aircnews.txt $_checkver.localfile 0 _checkver }
alias -l _checkver.localfile { return $_chfile($_usrdir(aircnews.txt)) }
alias _checkver.init {
if ($show) { info.a Checking for aIRC updates/news... }
}
alias _checkvers.parse {
var %file = $_checkver.localfile,%line = $read -nl1 %file,%match,%myver = $_aircvernum,%date
tokenize 32 %line
; lastvers ctime aIRC aircversionnum mIRC mircversion
; lastvers 982807577 aIRC 00086280 mIRC 5.82
%match = lastvers & aIRC ???????? mIRC &
if (%match iswm $1-) && ($_isint($2)) && ($_isint($4)) {
if ($4 < %myver) { error.a Invalid updates/news file (or you hacked aIRC) }
else {
var %text
if ($4 > %myver) { %text = There is a new aIRC version available: $_vernum2ver($4) for mIRC $6 }
else { %text = Your aIRC version is up to date }
; info.a %text - Use /updates for more info
info.a %text
}
}
else { error.a Invalid updates/news file! }
}
alias _checkver.errsockopen { _checkver.sockerror }
alias _checkver.errsockwrite { _checkver.sockerror }
alias _checkver.errsockread { _checkver.sockerror }
alias _checkver.errhttp { error.a Error trying to get aIRC updates/news from $_sockmark(1) $+ : $2- }
alias _checkver.startget { }
alias _checkver.nohttp11 { error.a $_sockmark(1) doesn't support HTTP/1.1 }
alias _checkver.sockclose { _checkvers.parse }
alias -l _checkver.sockerror { error.a Error trying to get aIRC updates/news from $_sockmark(1) $+ : $_sockerr }
;
;/**********************************************************************
; *
; * aIRC
; * Lag Meter
; *
; **********************************************************************/
alias lag {
if ($_disconnected) { return }
if ($show) { info.a Pinging server... }
_lag e
}
alias lagmethod {
if ($1 == raw) { _setsetup lagcheck method 0 }
elseif ($1 == ctcpreply) { _setsetup lagcheck method 1 }
if ($show) { info.a Lag checking method is: $iif($_getsetup(lagcheck,method),ctcpreply,raw) - Use "/lagmethod [raw|ctcpreply]" to modify the lagchecking method }
}
alias _lag {
.timer_lag off
if ($_connected) {
var %send = lag_ $+ $ticks $+ _f $+ $1
if (%.network == PTnet) || ($_getsetup(lagcheck,method)) { .quote NOTICE $me :aIRC_lagchecking %send $+ }
else { .quote %send }
if (%.lag.sent == $null) { %.lag.sent = $ctime }
}
}
raw 421:& lag_*_*:{ _rawlag $2 }
raw 434:& lag_*_*:{ _rawlag $2 }
ON ME:*:CTCPREPLY:aIRC_lagchecking lag_*_*:{ _rawlag $2 }
alias _rawlag {
tokenize 95 $1-
if ($2 !isnum) || ($2 < 0) { return }
unset %.lag.sent
%.lag.current = $calc(($ticks - $2) / 1000)
if (e isin $3) { info.a Your lag is: $__lagtime(%.lag.current) }
if ($_getsetup(lagcheck,state)) { .timer_lag 1 $_getsetup(lagcheck,interval) _lag }
halt
}
;/**********************************************************************
; *
; * aIRC
; * Hooks
; *
; **********************************************************************/
alias _hook.call {
if ($hget(_airchooks,$1) != $null) {
var %hooks = $ifmatch,%i = 1,%n = $numtok(%hooks,32),%alias
_result2null
while (%i <= %n) {
%alias = $gettok(%hooks,%i,32)
if ($isalias(%alias)) {
%alias $2-
if ($result != $null) { return $ifmatch }
}
inc %i
}
}
return $null
}
alias _hook.flush {
if ($hget(_airchooks) != $null) { hfree _airchooks }
}
alias _hook.get { return $hget(_airchooks,$1) }
alias _hook.add {
var %h = _airchooks,%tmp
if ($hget(%h) == $null) { hmake %h 20 }
hadd %h $1 $addtok($hget(%h,$1),$2,32)
}
alias _hook.del {
var %h = _airchooks,%tmp
if ($hget(%h) == $null) { hmake %h 20 }
hadd %h $1 $remtok($hget(%h,$1),$2,32)
if ($hget(%h,$1) == $null) { hdel -w %h $1 }
}
;/**********************************************************************
; *
; * aIRC
; * Ircop commands
; *
; **********************************************************************/
alias connect {
if ($_disconnected) || ($_iamnotircop(connect)) { return }
var %tmp = $_rparameter($1-,1,Connect IRC servers [/connect],normal,$null,ircopconnect,$null,<new server> [[<port>] <existing server>])
_recent.add ircopconnect 20 $1-
connect $1-
}
alias squit {
if ($_disconnected) || ($_iamnotircop(squit)) { return }
tokenize 32 $_parameter($1,1,IRC Server Quit [/squit],1,$null,Server:) $_rparameter($2-,1,IRC Server Quit [/squit],normal,$null,squitreason,$null,SQuit reason:)
_recent.add squitreason 20 $2-
squit $1-
}
alias oper { oper $_parameter($1,1,IRCop Login [/oper],replace 32 44,$null,Login:) $_parameterpass($2-,1,IRCop Login [/oper],normal,$null,Password:) }
alias kill {
if ($_disconnected) || ($_iamnotircop(kill)) { return }
tokenize 32 $_parameter($1,1,IRCop Kill [/kill],replace 32 44,$_activequery,Kill:) $_rparameter($2-,1,Kill [/kill],normal,$null,killreason,$null,Kill reason:)
_recent.add killreason 20 $2-
var %i = $numtok($1,44)
while (%i) {
_rawkill $gettok($1,%i,44) $2-
dec %i
}
}
alias -l _rawkill { _puthelp & & .raw kill $1 : $+ $2- }
alias whokill {
var %wm,%parm,%reason
if ($_disconnected) || ($_iamnotircop(kill)) { return }
var %parm = $_parameter($1,1,Kill wildcard [/whokill],1,$address($_activequery,3),Wildcard to Kill:)
if ($remove($1,*,.) == $null) {
error.a No, I won't let you kill the entire net! ( $+ $1 $+ )
return
}
%wm = %parm
if (! !isin $1) && (@ !isin $1) { %wm = *!@ $+ $1 }
%wm = $_fixmask(%wm)
if (%wm == $null) {
error.a Invalid mask for whokill: $1
return
}
%reason = $_rparameter($2-,1,Kill [/kill],normal,$null,killreason,$null,Kill reason:)
_recent.add killreason 20 %reason
unset %c.whokill.*
%c.whokill.parm = %parm
%c.whokill.wm = %wm
%c.whokill.reason = %reason
%c.whokill.inc = 0
.enable #_whokill
who $1
info.a WhoKill: $^'($1) $^p($2-) - Performing Who...
}
#_whokill off
raw 352:*:{
var %addy = $6 $+ ! $+ $3 $+ @ $+ $4,%handle = $_finduser(%addy),%flags
if (%handle != $null) { %flags = $_nickflags(%handle) }
if (%c.whokill.reason == $null) { %c.whokill.reason = $me }
if (%c.whokill.wm iswm %addy) && (* !isin $7) && (b !isincs %flags) && (f !isincs %flags) && (m !isincs %flags) {
info.a WhoKill: Killing %addy
inc %c.whokill.inc
_rawkill $6 %c.whokill.reason
}
halt
}
raw 315:*:{
if (%c.whokill.inc) { info.a WhoKill: $_nsingoplur(%c.whokill.inc,user,users) killed ( $+ %c.whokill.wm $+ ) }
else { info.a WhoKill: No users killed ( $+ %c.whokill.wm $+ ) }
unset %c.whokill.*
.disable #_whokill
halt
}
#_whokill end
alias kline {
if ($_disconnected) || ($_iamnotircop(kline)) { return }
tokenize 32 $_parameter($1,1,IRCop Kline [/kline],replace 32 44,$_activequery,Kline:) $2-
var %i = $numtok($1,44)
while (%i) {
kline $gettok($1,%i,44) $2-
dec %i
}
}
alias deoper {
if ($_disconnected) || ($_iamnotircop(deoper)) { return }
mode $me - $+ $iif(O isincs $usermode,O) $+ $iif(o isincs $usermode,o)
}
;/**********************************************************************
; *
; * aIRC
; * Jokes
; *
; **********************************************************************/
alias fwhois {
if ($_active == $null) {
error.a Can't use /fwhois in this window
return
}
%c.fwhois.nick = $_parameter($1,1,Funny Whois [/fwhois],1,$_activequery,Nick:)
%c.fwhois.channels = $_parameter($2-,1,Funny Whois [/fwhois],replace 44 32,$null,Channels with [ $chr(35) ] separated by spaces:)
.enable #_fwhois
%c.fwhois.active = $active
whois %c.fwhois.nick
}
#_fwhois off
raw 319:*:{ halt }
raw 318:*:{
if ($2 == %c.fwhois.nick) && (%=whois.nick != $null) {
.timer 1 1 msg %c.fwhois.active -
.timer 1 2 msg %c.fwhois.active $2 is %=whois.addy * %=whois.name
.timer 1 3 msg %c.fwhois.active $2 on $gettok(%=whois.channels,1-2,32) %c.fwhois.channels
.timer 1 4 msg %c.fwhois.active $2 using %=whois.server %=whois.servinf
.timer 1 5 msg %c.fwhois.active End of /WHOIS list.
.timer 1 6 msg %c.fwhois.active -
}
unset %c.fwhois.*
.disable #_fwhois
halt
}
#_fwhois end
;/**********************************************************************
; *
; * aIRC
; * Tip of the day
; *
; **********************************************************************/
alias tip {
_dialog -m _tip _tip
if ($1- != $null) { did -o _tip 250 1 $ifmatch }
}
alias _tip {
var %file = etc\tips.txt
if ($dialog(_tip) == $null) || ($isfile(%file) == $false) { return }
_setsetup script _tipnumber $calc($_getsetup(script,_tipnumber) + 1)
if ($_getsetup(script,_tipnumber) > $lines(%file)) { _setsetup script _tipnumber 1 }
var %tipa.a = $read -l $+ $_getsetup(script,_tipnumber) %file
if ($_evaltext(%tipa.a) != $null) { did -o _tip 1 1 $ifmatch }
}
dialog _tip {
size -1 -1 165 93
title "Tip of the day"
option dbu
text "",1,15 15 130 55
box "",2,5 2 153 70
check "",220,5 78 10 10
button "&Next >>",231,85 75 33 15
button "&Close",232,125 75 33 15,cancel
edit "",250,250 170 66 30,hide
}
ON *:DIALOG:_tip:init:0:{
_mdx.init $_icofile(info.ico)
_tip
if ($_getsetup(script,onstart.tipofday)) { did -c $dname 220 }
did -f $dname 232
_dummy $_lang.loaddialog($dname,$dname,00086969,main.lang,$scriptdir)
}
ON *:DIALOG:_tip:sclick:231:{ _tip }
ON *:DIALOG:_tip:sclick:232:{
_setsetup script onstart.tipofday $did(220).state
if ($did(250) != $null) { .timer -mo 1 0 $ifmatch }
}
;/**********************************************************************
; *
; * aIRC
; * Fonts
; *
; **********************************************************************/
;
; /fonts [-bcqgtlmnw] <fontsize> <fontname>
; b bold
;
; c channel windows
; q query/chat windows
; g finger window
; t transfer windows (send/get)
; l links window
; m message window
; n notify window
; w wwwlist window
alias fonts {
var %flags,%parms,%font,%size,%bold,%win = @Fonts,%ff
if (-* iswm $1) && ($1 !isnum) { var %flags = $1,%parms = $2- }
else { %parms = $1- }
if ($removecs(%flags,-,b) == $null) { %flags = %flags $+ scq }
if (%parms isnum) { font $iif(b isincs %flags,-bs,-s) $round(%parms,0) $window(Status Window).font }
elseif (%parms != $null) { font $iif(b isincs %flags,-bs,-s) %parms }
else {
window -a "Status Window"
font
}
%font = $window(Status Window).font
%size = $window(Status Window).fontsize
%bold = $window(Status Window).fontbold
%ff = %font $+ , $+ $calc(%size + $iif(%bold,700,400))
_theme.fonts fstatus %ff
if (q isincs %flags) { _theme.fonts fquery %ff }
if (c isincs %flags) { _theme.fonts fchannel %ff }
if (g isincs %flags) { _theme.fonts ffinger %ff }
if (t isincs %flags) { _theme.fonts fdccsg %ff }
if (l isincs %flags) { _theme.fonts flinks %ff }
if (m isincs %flags) { _theme.fonts fmessage %ff }
if (n isincs %flags) { _theme.fonts fnotify %ff }
if (w isincs %flags) { _theme.fonts fwwwlist %ff }
}
;/**********************************************************************
; *
; * aIRC
; * about aIRC
; *
; **********************************************************************/
alias about {
if ($dialog(_about)) { dialog -v _about }
else { dialog -m _about _about }
if ($1- != $null) { did -o _about 250 1 $1- }
}
alias _about.photo {
if ($dialog(_about)) {
var %t = $findfile($_fixdir(etc\),tabo*.jpg,0,1),%n = $calc($calc($did(_about,249) % %t) + 1),%f = $findfile($_fixdir(etc\),tabo*.jpg,%n,1)
did -o _about 249 1 %n
if ($isfile(%f)) { did -g _about 7 " $+ %f $+ " }
}
}
dialog _about {
size -1 -1 168 85
title "About aIRC"
option dbu
icon 1,8 5 20 20,etc\aIRC.ico
text "",2,30 5 90 50
icon 7,130 5 32 35
link "",51,40 55 175 15
link "",52,45 68 90 15
button "&Author!",53,133 43 26 11
check "",55,8 68 8 8
button "",230,50 50 33 15,cancel hide
edit "",249,125 85 33 15,hide
edit "",250,125 85 33 15,hide
}
ON *:DIALOG:_about:init:0:{
_mdx.init
did -a $dname 2 aIRC® $_vers $+ $crlf $+ Script for mIRC® v5.82 $+ $crlf $crlf $+ Copyright © 1997-2001 tabo Co. Ltd $+ $crlf $+ All Rights Reserved $+ $crlf $crlf $+ Written by tabo
did -o $dname 249 1 $rand(1,$findfile($_fixdir(etc\),tabo*.jpg,0,1))
did -o $dname 51 1 $_aircweb
did -o $dname 52 1 $_tabomail
if ($_getsetup(script,onstart.about)) { did -c $dname 55 }
_about.photo
_dummy $_lang.loaddialog($dname,$dname,00086969,main.lang,$scriptdir)
}
ON *:DIALOG:_about:sclick:7:{ _about.photo }
ON *:DIALOG:_about:sclick:51:{ run $_aircweb }
ON *:DIALOG:_about:sclick:52:{ mail $_tabomail aIRC comment $_vers $+ +w $+ $os $+ +m $+ $version from $me $iif($_server,in [ $_server ] ) $iif(%.network,$strip($^p(%.network))) }
ON *:DIALOG:_about:sclick:53:{ _about.photo }
ON *:DIALOG:_about:sclick:230:{
_setsetup script onstart.about $did(55).state
if ($did(250) != $null) { .timer -mo 1 0 $ifmatch }
}
;/**********************************************************************
; *
; * aIRC
; * ASCII table
; *
; **********************************************************************/
alias tascii {
var %win = @Ascii Table,%file = etc\asciit.txt,%line,%w,%h
if ($isfile(%file) == $false) || ($crc(%file) != BAEFBC62) { _tascii.makefile }
_tascii.makefile
close -@ %win
%line = $read -l1 %file
%w = $width(%line,$window(status window).font,$window(status window).fontsize,$iif($window(status window).fontbold,1,0),1)
%w = $round($calc(%w + (%w / 9)),0)
%h = $calc($height(%line,$window(status window).font,$window(status window).fontsize) * 27)
window -k +lst %win $round($calc(($window(-3).w - %w) / 2),0) $round($calc(($window(-3).h - %h) / 2),0) %w %h %win $window(status window).font $window(status window).fontsize
_window.font.reset %win %win
loadbuf -c $+ $colour(info) %win $"(%file)
}
alias _tascii.makefile {
var %i1 = 33,%file = etc\asciit.txt
write -c $"(%file)
while (%i1 <= 53) {
var %i2 = %i1 + 21,%i3 = %i2 + 21,%i4 = %i3 + 21,%i5 = %i4 + 21,%i6 = %i5 + 21,%i7 = %i6 + 21,%i8 = %i7 + 21,%i9 = %i8 + 21,%i10 = %i9 + 21,%i11 = %i10 + 21
if (%i1 < 37) { write $"(%file) %i1 $chr(%i1) %i2 $chr(%i2) %i3 $chr(%i3) %i4 $chr(%i4) %i5 $chr(%i5) %i6 $chr(%i6) %i7 $chr(%i7) %i8 $chr(%i8) %i9 $chr(%i9) %i10 $chr(%i10) %i11 $chr(%i11) }
elseif (%i1 <= 46) { write $"(%file) %i1 $chr(%i1) %i2 $chr(%i2) %i3 $chr(%i3) %i4 $chr(%i4) %i5 $chr(%i5) %i6 $chr(%i6) %i7 $chr(%i7) %i8 $chr(%i8) %i9 $chr(%i9) %i10 $chr(%i10) %i11 $chr(%i11) }
else { write $"(%file) %i1 $chr(%i1) %i2 $chr(%i2) %i3 $chr(%i3) %i4 $chr(%i4) %i5 $chr(%i5) %i6 $chr(%i6) %i7 $chr(%i7) %i8 $chr(%i8) %i9 $chr(%i9) %i10 $chr(%i10) }
inc %i1
}
}
menu @Ascii Table {
©...:{ clipboard $chr($_param(isnum 33-256,$null,Copy character n::)) }
}
alias _windowsize.Ascii Table { return C C 614 281 }
alias _windowopts.Ascii Table { return 0 0 0 }
;/**********************************************************************
; *
; * aIRC
; * sockets
; *
; **********************************************************************/
alias _sockrename {
if ($1 == $2) { return }
sockrename $1-
}
alias _sw {
if ($sockname != $null) { sockwrite -n $sockname $1- }
}
alias _swcrlf {
if ($sockname != $null) { sockwrite $sockname $1- $+ $crlf }
}
alias _sockerr { return $sock($sockname).wsmsg }
alias _sockmark {
if ($2 == $null) && ($sockname) { return $gettok($sock($sockname).mark,$1,9) }
return $gettok($sock($1).mark,$2,9)
}
alias _sckbpsw {
if ($1- == $null) { return 0 bytes/s }
return $_size($1) $+ /s
}
alias _file2sock {
var %sent = 0
while (1) {
bread " $+ $2- $+ " %sent 4096 &bin
if ($bvar(&bin,0)) {
inc %sent $ifmatch
breplace &bin 160 32
sockwrite $1 &bin
}
else { break }
}
}
alias _parsetelnet {
var %t = $remove($1-,ÿý),%i,%left,%right,%pos,%space = 0
if ($chr(7) isin %t) {
beep
%t = $remove(%t,$chr(7))
}
if ($chr(8) isin %t) {
while ($pos(%t,$chr(8)) > 0) {
var %pos = $ifmatch,%left,%right,%space = 0
if ($mid(%t,$calc(%pos - 1),1) == $null) { %space = 1 }
if (%pos > 1) { %left = $left($gettok(%t,1,8),-1) }
%right = $right(%t,$calc(%pos * -1))
if (%space) { %t = %left %right }
else { %t = %left $+ %right }
}
}
return %t
}
alias _knownports { return 11,19-21,23,25,43,53,59,79,80,109,110,113,135,137,138,139,144,512-515,517,543,1027-1029,1032,1080,3333,4000,5000,5580,6660-6670,7000-7005,8000,8080 }
alias _idenport {
if ($1 !isnum) { return }
var %file,%line
if (u* iswm $2) { %file = etc\portsudp.txt }
else { %file = etc\portstcp.txt }
if ($isfile(%file)) { %line = $read -ns $+ $1 %file }
return %line
}
;/**********************************************************************
; *
; * aIRC
; * Logs
; *
; **********************************************************************/
alias logs {
var %a = $iif($1 != $null,$1,$active),%reload = 0
if (%c.reloadlogs) { %reload = 1 }
unset %c.reloadlogs
if (*.log iswm %a) { %a = $left(%a,-4) }
if (=* iswm %a) { %a = $right(%a,-1) }
if ($window(@Logs) == $null) {
window -kl24S @Logs $_window.conf(@Logs)
_window.font.reset @Logs @Logs
%reload = 1
}
if (%reload) {
titlebar @Logs - Gathering logs list... please wait
clear -l @Logs
var %l = $findfile($logdir,*.log,0,1,aline -l @Logs $nopath($1-))
}
clear @Logs
if ($_logfile(%a) != $null) { _logs $nopath($ifmatch) }
else { titlebar @Logs }
}
alias _logs {
var %title,%file = $logdir $+ $1-,%lines
if (*.log !iswm %file) { %file = %file $+ .log }
clear @Logs
if ($isfile(%file)) {
loadbuf -p @Logs " $+ %file $+ "
sline @Logs 10
%title = $1
%lines = $lines(%file)
if (*.log iswm $1) { %title = $deltok($1,$numtok($1,46),46) }
titlebar @Logs - %title - ( $+ $_nsingoplur(%lines,line,lines) $+ / $+ $_size($file(%file).size) $+ )
if ($fline(@Logs,$nopath(%file),1,1)) { sline -l @Logs $ifmatch }
}
else { titlebar @Logs }
}
menu @Logs {
dclick {
if ($mouse.lb) && ($sline(@Logs,1) != $null) { _logs $sline(@Logs,1) }
}
$_window.ciright(&read):{ _logs $sline(@Logs,1) }
re&fresh:{
var %t = $gettok($window(@Logs).title,2,32)
if (%t == $null) { %t = $sline(@Logs,1) }
%c.reloadlogs = 1
logs
if (%t) { _logs %t }
}
-
$_window.ciright(©...):{ _logs.copy }
$_window.ciright(&erase...):{ _logs.erase }
}
alias _logs.copy {
var %d = $$sdir="Copy files to:",%i = $sline(@Logs,0)
while (%i) {
.copy -o " $+ $logdir $+ $sline(@Logs,%i) $+ .log" " $+ %d $+ $sline(@Logs,%i) $+ .log"
dec %i
}
}
alias _logs.erase {
if ($_yesno(1,$null,0,Delete selected files?)) {
while ($sline(@Logs,0)) {
_remove " $+ $logdir $+ $sline(@Logs,$sline(@Logs,0)) $+ "
dline -l @Logs $sline(@Logs,$sline(@Logs,0)).ln
}
}
clear @Logs
titlebar @Logs
}
alias _windowsize.Logs { return C C 478 161 }
alias _windowopts.Logs { return 0 1 1 }
;/**********************************************************************
; *
; * aIRC
; * Textwin
; *
; **********************************************************************/
alias textwin {
if ($1 == $null) && (($chan($active)) || ($query($active)) || ($left($active,1) == =)) { tokenize 32 $active $2- }
var %dir = $mircdir $+ etc\text\,%m = %dir $+ *.txt
if ($2- == $null) { tokenize 32 $1 $$dir="Text file:" %m }
else {
if ($2- == $nopath($2-)) { tokenize 32 $1 %dir $+ $2- }
if (. !isin $2-) { tokenize 32 $1 $2- $+ .txt }
}
if ($isfile($2-) == $false) {
error.a File not found: $^'($2-)
return
}
if ($1 == $null) || ($2- == $null) { return }
_textwin @Text ---> $+ $1 $+ : $+ $nopath($2-) $2-
}
; _textwin @window file
alias _textwin {
var %l,%t
if ($window($1) == $null) {
window -abkl $1 $_window.conf(@Text)
_window.font.reset $1 @Text
}
clear $1
%l = $read -l0 $2-
if (%l isnum) && (%l > 0) { loadbuf 2- $+ $calc(%l + 1) $1 " $+ $2- $+ " }
else { loadbuf $1 " $+ $2- $+ " }
window -b $1
%t = $read -l $+ $calc($lines($2-) - 1) $2-
if (* iswm %t) { titlebar $1 - $remove(%t,) }
else { titlebar $1 }
}
menu @Text {
dclick { _textwin.send }
$iif($sline($active,1),&send):{ _textwin.send }
-
&destiny:{ renwin $active @Text ---> $+ $_param(1,$null,New destiny:) $+ : $+ $gettok($active,5-,160) }
&file:{
var %dir = $mircdir $+ etc\text\,%m = %dir $+ *.txt,%a = $dir="Text file:" %m,%w
if ($isfile(%a)) {
clear $active
%w = @Text ---> $+ $gettok($active,3,160) $+ : $+ $nopath(%a)
if ($active != %w) { renwin $active %w }
_textwin %w %a
}
}
$iif($sline($active,0),©):{ _textwin.copy }
}
alias _textwin.send {
if ($sline($active,0) == 1) { _puthelp $gettok($active,3,160) & msg $gettok($active,3,160) $gettok($window($active).title,2-,32) $sline($active,1) }
elseif ($sline($active,0) > 1) && ($_yesno(1,$null,0,Send [ $sline($active,0) ] lines message to [ $gettok($active,3,160) ] )) {
var %t = $sline($active,0),%l = 1
while (%l <= %t) {
_puthelp $gettok($active,3,160) & msg $gettok($active,3,160) $gettok($window($active).title,2-,32) $sline($active,%l)
inc %l
}
}
}
alias _textwin.copy {
var %i = 1,%n = $sline($active,0)
clipboard
while (%i <= %n) {
clipboard -a $gettok($window($active).title,2-,32) $sline($active,%i) $+ $crlf
inc %i
}
}
alias _windowsize.Text { return C C 493 157 }
alias _windowopts.Text { return 0 1 1 }
;/**********************************************************************
; *
; * aIRC
; * Binds
; *
; **********************************************************************/
; /bind <fkey> [command]
alias bind {
var %fkey = $1,%command = $2-,%used = 0
if (%fkey == $null) { error.a Syntax: /bind fkey [command] }
elseif ($_isvalidfkey(%fkey)) {
if ($nopath($isalias($_getaliasfromfkey(%fkey)).fname) != eop.mrc) { %used = 1 }
%fkey = $remove(%fkey,f)
if (%used) {
error.a Can't bind $_codekey2fkey(%fkey) $+ . It's probably being used by an addon
return
}
if (%command != $null) {
_setsetup binds %fkey %command
if ($show) { info.a Binded to $_codekey2fkey(%fkey) $+ : %command }
}
else {
_setsetup binds %fkey
if ($show) { info.a Unbinded $_codekey2fkey(%fkey) }
}
}
else { error.a Invalid Fkey: %fkey }
}
; $_addfkey(flags,duration,command)
; flags:
; o = connected only
alias _addfkey {
if ($3- == $null) { return }
var %tmp = $1,%setflags = _ $+ $1,%setduration = $round($2,0),%setcommand = $3-,%keys = 5 6 7 8 s5 s6 s7 s8 c5 c6 c7 c8 cs5 cs6 cs7 cs8 9 10 11 12 s9 s10 s11 s12 c9 c10 c11 c12 cs9 cs10 cs11 cs12 1 2 3 4 s1 s2 s3 s4 c1 c2 c3 c4 cs1 cs2 cs3 cs4,%var,%i = 1,%n = $numtok(%keys,32),%tok,%cnt,%flags,%duration,%command,%duration,%seton,%result,%lastset = 0,%firstfree,%disconnected = $_not($_connected),%assign = 1
if ($_not($_isint(%setduration))) || (%setduration < 2) { %setduration = 600 }
while (%i <= %n) {
%tok = $gettok(%keys,%i,32)
%var = % $+ ~fkey. $+ %tok
%cnt = [ [ %var ] ]
if ($nopath($isalias($_getaliasfromfkey(%tok)).fname) == eop.mrc) {
if ($_getsetup(binds,%tok) != $null) {
if ($ifmatch == %setcommand) {
%assign = 0
%result = %tok
break
}
}
else {
var %seton = $gettok(%cnt,1,32),%flags = $gettok(%cnt,2,32),%duration = $gettok(%cnt,3,32),%command = $gettok(%cnt,4-,32)
if (%seton) && (%seton >= %lastset) { %lastset = %seton }
if (o isin %flags) && (%disconnected) { var %cnt }
if ($calc(%seton + %duration) < $ctime) { var %cnt }
if (%firstfree == $null) && (%cnt == $null) { %firstfree = %tok }
if (%command == %setcommand) {
%result = %tok
break
}
}
}
inc %i
}
if (%result == $null) {
if (%firstfree) { %result = $ifmatch }
elseif (%lastset) { %result = $ifmatch }
else { %result = $_randtok(5 6 7 8,32) }
}
if (%assign) {
%var = % $+ ~fkey. $+ %result
set -u $+ %setduration [ %var ] $ctime %setflags %setduration %setcommand
}
return $_codekey2fkey(%result)
}
alias _isvalidfkey {
var %fkey = $1,%tmp = _ $+ %fkey,%fnum = $gettok(%tmp,2,$asc(f))
if ($_isint(%fnum) isnum 1-12) && ($count(%fkey,c) <= 1) && ($count(%fkey,s) <= 1) && ($count(%fkey,f) == 1) {
if (c isin %fkey) && (s isin %fkey) && ($pos(%fkey,c) > $pos(%fkey,s)) { return 0 }
if (c isin %fkey) && ($pos(%fkey,c) > $pos(%fkey,f)) { return 0 }
if (s isin %fkey) && ($pos(%fkey,c) > $pos(%fkey,f)) { return 0 }
return 1
}
return 0
}
alias _codekey2fkey { return $iif(c isin $1,Ctrl+) $+ $iif(s isin $1,Shift+) $+ F $+ $remove($1,c,s) }
alias _fkey2codekey { return $remove($replace($1,Ctrl+,c,Shift+,s),f) }
alias _getaliasfromfkey {
var %result
if (c isin $1) { %result = c }
if (s isin $1) { %result = %result $+ s }
%result = %result $+ f $+ $remove($1,c,f,s)
if (s isin %result) { return $remove(%result,c) }
return %result
}
alias defkeys {
bind f1 help
bind f2 join
bind f3 clear
bind f5 away
bind f9 _visitaircweb
bind f10 setup
bind f12 showmirc -t
bind sf2 join -i
bind sf3 clearall
bind sf9 _downloadlastairc
bind sf10 cprot
bind sf11 identd on airc
bind cf9 _visitwebboard
bind cf10 pprot
}
;/**********************************************************************
; *
; * aIRC
; * DCC Chat Ping
; *
; **********************************************************************/
alias dccping {
if ($_dcctotal.chat == 0) {
error.a No active DCC Chats
return
}
var %t = $iif($chat($_activequery),$_activequery),%chats = $_chats,%n
%n = $_selectedit($iif($1 != $null,$1,%t),1,DCC Chat Ping [/dccping],ischat,$null,32,%chats,DCC Chat session:)
if ($chat(%n) != $null) { msg = $+ $ifmatch PING $ticks }
else { error.a You must specify a valid DCC Chat session }
}
ON &*:CHAT:*:{
if ($2- isnum) && ($2- > 0) && ($len($2-) <= 30) {
if (PING* iswm $strip($remove($1,))) { msg = $+ $nick $replace($1-,PING,PONG) }
elseif ($1 == PONG) || ($1 == PONG) { echo.w $colour(info) = $+ $nick $^*** [DCC Chat Lag: $nick $+ ] $_lagtime($2) }
}
}
;/**********************************************************************
; *
; * aIRC
; * IP Chat
; *
; **********************************************************************/
alias ipchat {
unset %c.ipchat.*
%c.ipchat.n = $_parameter($1,1,I.P. DCC Chat [/ipchat],1,$_activequery,Nick | I.P.:)
%c.ipchat.ip = $iif(. isin %c.ipchat.n,%c.ipchat.n,$_gethost(%c.ipchat.n))
if (%c.ipchat.ip == $null) || ($_isip(%c.ipchat.ip) == $null) { .dns %c.ipchat.n }
else {
dcc chat %c.ipchat.ip
unset %c.ipchat.*
}
}
ON *:DNS:{
if (%c.ipchat.n != $null) && ($nick == %c.ipchat.n) {
if ($iaddress) { .dcc chat $iaddress }
else { .dcc chat %c.ipchat.n }
unset %c.ipchat.*
halt
}
elseif (%c.ipchat.ip != $null) && ((%c.ipchat.ip == $iaddress) || (%c.ipchat.ip == $naddress)) {
if ($iaddress) { .dcc chat $iaddress }
else { .dcc chat %c.ipchat.n }
unset %c.ipchat.*
halt
}
}
;/**********************************************************************
; *
; * aIRC
; * Text Preview Window
; *
; **********************************************************************/
; /_txtpreviewin x y w h parentdialog monitordid did flags alias
alias _txtpreviewin {
var %xywh = $1-4,%dname = $5,%md = $6,%did = $7,%flags = $8,%alias = $9,%win = @Preview - $+ $replace($dialog(%dname).title,$chr(32), )
if ($dialog(%dname) == $null) { return }
if ($window(%win)) { close -@ %win }
window -adok %win %xywh
dialog -v %dname
_setd junk txtpreviewin %win $1-
_txtpreviewin.refresh %win -r
}
alias _txtpreviewin.refresh {
var %win = $1,%cflags = $2
.timer_txtpreviewin $+ %win off
if ($window(%win)) {
tokenize 32 $_get(junk,txtpreviewin,%win)
var %xywh = $1-4,%dname = $5,%md = $6,%did = $7,%flags = $8,%alias = $9,%result
if ($dialog(%dname)) {
if (r isin %cflags) {
clear %win
%alias $did(%dname,%did)
if ($result != $null) {
var %line = $replace($ifmatch,$crlf,$cr)
var %i = 1,%n = $numtok(%line,13)
while (%i <= %n) {
aline -p %win $gettok(%line,%i,13)
inc %i
}
}
}
.timer_txtpreviewin $+ %win -o 1 1 _txtpreviewin.refresh %win -
}
else { close -@ %win }
}
}