# *********** Paste the following section into auto_include.ms ***********
#Random Code Generation
export('codegen.version', '2.0')
proc(_codegen, @codelength, @codetype, @codetype2,
#How to use:
# call _codegen(NUMBER, character type 1, character type 2)
# The number determines how long the code is, and the 2 types determine which types of characters you want.
# Character types: lowercase ("lower"), uppercase ("upper"), number ("num"), or all.
#--- User Input Checks
if(@codelength == '' ||
is_numeric(@codelength) == false){
}
if(@codetype == ''){
@codetype = full
}
#--- List of Characters
assign(@lower, array(a
,b
,c
,d
,e
,f
,g
,h
,i
,j
,k
,l
,m
,n
,o
,p
,q
,r
,s
,t
,u
,v
,w
,x
,y
,z
))
assign(@upper, array(A
,B
,C
,D
,E
,F
,G
,H
,I
,J
,K
,L
,M
,N
,O
,P
,Q
,R
,S
,T
,U
,V
,W
,X
,Y
,Z
))
assign(@full, array(a
,b
,c
,d
,e
,f
,g
,h
,i
,j
,k
,l
,m
,n
,o
,p
,q
,r
,s
,t
,u
,v
,w
,x
,y
,z
,A
,B
,C
,D
,E
,F
,G
,H
,I
,J
,K
,L
,M
,N
,O
,P
,Q
,R
,S
,T
,U
,V
,W
,X
,Y
,Z
,1,2,3,4,5,6,7,8,9))
#--- Character Set 1
case lower:
case l:
case low:
case upper:
case u:
case up:
case number:
case n:
case '#':
case num:
case full:
case all:
default:
die(color(3).
' - '.color
(4).
'Fail:'.color
(3).
' Invalid code type given (1)')
}
#--- Character Set 2
if(@codetype2 !== '',
case lower:
case l:
case low:
case upper:
case u:
case up:
case number:
case n:
case '#':
case num:
case full:
case all:
default:
die(color(3).
' - '.color
(4).
'Fail:'.color
(3).
' Invalid code type given (2)')
}
foreach(@chars2, @i,
)
)
#--- Generate code
for(@i = 0, @i < @codelength, @i++,
)
)
# *********** Paste the following section into aliases.msa ***********
everyone:/codegen [$length] [$type1] [$type2] [$] = >>>
proc(_codegen_help,
msg(color(7).
'/codegen'.color
(3).
' - '.color
(f
).
'Prints a randomly generated code. Defaults to a code 7 characters in length using uppercase, lowercase, and numbers.')
msg(color(a
).
'Command usage: <required> [optional]')
msg(color(3).
'/codegen [length] [Character type 1] [Character type 2]')
msg(color(3).
' - '.color
(f
).
' You can specify how many characters the code should be, and specify the types of characters.')
msg(color(3).
' - '.color
(f
).
' Character types: lowercase ("lower"), uppercase ("upper"), number ("num"), or all.')
)
switch($length){
case help:
case -help:
case ?:
case '/?':
_codegen_help()
default:
assign(@code, _codegen
($length, $type1, $type2))
msg(color(7).
'['.color
(6).
'CodeGen'.color
(7).
'] '.color
(7).
'Random generated code at '.simple_date
(E.
', '.h.
':'.m.
':'.s.
'.'.S.
' '.a
).
':')
}
<<<