forked from cyberkitsune/PSO2Proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPSO2DataTools.py
More file actions
562 lines (525 loc) · 20 KB
/
Copy pathPSO2DataTools.py
File metadata and controls
562 lines (525 loc) · 20 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
# Should this file even be in here?
# -*- coding: utf-8 -*-
from twisted.python import log
PSO2_IRC = [
("{red}", "\x03""04"), # Red
("{blu}", "\x03""02"), # Blue
("{blue}", "\x03""02"), # Blue
("{gre}", "\x03""03"), # green
("{green}", "\x03""03"), # green
("{grn}", "\x03""03"), # green
("{gree}", "\x03""03"), # green
("{yel}", "\x03""08"), # yellow
("{yellow}", "\x03""08"), # yellow
("{ora}", "\x03""07"), # orange (olive)
("{orange}", "\x03""07"), # orange (olive)
("{org}", "\x03""07"), # orange (olive)
("{pur}", "\x03""06"), # purple
("{purple}", "\x03""06"), # purple
("{vir}", "\x03""06"), # purple
("{vio}", "\x03""13"), # Violet
("{violet}", "\x03""13"), # Violet
("{bei}", "\x03""05"), # Beige
("{beige}", "\x03""05"), # Beige
("{gra}", "\x03""14"), # grey
("{gray}", "\x03""14"), # grey
("{gra}", "\x03""14"), # grey
("{gry}", "\x03""14"), # grey
("{bla}", "\x03""14"), # grey
("{ble}", "\x03""14"), # grey
("{bra}", "\x03""14"), # grey
("{whi}", "\x03""00"), # white
("{white}", "\x03""00"), # white
("{whit}", "\x03""00"), # white
("{blk}", "\x03""01"), # black
("{black}", "\x03""01"), # black
("{pla}", "\x03""01"), # black
("{def}", "\x0F"), # colour reset
]
IRC_PSO2 = [
# Color text on white background
("\x03""00,00", "{whi}"), # white
("\x03""01,00", "{blk}"), # black
("\x03""02,00", "{blu}"), # blue (navy)
("\x03""03,00", "{gre}"), # green
("\x03""04,00", "{red}"), # red
("\x03""05,00", ""), # brown (maroon)
("\x03""06,00", "{pur}"), # purple
("\x03""07,00", "{ora}"), # orange (olive)
("\x03""08,00", "{yel}"), # yellow
("\x03""09,00", ""), # light green (lime)
("\x03""10,00", ""), # teal (a green/blue cyan)
("\x03""11,00", ""), # light cyan (cyan) (aqua)
("\x03""12,00", ""), # light blue (royal)
("\x03""13,00", "{vio}"), # pink (light purple) (fuchsia)
("\x03""14,00", "{gra}"), # grey
("\x03""15,00", ""), # light grey (silver)
("\x03""99,00", ""), # transparent
# Color text on black background
("\x03""00,01", "{whi}"), # white
("\x03""01,01", "{blk}"), # black
("\x03""02,01", "{blu}"), # blue (navy)
("\x03""03,01", "{gre}"), # green
("\x03""04,01", "{red}"), # red
("\x03""05,01", ""), # brown (maroon)
("\x03""06,01", "{pur}"), # purple
("\x03""07,01", "{ora}"), # orange (olive)
("\x03""08,01", "{yel}"), # yellow
("\x03""09,01", ""), # light green (lime)
("\x03""10,01", ""), # teal (a green/blue cyan)
("\x03""11,01", ""), # light cyan (cyan) (aqua)
("\x03""12,01", ""), # light blue (royal)
("\x03""13,01", "{vio}"), # pink (light purple) (fuchsia)
("\x03""14,01", "{gra}"), # grey
("\x03""15,01", ""), # light grey (silver)
("\x03""99,01", ""), # transparent
# Color text on blue background
("\x03""00,02", "{whi}"), # white
("\x03""01,02", "{blk}"), # black
("\x03""02,02", "{blu}"), # blue (navy)
("\x03""03,02", "{gre}"), # green
("\x03""04,02", "{red}"), # red
("\x03""05,02", ""), # brown (maroon)
("\x03""06,02", "{pur}"), # purple
("\x03""07,02", "{ora}"), # orange (olive)
("\x03""08,02", "{yel}"), # yellow
("\x03""09,02", ""), # light green (lime)
("\x03""10,02", ""), # teal (a green/blue cyan)
("\x03""11,02", ""), # light cyan (cyan) (aqua)
("\x03""12,02", ""), # light blue (royal)
("\x03""13,02", "{vio}"), # pink (light purple) (fuchsia)
("\x03""14,02", "{gra}"), # grey
("\x03""15,02", ""), # light grey (silver)
("\x03""99,02", ""), # transparent
# Color text on green background
("\x03""00,03", "{whi}"), # white
("\x03""01,03", "{blk}"), # black
("\x03""02,03", "{blu}"), # blue (navy)
("\x03""03,03", "{gre}"), # green
("\x03""04,03", "{red}"), # red
("\x03""05,03", ""), # brown (maroon)
("\x03""06,03", "{pur}"), # purple
("\x03""07,03", "{ora}"), # orange (olive)
("\x03""08,03", "{yel}"), # yellow
("\x03""09,03", ""), # light green (lime)
("\x03""10,03", ""), # teal (a green/blue cyan)
("\x03""11,03", ""), # light cyan (cyan) (aqua)
("\x03""12,03", ""), # light blue (royal)
("\x03""13,03", "{vio}"), # pink (light purple) (fuchsia)
("\x03""14,03", "{gra}"), # grey
("\x03""15,03", ""), # light grey (silver)
("\x03""99,03", ""), # transparent
# Color text on red background
("\x03""00,04", "{whi}"), # white
("\x03""01,04", "{blk}"), # black
("\x03""02,04", "{blu}"), # blue (navy)
("\x03""03,04", "{gre}"), # green
("\x03""04,04", "{red}"), # red
("\x03""05,04", ""), # brown (maroon)
("\x03""06,04", "{pur}"), # purple
("\x03""07,04", "{ora}"), # orange (olive)
("\x03""08,04", "{yel}"), # yellow
("\x03""09,04", ""), # light green (lime)
("\x03""10,04", ""), # teal (a green/blue cyan)
("\x03""11,04", ""), # light cyan (cyan) (aqua)
("\x03""12,04", ""), # light blue (royal)
("\x03""13,04", "{vio}"), # pink (light purple) (fuchsia)
("\x03""14,04", "{gra}"), # grey
("\x03""15,04", ""), # light grey (silver)
("\x03""99,04", ""), # transparent
# Color text on brown background
("\x03""00,05", "{whi}"), # white
("\x03""01,05", "{blk}"), # black
("\x03""02,05", "{blu}"), # blue (navy)
("\x03""03,05", "{gre}"), # green
("\x03""04,05", "{red}"), # red
("\x03""05,05", ""), # brown (maroon)
("\x03""06,05", "{pur}"), # purple
("\x03""07,05", "{ora}"), # orange (olive)
("\x03""08,05", "{yel}"), # yellow
("\x03""09,05", ""), # light green (lime)
("\x03""10,05", ""), # teal (a green/blue cyan)
("\x03""11,05", ""), # light cyan (cyan) (aqua)
("\x03""12,05", ""), # light blue (royal)
("\x03""13,05", "{vio}"), # pink (light purple) (fuchsia)
("\x03""14,05", "{gra}"), # grey
("\x03""15,05", ""), # light grey (silver)
("\x03""99,05", ""), # transparent
# Color text on purple background
("\x03""00,06", "{whi}"), # white
("\x03""01,06", "{blk}"), # black
("\x03""02,06", "{blu}"), # blue (navy)
("\x03""03,06", "{gre}"), # green
("\x03""04,06", "{red}"), # red
("\x03""05,06", ""), # brown (maroon)
("\x03""06,06", "{pur}"), # purple
("\x03""07,06", "{ora}"), # orange (olive)
("\x03""08,06", "{yel}"), # yellow
("\x03""09,06", ""), # light green (lime)
("\x03""10,06", ""), # teal (a green/blue cyan)
("\x03""11,06", ""), # light cyan (cyan) (aqua)
("\x03""12,06", ""), # light blue (royal)
("\x03""13,06", "{vio}"), # pink (light purple) (fuchsia)
("\x03""14,06", "{gra}"), # grey
("\x03""15,06", ""), # light grey (silver)
("\x03""99,06", ""), # transparent
# Color text on orange background
("\x03""00,07", "{whi}"), # white
("\x03""01,07", "{blk}"), # black
("\x03""02,07", "{blu}"), # blue (navy)
("\x03""03,07", "{gre}"), # green
("\x03""04,07", "{red}"), # red
("\x03""05,07", ""), # brown (maroon)
("\x03""06,07", "{pur}"), # purple
("\x03""07,07", "{ora}"), # orange (olive)
("\x03""08,07", "{yel}"), # yellow
("\x03""09,07", ""), # light green (lime)
("\x03""10,07", ""), # teal (a green/blue cyan)
("\x03""11,07", ""), # light cyan (cyan) (aqua)
("\x03""12,07", ""), # light blue (royal)
("\x03""13,07", "{vio}"), # pink (light purple) (fuchsia)
("\x03""14,07", "{gra}"), # grey
("\x03""15,07", ""), # light grey (silver)
("\x03""99,07", ""), # transparent
# Color text on light yelll background
("\x03""00,08", "{whi}"), # white
("\x03""01,08", "{blk}"), # black
("\x03""02,08", "{blu}"), # blue (navy)
("\x03""03,08", "{gre}"), # green
("\x03""04,08", "{red}"), # red
("\x03""05,08", ""), # brown (maroon)
("\x03""06,08", "{pur}"), # purple
("\x03""07,08", "{ora}"), # orange (olive)
("\x03""08,08", "{yel}"), # yellow
("\x03""09,08", ""), # light green (lime)
("\x03""10,08", ""), # teal (a green/blue cyan)
("\x03""11,08", ""), # light cyan (cyan) (aqua)
("\x03""12,08", ""), # light blue (royal)
("\x03""13,08", "{vio}"), # pink (light purple) (fuchsia)
("\x03""14,08", "{gra}"), # grey
("\x03""15,08", ""), # light grey (silver)
("\x03""99,08", ""), # transparent
# Color text on light green background
("\x03""00,09", "{whi}"), # white
("\x03""01,09", "{blk}"), # black
("\x03""02,09", "{blu}"), # blue (navy)
("\x03""03,09", "{gre}"), # green
("\x03""04,09", "{red}"), # red
("\x03""05,09", ""), # brown (maroon)
("\x03""06,09", "{pur}"), # purple
("\x03""07,09", "{ora}"), # orange (olive)
("\x03""08,09", "{yel}"), # yellow
("\x03""09,09", ""), # light green (lime)
("\x03""10,09", ""), # teal (a green/blue cyan)
("\x03""11,09", ""), # light cyan (cyan) (aqua)
("\x03""12,09", ""), # light blue (royal)
("\x03""13,09", "{vio}"), # pink (light purple) (fuchsia)
("\x03""14,09", "{gra}"), # grey
("\x03""15,09", ""), # light grey (silver)
("\x03""99,09", ""), # transparent
# Color text on teal background
("\x03""00,10", "{whi}"), # white
("\x03""01,10", "{blk}"), # black
("\x03""02,10", "{blu}"), # blue (navy)
("\x03""03,10", "{gre}"), # green
("\x03""04,10", "{red}"), # red
("\x03""05,10", ""), # brown (maroon)
("\x03""06,10", "{pur}"), # purple
("\x03""07,10", "{ora}"), # orange (olive)
("\x03""08,10", "{yel}"), # yellow
("\x03""09,10", ""), # light green (lime)
("\x03""10,10", ""), # teal (a green/blue cyan)
("\x03""11,10", ""), # light cyan (cyan) (aqua)
("\x03""12,10", ""), # light blue (royal)
("\x03""13,10", "{vio}"), # pink (light purple) (fuchsia)
("\x03""14,10", "{gra}"), # grey
("\x03""15,10", ""), # light grey (silver)
("\x03""99,10", ""), # transparent
# Color text on light cyan background
("\x03""00,11", "{whi}"), # white
("\x03""01,11", "{blk}"), # black
("\x03""02,11", "{blu}"), # blue (navy)
("\x03""03,11", "{gre}"), # green
("\x03""04,11", "{red}"), # red
("\x03""05,11", ""), # brown (maroon)
("\x03""06,11", "{pur}"), # purple
("\x03""07,11", "{ora}"), # orange (olive)
("\x03""08,11", "{yel}"), # yellow
("\x03""09,11", ""), # light green (lime)
("\x03""10,11", ""), # teal (a green/blue cyan)
("\x03""11,11", ""), # light cyan (cyan) (aqua)
("\x03""12,11", ""), # light blue (royal)
("\x03""13,11", "{vio}"), # pink (light purple) (fuchsia)
("\x03""14,11", "{gra}"), # grey
("\x03""15,11", ""), # light grey (silver)
("\x03""99,11", ""), # transparent
# Color text on light blue background
("\x03""00,12", "{whi}"), # white
("\x03""01,12", "{blk}"), # black
("\x03""02,12", "{blu}"), # blue (navy)
("\x03""03,12", "{gre}"), # green
("\x03""04,12", "{red}"), # red
("\x03""05,12", ""), # brown (maroon)
("\x03""06,12", "{pur}"), # purple
("\x03""07,12", "{ora}"), # orange (olive)
("\x03""08,12", "{yel}"), # yellow
("\x03""09,12", ""), # light green (lime)
("\x03""10,12", ""), # teal (a green/blue cyan)
("\x03""11,12", ""), # light cyan (cyan) (aqua)
("\x03""12,12", ""), # light blue (royal)
("\x03""13,12", "{vio}"), # pink (light purple) (fuchsia)
("\x03""14,12", "{gra}"), # grey
("\x03""15,12", ""), # light grey (silver)
("\x03""99,12", ""), # transparent
# Color text on pink background
("\x03""00,13", "{whi}"), # white
("\x03""01,13", "{blk}"), # black
("\x03""02,13", "{blu}"), # blue (navy)
("\x03""03,13", "{gre}"), # green
("\x03""04,13", "{red}"), # red
("\x03""05,13", ""), # brown (maroon)
("\x03""06,13", "{pur}"), # purple
("\x03""07,13", "{ora}"), # orange (olive)
("\x03""08,13", "{yel}"), # yellow
("\x03""09,13", ""), # light green (lime)
("\x03""10,13", ""), # teal (a green/blue cyan)
("\x03""11,13", ""), # light cyan (cyan) (aqua)
("\x03""12,13", ""), # light blue (royal)
("\x03""13,13", "{vio}"), # pink (light purple) (fuchsia)
("\x03""14,13", "{gra}"), # grey
("\x03""15,13", ""), # light grey (silver)
("\x03""99,13", ""), # transparent
# Color text on grey background
("\x03""00,14", "{whi}"), # white
("\x03""01,14", "{blk}"), # black
("\x03""02,14", "{blu}"), # blue (navy)
("\x03""03,14", "{gre}"), # green
("\x03""04,14", "{red}"), # red
("\x03""05,14", ""), # brown (maroon)
("\x03""06,14", "{pur}"), # purple
("\x03""07,14", "{ora}"), # orange (olive)
("\x03""08,14", "{yel}"), # yellow
("\x03""09,14", ""), # light green (lime)
("\x03""10,14", ""), # teal (a green/blue cyan)
("\x03""11,14", ""), # light cyan (cyan) (aqua)
("\x03""12,14", ""), # light blue (royal)
("\x03""13,14", "{vio}"), # pink (light purple) (fuchsia)
("\x03""14,14", "{gra}"), # grey
("\x03""15,14", ""), # light grey (silver)
("\x03""99,14", ""), # transparent
# Color text on silver background
("\x03""00,15", "{whi}"), # white
("\x03""01,15", "{blk}"), # black
("\x03""02,15", "{blu}"), # blue (navy)
("\x03""03,15", "{gre}"), # green
("\x03""04,15", "{red}"), # red
("\x03""05,15", ""), # brown (maroon)
("\x03""06,15", "{pur}"), # purple
("\x03""07,15", "{ora}"), # orange (olive)
("\x03""08,15", "{yel}"), # yellow
("\x03""09,15", ""), # light green (lime)
("\x03""10,15", ""), # teal (a green/blue cyan)
("\x03""11,15", ""), # light cyan (cyan) (aqua)
("\x03""12,15", ""), # light blue (royal)
("\x03""13,15", "{vio}"), # pink (light purple) (fuchsia)
("\x03""14,15", "{gra}"), # grey
("\x03""15,15", ""), # light grey (silver)
("\x03""99,15", ""), # transparent
# Color text on restored defaulted background
("\x03""00,", "{whi}"), # white
("\x03""01,", "{blk}"), # black
("\x03""02,", "{blu}"), # blue (navy)
("\x03""03,", "{gre}"), # green
("\x03""04,", "{red}"), # red
("\x03""05,", ""), # brown (maroon)
("\x03""06,", "{pur}"), # purple
("\x03""07,", "{ora}"), # orange (olive)
("\x03""08,", "{yel}"), # yellow
("\x03""09,", ""), # light green (lime)
("\x03""10,", ""), # teal (a green/blue cyan)
("\x03""11,", ""), # light cyan (cyan) (aqua)
("\x03""12,", ""), # light blue (royal)
("\x03""13,", "{vio}"), # pink (light purple) (fuchsia)
("\x03""14,", "{gra}"), # grey
("\x03""15,", ""), # light grey (silver)
("\x03""99,", ""), # transparent
# Color text on default background
("\x03""00", "{whi}"), # white
("\x03""01", "{blk}"), # black
("\x03""02", "{blu}"), # blue (navy)
("\x03""03", "{gre}"), # green
("\x03""04", "{red}"), # red
("\x03""05", ""), # brown (maroon)
("\x03""06", "{pur}"), # purple
("\x03""07", "{ora}"), # orange (olive)
("\x03""08", "{yel}"), # yellow
("\x03""09", ""), # light green (lime)
("\x03""10", ""), # teal (a green/blue cyan)
("\x03""11", ""), # light cyan (cyan) (aqua)
("\x03""12", ""), # light blue (royal)
("\x03""13", "{vio}"), # pink (light purple) (fuchsia)
("\x03""14", "{gra}"), # grey
("\x03""15", ""), # light grey (silver)
("\x03""99", ""), # transparent
# Format codes
("\x02", ""), # bold
("\x03,", "{def}"), # no more color
("\x03", "{def}"), # no more color
("\x1D", ""), # italic text
("\x0F", "{def}"), # colour reset
("\x16", ""), # reverse colour
("\x1F", ""), # underlined text
# drop other control chars
("\x04", ""),
("\x05", ""),
("\x06", ""),
("\x07", ""),
("\x08", ""),
("\x09", ""),
("\x0A", ""),
("\x0B", ""),
("\x0C", ""),
("\x0D", ""),
("\x0E", ""),
("\x10", ""),
("\x11", ""),
("\x12", ""),
("\x13", ""),
("\x14", ""),
("\x15", ""),
("\x17", ""),
("\x18", ""),
("\x19", ""),
("\x1A", ""),
("\x1B", ""),
("\x1C", ""),
("\x1E", ""),
]
Bad_Unicode = [
"👌",
"👉 ",
]
def replace_with_table(pIncoming, table, debug=0, check=0):
if isinstance(pIncoming, str):
lIncoming = unicode(pIncoming, 'utf-8-sig', 'replace')
else:
lIncoming = pIncoming
if debug > 0:
print ("Incoming object: {}".format(repr(pIncoming)))
print ("Incoming unicode: {}".format(repr(lIncoming)))
if (check):
for i, o in table:
outtext = lIncoming.replace(i, "")
lIncoming = outtext
else:
for i, o in table:
outtext = lIncoming.replace(i, o)
lIncoming = outtext
if (check):
lIncoming = lIncoming.strip()
if isinstance(pIncoming, str):
outtext = lIncoming.encode('utf-8', 'replace')
for i in Bad_Unicode:
outtext = outtext.replace(i, "")
else:
outtext = lIncoming
if debug > 0:
print ("Outgoing replace: {}".format(repr(lIncoming)))
print ("Outgoing string: {}".format(repr(outtext)))
return outtext
def check_pso2_with_irc(pIncoming, debug=0):
return replace_with_table(pIncoming, PSO2_IRC, debug, check=1)
def check_irc_with_pso2(pIncoming, debug=0):
return replace_with_table(pIncoming, IRC_PSO2, debug, check=1)
def replace_pso2_with_irc(pIncoming, debug=0):
return replace_with_table(pIncoming, PSO2_IRC, debug)
def replace_irc_with_pso2(pIncoming, debug=0):
return replace_with_table(pIncoming, IRC_PSO2, debug)
def ci_switchs(cmd): # decode /ci[1-9] {[1-5]} {t[1-5]} {nw} {s[0-99]}
count = 0
cmdl = cmd.split(" ", 5)
lcmd = len(cmdl)
if lcmd == count + 1:
return count
if not (cmdl[count + 1]):
return count
if cmdl[count + 1].isdigit():
count += 1
if lcmd == count + 1:
return count
try:
if cmdl[count + 1][0] == "t":
count += 1
except Exception:
log.msg("issue with ci string: %s" % cmd)
return count
if lcmd == count + 1:
return count
if cmdl[count + 1] == "nw":
count += 1
if lcmd == count + 1:
return count
if cmdl[count + 1][0] == "s":
count += 1
return count
PSO2_Commands = [
# Text Bubble Emotes
("toge", 0),
("moya", 0),
("mn", 0), # (mn#)
# Switch Main Palette (mpal#)
("mainpalette", 0),
("mpal", 0),
("subpalette", 0),
("spal", 0),
# Switch Consume %1
("costume", 1),
("cs", 1),
# Switch Camos %1
("camouflage", 1),
("cmf", 1),
# Lobby action %1
("la", 1),
("mla", 1),
("fla", 1),
("cla", 1),
# Symbol Art (symbol#)
("symbol", 0),
# Voice Clip (vo#)
("vo", 0),
# All chat
("a", 0),
# Party chat
("p", 0),
# Team Chat
("t", 0),
# EOL
]
def need_switchs(msg): # return the max number of swtichs for the command
for s, n in PSO2_Commands:
if msg.startswith(s):
return n
if msg.startswith("ci"):
return ci_switchs(msg) # Cut-ins need special handling
return -1 # Unknown
def split_cmd_msg(message):
cmd = ""
msg = message
if not message.strip() or message.strip() == "null":
return (cmd, "")
cmd, split, msg = message.rpartition("/") # Let process that last command
if split:
args = need_switchs(msg) # how many switchs does the last command need?
if args == -1: # not a vaild command, let look again
cmdr, msgr = split_cmd_msg(cmd)
return (cmdr, msgr + split + msg)
else: # so it is a vaild command, let add back togther
msg += u" "
msgl = msg.split(u" ", args + 1) # let break apart msg strings into a list
msg = msgl[-1] # the string at the end of the list is the text
cmdl = [] # Start a new list, with cmd
cmdl.extend(msgl[0:args + 1]) # Add the command and all the switchs
cmd = split + u" ".join(cmdl) # join the list into a string
if cmd and msg.rstrip():
cmd += u" "
return (cmd, msg.rstrip())