Skip to content

Commit dbea1f1

Browse files
committed
Release 1.0.2
1 parent 382046a commit dbea1f1

2 files changed

Lines changed: 239 additions & 0 deletions

File tree

_libs/python/esc/__init__.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Thx to Ayuto
2+
# Version 1.1
3+
# [+] More Colors
4+
# [+] Public variables
5+
# [FIX] Displaying color-codes in console
6+
version = '1.1'
7+
8+
# =============================================================================
9+
# >> Imports
10+
# =============================================================================
11+
import es
12+
from configobj import ConfigObj
13+
import usermsg
14+
import re
15+
16+
# =============================================================================
17+
# >> GLOBALS
18+
# =============================================================================
19+
CUSTOMCOLORS_PATH = '_libs/python/esc/colors.ini'
20+
colors = ConfigObj(es.getAddonPath(CUSTOMCOLORS_PATH))
21+
22+
# =============================================================================
23+
# >> Format Colors
24+
# =============================================================================
25+
def formatColor(r, g, b, a=255):
26+
return '\x08%02X%02X%02X%02X'% (r, g, b, a)
27+
28+
def format(message):
29+
# > Find Colors
30+
re1='(#)' # Any Single Character 1
31+
re2='(\\d+)' # Integer Number 1
32+
re3='(,)' # Any Single Character 2
33+
re4='(\\d+)' # Integer Number 2
34+
re5='(,)' # Any Single Character 3
35+
re6='(\\d+)' # Integer Number 3
36+
37+
rg = re.compile(re1+re2+re3+re4+re5+re6,re.IGNORECASE|re.DOTALL)
38+
m = re.findall(rg,message)
39+
# > Format
40+
for match in m:
41+
# > Get
42+
h,r,k1,g,k2,b= match
43+
# > Format
44+
r = int(r)
45+
g = int(g)
46+
b = int(b)
47+
# > Make Color-String
48+
message = message.replace(''.join(map(str,match)), formatColor(r,g,b))
49+
50+
# > Custom Colors
51+
for color in colors:
52+
r,g,b = tuple(colors[color])
53+
r = int(r)
54+
g = int(g)
55+
b = int(b)
56+
message = message.replace(color, formatColor(r,g,b))
57+
58+
return message
59+
60+
# =============================================================================
61+
# >> Tell-Function
62+
# =============================================================================
63+
def tell(userid, message):
64+
if not es.getuserid(userid):
65+
return
66+
67+
usermsg.saytext2(userid, 0, '\x01'+format(message))
68+
69+
# =============================================================================
70+
# >> Message-Function
71+
# =============================================================================
72+
def msg(message):
73+
usermsg.saytext2('#all', 0, '\x01'+format(message))
74+
75+
# =============================================================================
76+
# >> Public Variable
77+
# =============================================================================
78+
es.set('esc_version', version)
79+
es.makepublic('esc_version')

_libs/python/esc/colors.ini

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# Counter-Strike Source colors
2+
"#default" = 255, 179, 0
3+
"#green" = 255, 61, 61
4+
"#lightgreen" = 155, 255, 155
5+
"#darkgreen" = 158, 195, 79
6+
"#red" = 255, 61, 61
7+
"#blue" = 155, 205, 255
8+
"#white" = 205, 205, 205
9+
10+
# Blue
11+
"#AliceBlue" = 240, 248, 255
12+
"#BlueViolet" = 138, 43, 226
13+
"#CadetBlue" = 95, 158, 160
14+
"#CornflowerBlue" = 100, 149, 237
15+
"#DarkBlue" = 0, 0, 139
16+
"#DarkCyan" = 0, 139, 139
17+
"#DarkSlateBlue" = 72, 61, 139
18+
"#DarkTurquoise" = 0, 206, 209
19+
"#DeepSkyBlue" = 0, 191, 255
20+
"#DodgerBlue" = 30, 144, 255
21+
"#LightBlue" = 173, 216, 230
22+
"#LightCyan" = 224, 255, 255
23+
"#LightSkyBlue" = 135, 206, 250
24+
"#LightSlateBlue" = 132, 112, 255
25+
"#LightSteelBlue" = 176, 196, 222
26+
"#MediumAquamarine" = 102, 205, 170
27+
"#MediumBlue" = 0, 0, 205
28+
"#MediumSlateBlue" = 123, 104, 238
29+
"#MediumTurquoise" = 72, 209, 204
30+
"#MidnightBlue" = 25, 25, 112
31+
"#NavyBlue" = 0, 0, 128
32+
"#PaleTurquoise" = 175, 238, 238
33+
"#PowderBlue" = 176, 224, 230
34+
"#RoyalBlue" = 65, 105, 225
35+
"#SkyBlue" = 135, 206, 235
36+
"#SlateBlue" = 106, 90, 205
37+
"#SteelBlue" = 70, 130, 180
38+
"#aquamarine" = 127, 255, 212
39+
"#azure" = 240, 255, 255
40+
"#Blue" = 0, 0, 255, # Upper B to solve conflict with #blue
41+
"#cyan" = 0, 255, 255
42+
"#navy" = 0, 0, 128
43+
"#turquoise" = 64, 224, 208
44+
45+
# Brown
46+
"#RosyBrown" = 188, 143, 143
47+
"#SaddleBrown" = 139, 69, 19
48+
"#SandyBrown" = 244, 164, 96
49+
"#beige" = 245, 245, 220
50+
"#brown" = 165, 42, 42
51+
"#burlywood" = 222, 184, 135
52+
"#chocolate" = 210, 105, 30
53+
"#peru" = 205, 133, 63
54+
"#tan" = 210, 180, 140
55+
56+
# Gray
57+
"#DarkSlateGray" = 47, 79, 79
58+
"#DimGrey" = 105, 105, 105
59+
"#LightGrey" = 211, 211, 211
60+
"#LightSlateGrey" = 119, 136, 153
61+
"#SlateGrey" = 112, 128, 144
62+
"#grey" = 190, 190, 190
63+
64+
# Green
65+
"#DarkGreen" = 0, 100, 0
66+
"#DarkKhaki" = 189, 183, 107
67+
"#DarkOliveGreen" = 85, 107, 47
68+
"#DarkSeaGreen" = 143, 188, 143
69+
"#ForestGreen" = 34, 139, 34
70+
"#GreenYellow" = 173, 255, 47
71+
"#LawnGreen" = 124, 252, 0
72+
"#LightGreen" = 144, 238, 144
73+
"#LightSeaGreen" = 32, 178, 170
74+
"#LimeGreen" = 50, 205, 50
75+
"#MediumSeaGreen" = 60, 179, 113
76+
"#MediumSpringGreen" = 0, 250, 154
77+
"#MintCream" = 245, 255, 250
78+
"#OliveDrab" = 107, 142, 35
79+
"#PaleGreen" = 152, 251, 152
80+
"#SeaGreen" = 46, 139, 87
81+
"#SpringGreen" = 0, 255, 127
82+
"#YellowGreen" = 154, 205, 50
83+
"#chartreuse" = 127, 255, 0
84+
"#Green" = 0, 255, 0, # Upper G to solve conflict with default #green
85+
"#khaki" = 240, 230, 140
86+
87+
# Orange
88+
"#DarkOrange" = 255, 140, 0
89+
"#DarkSalmon" = 233, 150, 122
90+
"#LightCoral" = 240, 128, 128
91+
"#LightSalmon" = 255, 160, 122
92+
"#PeachPuff" = 255, 218, 185
93+
"#bisque" = 255, 228, 196
94+
"#coral" = 255, 127, 80
95+
"#honeydew" = 240, 255, 240
96+
"#orange" = 255, 165, 0
97+
"#salmon" = 250, 128, 114
98+
"#sienna" = 160, 82, 45
99+
100+
# Red
101+
"#DarkRed" = 139, 0, 0
102+
"#DeepPink" = 255, 20, 147
103+
"#HotPink" = 255, 105, 180
104+
"#IndianRed" = 205, 92, 92
105+
"#LightPink" = 255, 182, 193
106+
"#MediumVioletRed" = 199, 21, 133
107+
"#MistyRose" = 255, 228, 225
108+
"#OrangeRed" = 255, 69, 0
109+
"#PaleVioletRed" = 219, 112, 147
110+
"#VioletRed" = 208, 32, 144
111+
"#firebrick" = 178, 34, 34
112+
"#pink" = 255, 192, 203
113+
"#Red" = 255, 0, 0, # Upper R to solve conflict with #red
114+
"#tomato" = 255, 99, 71
115+
116+
# Violette
117+
"#DarkMagenta" = 139, 0, 139
118+
"#DarkOrchid" = 153, 50, 204
119+
"#DarkViolet" = 148, 0, 211
120+
"#LavenderBlush" = 255, 240, 245
121+
"#MediumOrchid" = 186, 85, 211
122+
"#MediumPurple" = 147, 112, 219
123+
"#lavender" = 230, 230, 250
124+
"#magenta" = 255, 0, 255
125+
"#maroon" = 176, 48, 96
126+
"#orchid" = 218, 112, 214
127+
"#plum" = 221, 160, 221
128+
"#purple" = 160, 32, 240
129+
"#thistle" = 216, 191, 216
130+
"#violet" = 238, 130, 238
131+
132+
# White
133+
"#AntiqueWhite" = 250, 235, 215
134+
"#FloralWhite" = 255, 250, 240
135+
"#GhostWhite" = 248, 248, 255
136+
"#NavajoWhite" = 255, 222, 173
137+
"#OldLace" = 253, 245, 230
138+
"#WhiteSmoke" = 245, 245, 245
139+
"#gainsboro" = 220, 220, 220
140+
"#ivory" = 255, 255, 240
141+
"#linen" = 250, 240, 230
142+
"#seashell" = 255, 245, 238
143+
"#snow" = 255, 250, 250
144+
"#wheat" = 245, 222, 179
145+
"#White" = 255, 255, 255, # Upper W to solve conflict with #white
146+
147+
# Yellow
148+
"#BlanchedAlmond" = 255, 235, 205
149+
"#DarkGoldenrod" = 184, 134, 11
150+
"#LemonChiffon" = 255, 250, 205
151+
"#LightGoldenrod" = 238, 221, 130
152+
"#LightGoldenrodYellow" = 250, 250, 210
153+
"#LightYellow" = 255, 255, 224
154+
"#PaleGoldenrod" = 238, 232, 170
155+
"#PapayaWhip" = 255, 239, 213
156+
"#cornsilk" = 255, 248, 220
157+
"#gold" = 255, 215, 0
158+
"#goldenrod" = 218, 165, 32
159+
"#moccasin" = 255, 228, 181
160+
"#yellow" = 255, 255, 0

0 commit comments

Comments
 (0)