atma/contrib/1.393-cpM/formatStr/formatstr.sa

178 lines
4.9 KiB
Text
Executable file
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#formatstr.sa off
[addon]
name=FormatString parsing engine
id=formatstr
category=FileServing
version=2.2a-sa
author=Correl J. Roush
helpfile=formatStr.hlp
[dirs]
1=Profiles
[scriptfiles]
1=formatstr.sa
[miscfiles]
1=formatStr.hlp
2=Profiles\^profile_Atma.hsh
3=Profiles\^profile_away.hsh
4=Profiles\^profile_GreetZ.hsh
5=Profiles\^profile_nickComp.hsh
6=Profiles\^profile_standard.hsh
7=Profiles\^theme_phoenix.hsh
[configfiles]
[formatstr.sa]
#formatstr.sa off
on *:start:{
^formatstr.loadprofiles
}
alias ^formatstr.version { return $readini($script,addon,version) }
alias ^formatstr.help { run $scriptdirformatStr.hlp }
alias ^formatstr.loadprofiles {
$iif($hget(^formatstr.profiles),hfree ^formatstr.profiles)
.echo -q $findfile($scriptdirProfiles,*.hsh,0,0, loadprofile.appendtomaster $1-)
}
alias -l loadprofile.appendtomaster {
$iif(!$hget(^formatstr.profiles),hmake ^formatstr.profiles 100)
hload ^formatstr.profiles " $+ $1- $+ "
hadd ^formatstr.profiles profiles $addtok($hget(^formatstr.profiles,profiles),$hget(^formatstr.profiles,_name),44)
;echo -s Loaded $hget(^formatstr.profiles,_name) profile for the Phoenix FormatString Parser
hdel ^formatstr.profiles _name
}
alias parse_formatstr {
; $1 == word to format
; $2 == format string
var %counter = 1
%formattedstr = $2
while (%counter <= $hget(^formatstr.profiles,0).item) {
%formattedstr = $replace(%formattedstr,$hget(^formatstr.profiles,%counter).item,$eval($hget(^formatstr.profiles,$hget(^formatstr.profiles,%counter).item),2))
inc %counter
}
%formattedstr = $regex_stylefn(%formattedstr)
if ($nickComp(stripcolor)) { %formattedstr = $strip(%formattedstr,c) }
return %formattedstr $+ 
}
alias -l ^R {
;RandomStyle
%counter = 1
unset %randomstyle_output
while (%counter <= $len($1-)) {
%randomstyle_code = $gettok(>>,$rand(1,3),62)
;$iif(%randomstyle_code == , %randomstyle_code = %randomstyle_code $+ $rand(0,15))
%randomstyle_output = %randomstyle_output $+ %randomstyle_code $+ $iif($mid($1-,%counter,1) == $chr(32),$chr(1),$mid($1-,%counter,1))
inc %counter
}
return $replace(%randomstyle_output,$chr(1),$chr(32)) $+ 
}
alias -l ^C {
;CycleStyle
%counter = 1
unset %cyclestyle_output
while (%counter <= $len($1-)) {
%cyclestyle_code = $gettok(>>,$calc((%counter % 3) + 1),62)
%cyclestyle_output = %cyclestyle_output $+ %cyclestyle_code $+ $iif($mid($1-,%counter,1) == $chr(32),$chr(1),$mid($1-,%counter,1))
inc %counter
}
return $replace(%cyclestyle_output,$chr(1),$chr(32)) $+ 
}
alias -l ^M {
;RandomCase
%counter = 1
unset %randomcase_output
while (%counter <= $len($1-)) {
%randomcase = $rand(1,2)
if (%randomcase == 1) {
%randomcase_output = %randomcase_output $+ $iif($mid($1-,%counter,1) == $chr(32),$chr(1),$upper($mid($1-,%counter,1)))
}
else {
%randomcase_output = %randomcase_output $+ $iif($mid($1-,%counter,1) == $chr(32),$chr(1),$lower($mid($1-,%counter,1)))
}
inc %counter
}
return $replace(%randomcase_output,$chr(1),$chr(32))
}
alias -l ^N {
;CycleCase
%counter = 1
unset %cyclecase_output
while (%counter <= $len($1-)) {
inc %cyclecase
if ($calc(%cyclecase % 2) == 1) {
%cyclecase_output = %cyclecase_output $+ $iif($mid($1-,%counter,1) == $chr(32),$chr(1),$upper($mid($1-,%counter,1)))
}
else {
%cyclecase_output = %cyclecase_output $+ $iif($mid($1-,%counter,1) == $chr(32),$chr(1),$lower($mid($1-,%counter,1)))
}
inc %counter
}
return $replace(%cyclecase_output,$chr(1),$chr(32))
}
alias -l ^U {
return $upper($1-)
}
alias -l ^L {
return $lower($1-)
}
alias -l ^E {
;l33tstyle
%leetstyle = $replacecs($1-, $&
AE,$chr(198), $&
f,F, F,ph, $&
ck,x0r, $&
cks,x0rz $&
)
%leetstyle = $replacecs(%leetstyle, $&
a,A, A,4, $&
B,$chr(223), $&
c,$chr(162), C,$chr(169), $&
d,D, D,| $+ $chr(41), $&
e,E, E,3, $&
H,$chr(124) $+ - $+ $chr(124), $&
i,I, I,1, $&
K,$chr(124) $+ $chr(139), $&
l,L, L,$chr(163), $&
M,$chr(40) $+ \/ $+ $chr(41), $&
N,$chr(124) $+ \ $+ $chr(124), $&
o,$chr(248), O,0, $&
p,P, P,$chr(182), $&
Q,$chr(40) $+ $chr(44) $+ $chr(41), $&
S,5, $&
t,+, T,7, $&
u,$chr(181), U,$chr(124) $+ _ $+ $chr(124), $&
W,`//, $&
x,$chr(215) $&
)
return %leetstyle
}
alias -l regex_stylefn {
.echo -q $regsub($1-,/\\}/g,$chr(1),%stylefn)
%stylefn = $replace(%stylefn, $chr(32),$chr(5))
while ($regex(%stylefn,/{([CRULMNE]):(.*?):\1}/i)) {
.echo -q $regsub(%stylefn,/{([CRULMNE]):(.*?):\1}/gi,$chr(32) $+ $cr $lf $+ \1(\2) $cr $+ $chr(32),%stylefn)
}
return $replace($eval($replace(%stylefn, $cr,$!+, $lf,$!^, $chr(1),$chr(125)),2),$chr(5),$chr(32))
}