View difference between Paste ID: NDVwGEJT and msx6xN1g
SHOW: | | - or go back to the newest paste.
1
// TLD LIST
2
3
tld = [
4
AC AD AE AF AG AI AL AM AO AR AS ASIA AT AU AW AX AZ BA BB BD BE BF BG BH
5-
strtochar = [
5+
BI BIZ BJ BM BN BO BR BS BT BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO
6-
	temp = ""
6+
COM CR CU CV CX CY CZ DE DJ DK DM DO DZ EC EDU EE EG ER ES ET EU FI FJ FK
7
FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN
8-
		append temp (format ["%1"] (substr $arg1 $c 1))
8+
HR HT HU ID IE IL IM IN INFO IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN
9
KP KR KW KY KZ LB LC LI LK LR LS LT LU LV LY MA MC ME MG MH ML MM MN MO MP
10-
	result $temp
10+
MQ MR MS MT MU MV MW MX MY MZ NA NC NE NET NF NG NI NL NO NP NR NU NZ OM
11
ORG PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC
12
SD SE SG SH SI SK SL SM SN SO SR ST SU SV SY SZ TC TD TG TH TJ TK TL TM TN
13
TO TP TR TT TV TW TZ UA UG UK US UY UZ VC VE VG VI VN VU WF WS YE YT ZA ZM ZW
14
]
15
16
//----------------------------------
17
18
// Some generic commands that may be used elsewhere
19
20
createine = [ if (=s (getalias $arg1) "") [ $arg1 = $arg2 ] ]
21
append = [$arg1 = (concat (getalias $arg1) $arg2)]
22
isnum = [
23-
			< (listfind p (strtochar $arg1) [< (indexof "0 1 2 3 4 5 6 7 8 9 ." $p) 0]) 0
23+
	bool = 1
24
	loop c (strlen $arg1) [
25
		if (< (strstr "0123456789." (substr $arg1 $c 1)) 0) [bool = 0]
26
	]
27
	result $bool
28
]
29
30
// Ugly and could use many improvements, but for
31
// the most part, it does its job pretty nicely
32-
createine qc_sel      ""
32+
33
isip = [
34
	result (
35
		&& (
36-
qc_findserv = [listfind i $qc_servlist [=s @arg1 (at $i 0)]]
36+
37
		) (
38
			< (listfind i (strreplace $arg1 . " ") [|| (> $i 255) (< $i 0)]) 0
39
		) (isnum $arg1)
40
	)
41
]
42
43
// Alias variables for the first use
44
45
createine qc_servlist ""
46
createine qc_servname ""
47
48-
addqcserv = [
48+
49
50
qc_findserv = [listfind i $qc_servlist [=s $arg1 (at $i 0)]]
51
qc_complete = [
52
	qc_servname = ""
53-
			? (< (indexof "com org net de us" (at (strreplace $arg2 . " ") (- (listlen (strreplace $arg2 . " ")) 1))) 0) (! (isip $arg2))
53+
54
	qc_servname = (substr $qc_servname 1)
55
	listcomplete qc $qc_servname
56-
		error "^f3Invalid IP was rejected!"
56+
57
	listcomplete viewqcserv $qc_servname
58
]
59
qc_info = [
60-
				? (>= @numargs 2) @arg2 (connectedip)
60+
61
	echo (format "^f7Name: ^f2%1 ^f7%2: ^f2%3 ^f7Port: ^f2%4" (at $qc_sel 0) (? (isip (at $qc_sel 1)) IP Domain) (at $qc_sel 1) (at $qc_sel 2))
62-
				? (> @numargs 2) @arg3 (? (isconnected) (connectedport) 28785)
62+
63
64
// Below here lies the magic, user commands.
65
66
qcaddserv = [
67
	cond (|| (> (qc_findserv $arg1) -1) (isip $arg1)) [
68
		error "^f3QC entry already exists or is invalid!"
69
	] (
70-
delqcserv = [
70+
71
			? (< (indexof $tld (at (strreplace $arg2 . " ") (- (listlen (strreplace $arg2 . " ")) 1))) 0) (! (isip $arg2))
72
		) (! (isconnected))
73
	) [
74
		error "^f3IP or Domain is invalid!"
75
	] [
76
		append qc_servlist (
77
			format ["%1 %2 %3"] @arg1 (
78
				? (> @numargs 1) $arg2 (connectedip)
79-
listqcserv = [
79+
80
				? (> @numargs 2) $arg3 (? (isconnected) (connectedport) 28785)
81
			)
82
		)
83-
viewqcserv = [
83+
84
		qc_complete
85
	]
86
]
87
88
qcdelserv = [
89
	if (< (qc_findserv $arg1) 0) [
90
		error "^f3QC entry does not exist!"
91
	] [
92
		qc_servlist = (strreplace $qc_servlist (format ["%1"] (at $qc_servlist (qc_findserv $arg1))) "")
93
		echo "^f2QC ^f7entry has been deleted successfully!"
94
		qc_complete
95
	]
96
]
97
98
qclistserv = [
99
	echo (format "^f2%1^f7 Available servers: ^f2%2" (listlen $qc_servname) (strreplace $qc_servname " " "^f7, ^f2"))
100
]
101
102
qcviewserv = [
103
	if (< (qc_findserv $arg1) 0) [
104
		error "^f3QC entry does not exist!"
105
	] [qc_info $arg1]
106
]
107
108
qcviewservall = [
109
	if (!=s $qc_servlist "") [
110
		looplist i $qc_servname [qc_info $i]
111
	] [error "^f3No registered entries!"]
112
]
113
114
qc = [
115
	if (!=s $qc_servlist "") [
116
		connect (at (at $qc_servlist (qc_findserv $arg1)) 1) (at (at $qc_servlist (qc_findserv $arg1)) 2)
117
	] [error "^f3No registered entries!"]
118
]
119
120
// Compile tab completion upon execution, just in case
121
122
qc_complete
123