/
parser.py
11467 lines (11371 loc) · 480 KB
/
parser.py
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
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#! /usr/bin/env python
"""
Program: EQ Alert
File Name: eqa/lib/parser.py
Copyright (C) 2024 M Geitz
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""
import sys
import time
import re
import datetime
import eqa.lib.struct as eqa_struct
import eqa.lib.settings as eqa_settings
def process(exit_flag, log_q, action_q):
"""
Process: log_q
Produce: action_q
"""
try:
while not exit_flag.is_set():
# Sleep between empty checks
if log_q.qsize() < 1:
time.sleep(0.01)
# Check queue for message
if not log_q.empty():
## Read new message
line = log_q.get().strip()
## If line fits assumed log line structure
if (
re.fullmatch(
r"^\[(?:Fri|Mon|S(?:at|un)|T(?:hu|ue)|Wed) (?:A(?:pr|ug)|Dec|Feb|J(?:an|u[ln])|Ma[ry]|Nov|Oct|Sep) [0-9]{2} [0-9]{2}\:[0-9]{2}\:[0-9]{2} [0-9]{4}\] .+",
line,
)
is not None
):
### Split timestamp and message payload
timestamp, payload = line[1:].split("] ", 1)
timestamp = (
timestamp.split(" ")[3]
+ "."
+ datetime.datetime.now().strftime("%f")[:1]
+ "0"
)
### Build and queue action
action_q.put(
eqa_struct.message(
timestamp, determine(payload), None, None, payload
)
)
else:
eqa_settings.log("process_log: Cannot process: " + line)
log_q.task_done()
except Exception as e:
eqa_settings.log(
"process_log: Error on line "
+ str(sys.exc_info()[-1].tb_lineno)
+ ": "
+ str(e)
)
def determine(line):
"""Determine type of line"""
try:
# Melee
line_type = check_melee(line)
if line_type is not None:
return line_type
# Spell
line_type = check_spell(line)
if line_type is not None:
return line_type
# Who
line_type = check_who(line)
if line_type is not None:
return line_type
# Pets
line_type = check_pets(line)
if line_type is not None:
return line_type
# Received Player Chat
line_type = check_received_chat(line)
if line_type is not None:
return line_type
# Sent Player Chat
line_type = check_sent_chat(line)
if line_type is not None:
return line_type
# Ability Output
line_type = check_ability_output(line)
if line_type is not None:
return line_type
# Command Output
line_type = check_command_output(line)
if line_type is not None:
return line_type
# System Messages
line_type = check_system_messages(line)
if line_type is not None:
return line_type
# Group System Messages
line_type = check_group_system_messages(line)
if line_type is not None:
return line_type
# Loot Trade Messages
line_type = check_loot_trade(line)
if line_type is not None:
return line_type
# Emotes
line_type = check_emotes(line)
if line_type is not None:
return line_type
# Spell Specific
line_type = check_spell_specific(line)
if line_type is not None:
return line_type
# No Match Found
return "undetermined"
except Exception as e:
eqa_settings.log(
"process_log (determine): Error on line "
+ str(sys.exc_info()[-1].tb_lineno)
+ ": "
+ str(e)
)
return line_type
def check_melee(line):
"""
Check line for melee
"""
try:
# Melee Combat
if (
re.fullmatch(
r"^[a-zA-Z`\s]+ (stings|mauls|hits|crushes|slashes|pierces|bashes|backstabs|bites|kicks|claws|gores|punches|strikes|slices) (you|YOU) for \d+ point(s|) of damage\.$",
line,
)
is not None
):
return "combat_you_receive_melee"
elif (
re.fullmatch(
r"^[a-zA-Z`\s\-]+ (stings|mauls|hits|crushes|slashes|pierces|bashes|backstabs|bites|kicks|claws|gores|punches|strikes|slices) [a-zA-Z`\s\-]+ for \d+ point(s|) of damage\.$",
line,
)
is not None
):
return "combat_other_melee"
elif (
re.fullmatch(
r"^[a-zA-Z`\s\-]+ tries to (sting|maul|hit|crush|slash|pierce|bash|backstab|bite|kick|claw|gore|punch|strike|slice) [a-zA-Z`\s\-]+, but misses\!$",
line,
)
is not None
):
return "combat_other_melee_miss"
elif (
re.fullmatch(
r"^[a-zA-Z`\s\-]+ tries to (sting|maul|hit|crush|slash|pierce|bash|backstab|bite|kick|claw|gore|punch|strike|slice) [a-zA-Z`\s\-]+, but [a-zA-Z`\s\-]+ dodges\!$",
line,
)
is not None
):
return "combat_other_melee_dodge"
elif (
re.fullmatch(
r"^You try to (sting|maul|hit|crush|slash|pierce|bash|backstab|bite|kick|claw|gore|punch|strike|slice) [a-zA-Z`\s\-]+, but [a-zA-Z`\s\-]+ dodges\!$",
line,
)
is not None
):
return "combat_you_melee_dodge"
elif (
re.fullmatch(
r"^[a-zA-Z`\s\-]+ tries to (sting|maul|hit|crush|slash|pierce|bash|backstab|bite|kick|claw|gore|punch|strike|slice) YOU, but YOU dodge\!$",
line,
)
is not None
):
return "combat_you_melee_dodge"
elif (
re.fullmatch(
r"^[a-zA-Z`\s\-]+ tries to (sting|maul|hit|crush|slash|pierce|bash|backstab|bite|kick|claw|gore|punch|strike|slice) [a-zA-Z`\s\-]+, but [a-zA-Z`\s\-]+ is INVULNERABLE\!$",
line,
)
is not None
):
return "combat_other_melee_invulnerable"
elif (
re.fullmatch(
r"^You try to (sting|maul|hit|crush|slash|pierce|bash|backstab|bite|kick|claw|gore|punch|strike|slice) [a-zA-Z`\s\-]+, but [a-zA-Z`\s\-]+ is INVULNERABLE\!$",
line,
)
is not None
):
return "combat_you_melee_invulnerable"
elif (
re.fullmatch(
r"^[a-zA-Z`\s\-]+ tries to (sting|maul|hit|crush|slash|pierce|bash|backstab|bite|kick|claw|gore|punch|strike|slice) YOU, but ([a-zA-Z`\s\-]+|) are INVULNERABLE\!$",
line,
)
is not None
):
return "combat_your_melee_invulnerable"
elif (
re.fullmatch(
r"^[a-zA-Z`\s\-]+ tries to (sting|maul|hit|crush|slash|pierce|bash|backstab|bite|kick|claw|gore|punch|strike|slice) [a-zA-Z`\s\-]+, but [a-zA-Z`\s\-]+ parries\!$",
line,
)
is not None
):
return "combat_other_melee_parry"
elif (
re.fullmatch(
r"^You try to (sting|maul|hit|crush|slash|pierce|bash|backstab|bite|kick|claw|gore|punch|strike|slice) [a-zA-Z`\s\-]+, but [a-zA-Z`\s\-]+ parries\!$",
line,
)
is not None
):
return "combat_you_melee_parry"
elif (
re.fullmatch(
r"^[a-zA-Z`\s\-]+ tries to (sting|maul|hit|crush|slash|pierce|bash|backstab|bite|kick|claw|gore|punch|strike|slice) [a-zA-Z`\s\-]+, but [a-zA-Z`\s\-]+ blocks\!$",
line,
)
is not None
):
return "combat_other_melee_block"
elif (
re.fullmatch(
r"^[a-zA-Z`\s\-]+ tries to (sting|maul|hit|crush|slash|pierce|bash|backstab|bite|kick|claw|gore|punch|strike|slice) [a-zA-Z`\s\-]+, but [a-zA-Z`\s\-]+ ripostes\!$",
line,
)
is not None
):
return "combat_other_melee_riposte"
elif (
re.fullmatch(
r"^You try to (sting|maul|hit|crush|slash|pierce|bash|backstab|bite|kick|claw|gore|punch|strike|slice) [a-zA-Z`\s\-]+, but [a-zA-Z`\s\-]+ ripostes\!$",
line,
)
is not None
):
return "combat_you_melee_riposte"
elif (
re.fullmatch(
r"^[a-zA-Z`\s\-]+ tries to (sting|maul|hit|crush|slash|pierce|bash|backstab|bite|kick|claw|gore|punch|strike|slice) [a-zA-Z`\s\-]+, but [a-zA-Z`\s\-]+'s magical skin absorbs the blow\!$",
line,
)
is not None
):
return "combat_other_rune_damage"
elif (
re.fullmatch(
r"^[a-zA-Z`\s\-]+ tries to (sting|maul|hit|crush|slash|pierce|bash|backstab|bite|kick|claw|gore|punch|strike|slice) YOU, but YOUR magical skin absorbs the blow\!$",
line,
)
is not None
):
return "combat_your_rune_damage"
elif (
re.fullmatch(
r"^You try to (sting|maul|hit|crush|slash|pierce|bash|backstab|bite|kick|claw|gore|punch|strike|slice) [a-zA-Z`\s\-]+, but [a-zA-Z`\s\-]+'s magical skin absorbs the blow\!$",
line,
)
is not None
):
return "combat_you_rune_damage"
elif (
re.fullmatch(
r"^You (sting|maul|hit|crush|slash|pierce|bash|backstab|bite|kick|claw|gore|punch|strike|slice) [a-zA-Z`\s\-]+ for \d+ point(s|) of damage\.$",
line,
)
is not None
):
return "combat_you_melee"
elif (
re.fullmatch(
r"^You try to (sting|maul|hit|crush|slash|pierce|bash|backstab|bite|kick|claw|gore|punch|strike|slice) [a-zA-Z`\s\-]+, but miss\!$",
line,
)
is not None
):
return "combat_you_melee_miss"
elif (
re.fullmatch(r"^[a-zA-Z`\s]+ Scores a critical hit\!\(\d+\)$", line)
is not None
):
return "combat_other_melee_crit"
elif (
re.fullmatch(r"^[a-zA-Z`\s]+ has landed a Thunderous Kick\! \(\d+\)$", line)
is not None
):
return "combat_other_melee_crit_kick"
elif (
re.fullmatch(r"^[a-zA-Z`\s]+ lands a Crippling Blow\!\(\d+\)$", line)
is not None
):
return "combat_other_melee_crip_blow"
elif (
re.fullmatch(r"^[a-zA-Z`\s\-]+ has become (ENRAGED|enraged)\.$", line)
is not None
):
return "mob_enrage_on"
elif re.fullmatch(r"^[a-zA-Z`\s\-]+ is no longer enraged\.$", line) is not None:
return "mob_enrage_off"
elif (
re.fullmatch(r"^[a-zA-Z`\s\-]+ goes on a (RAMPAGE|rampage)\!$", line)
is not None
):
return "mob_rampage_on"
elif (
re.fullmatch(r"^[a-zA-Z`\s\-]+ has been slain by [a-zA-Z`\s\-]+\!$", line)
is not None
):
return "mob_slain_other"
elif re.fullmatch(r"^You have slain [a-zA-Z`\s\-]+\!$", line) is not None:
return "mob_slain_you"
elif (
re.fullmatch(r"^You have been slain by [a-zA-Z`\s\-]+\!$", line) is not None
):
return "you_slain"
elif (
re.fullmatch(r"^Your target is out of range, get closer\!$", line)
is not None
):
return "mob_out_of_range"
elif re.fullmatch(r"^You gain experience\!\!$", line) is not None:
return "experience_solo"
elif (
re.fullmatch(r"^You regain some experience from resurrection\.$", line)
is not None
):
return "experience_solo_resurrection"
elif re.fullmatch(r"^You gain party experience\!\!$", line) is not None:
return "experience_group"
elif re.fullmatch(r"^You have lost experience\.$", line) is not None:
return "experience_lost"
elif re.fullmatch(r"^You have been knocked unconscious\!$", line) is not None:
return "unconscious"
elif (
re.fullmatch(r"^[a-zA-Z`\s\-]+ was pierced by thorns\.$", line) is not None
):
return "combat_other_ds_thorns_damage"
elif re.fullmatch(r"^YOU are pierced by thorns\!$", line) is not None:
return "combat_you_ds_thorns_damage"
elif re.fullmatch(r"^[a-zA-Z`\s\-]+ was burned\.$", line) is not None:
return "combat_other_ds_fire_damage"
elif re.fullmatch(r"^YOU are burned\!$", line) is not None:
return "combat_you_ds_fire_damage"
elif (
re.fullmatch(
r"^You must first click on the being you wish to attack\!$", line
)
is not None
):
return "combat_you_no_target"
elif (
re.fullmatch(r"^You can\'t see your target from here\.$", line) is not None
):
return "combat_you_cannot_see"
elif re.fullmatch(r"^You can\'t hit them from here\.$", line) is not None:
return "combat_you_cannot_hit"
elif (
re.fullmatch(
r"^[a-zA-Z`\s\-]+ executes a FLURRY of attacks on [a-zA-Z`0-9\'\s\-]+\!$",
line,
)
is not None
):
return "combat_other_flurry"
elif (
re.fullmatch(
r"^A (shimmer|glimmering) drake (kicks|tries to kick).*\.$",
line,
)
is not None
):
return "combat_ranger_drake"
return None
except Exception as e:
eqa_settings.log(
"process_log (check_melee): Error on line "
+ str(sys.exc_info()[-1].tb_lineno)
+ ": "
+ str(e)
)
def check_spell(line):
"""
Check line for spell
"""
try:
if re.fullmatch(r"^[a-zA-Z`\s]+ begins to cast a spell\.$", line) is not None:
return "spells_cast_other"
elif re.fullmatch(r"^You begin casting [a-zA-Z\:`\s\']+\.$", line) is not None:
return "spells_cast_you"
elif (
re.fullmatch(r"^Your [0-9a-zA-Z\s`\:\'\-]+ begins to glow\.$", line)
is not None
):
return "spells_cast_item_you"
elif re.fullmatch(r"^\w+\'s spell fizzles\!$", line) is not None:
return "spells_fizzle_other"
elif re.fullmatch(r"^Your spell fizzles\!$", line) is not None:
return "spells_fizzle_you"
elif re.fullmatch(r"^Your spell did not take hold\.$", line) is not None:
return "spells_not_hold"
elif (
re.fullmatch(r"^Insufficient Mana to cast this spell\!$", line) is not None
):
return "spells_cast_oom"
elif (
re.fullmatch(r"^[a-zA-Z`\s]+\'s casting is interrupted\!$", line)
is not None
):
return "spells_interrupt_other"
elif re.fullmatch(r"^Your spell is interrupted\.$", line) is not None:
return "spells_interrupt_you"
elif re.fullmatch(r"^[a-zA-Z]+\'s song ends abruptly\.$", line) is not None:
return "spells_song_end"
elif (
re.fullmatch(r"^You are too distracted to cast a spell now\!$", line)
is not None
):
return "spells_distracted"
elif (
re.fullmatch(
r"^[a-zA-Z`\s]+ regains concentration and continues casting\.$", line
)
is not None
):
return "spells_recover_other"
elif (
re.fullmatch(
r"^You regain your concentration and continue your casting\.$", line
)
is not None
):
return "spells_recover_you"
elif re.fullmatch(r"^Your target resisted the .+ spell\.$", line) is not None:
return "spells_resist_other"
elif re.fullmatch(r"^You resist the .+ spell\!$", line) is not None:
return "spells_resist_you"
elif (
re.fullmatch(
r"^[a-zA-Z`\s]+ was hit by non\-melee for \d+ point(s|) of damage\.$",
line,
)
is not None
):
return "spells_damage_other"
elif (
re.fullmatch(r"^You were hit by non\-melee for \d+ damage\.$", line)
is not None
):
return "spells_damage_you"
elif re.fullmatch(r"^Aborting memorization of spell\.$", line) is not None:
return "spells_memorize_abort"
elif (
re.fullmatch(r"^Beginning to memorize [a-zA-Z`\s\'\:]+\.\.\.$", line)
is not None
):
return "spells_memorize_begin"
elif (
re.fullmatch(
r"^You are not high enough level to memorize that spell\.$", line
)
is not None
):
return "spells_memorize_too_high"
elif (
re.fullmatch(
r"^You will have to achieve level \d+ before you can scribe the [a-zA-Z`\s\'\:]+\.$",
line,
)
is not None
):
return "spells_scribe_not_yet"
elif (
re.fullmatch(r"^Beginning to scribe [a-zA-Z`\s\'\:]+\.\.\.$", line)
is not None
):
return "spells_scribe_begin"
elif (
re.fullmatch(
r"^You have finished scribing [a-zA-Z`\s\'\:]+(\.\.\.|\.)$", line
)
is not None
):
return "spells_scribe_finish"
elif (
re.fullmatch(
r"^Right click on another Scribe Slot in your Spell Book to swap this Spell position with the new one\.$",
line,
)
is not None
):
return "spells_scribe_swap_instruction"
elif re.fullmatch(r"^Swapping Spell Book Scribe slots\.$", line) is not None:
return "spells_scribe_swap"
elif (
re.fullmatch(r"^You have finished memorizing [a-zA-Z`\s\'\:]+\.$", line)
is not None
):
return "spells_memorize_finish"
elif (
re.fullmatch(
r"^You cannot memorize a spell you already have memorized\.$", line
)
is not None
):
return "spells_memorize_already"
elif re.fullmatch(r"^You forget .+\.", line) is not None:
return "spells_forget"
elif (
re.fullmatch(r"^Your [a-zA-Z`\'\s]+ spell has worn off\.$", line)
is not None
):
return "spells_worn_off"
elif (
re.fullmatch(
r"^You try to cast a spell on [a-zA-Z`\s]+, but they are protected\.$",
line,
)
is not None
):
return "spells_protected_other"
elif re.fullmatch(r"^You haven't recovered yet\.\.\.$", line) is not None:
return "spells_cooldown_active"
elif (
re.fullmatch(r"^You must be standing to cast a spell\.$", line) is not None
):
return "spells_sitting"
elif (
re.fullmatch(r"^You must first select a target for this spell\!$", line)
is not None
):
return "spells_no_target"
elif (
re.fullmatch(r"^A missed note brings \w+'s song to a close\!$", line)
is not None
):
return "songs_interrupted_other"
elif (
re.fullmatch(r"^You feel as if you are about to fall\.$", line) is not None
):
return "spells_levitate_dropping_you"
elif re.fullmatch(r"^You can\'t levitate in this zone\.$", line) is not None:
return "spells_levitate_block"
elif (
re.fullmatch(
r"^You feel as if you are about to look like yourself again\.$", line
)
is not None
):
return "spells_illusion_dropping_you"
elif re.fullmatch(r"^Your target has been cured\.$", line) is not None:
return "spells_cured_other"
elif re.fullmatch(r"^You feel yourself bind to the area\.$", line) is not None:
return "spells_bind_you"
elif (
re.fullmatch(r"^Your gate is too unstable, and collapses\.$", line)
is not None
):
return "spells_gate_collapse"
elif (
re.fullmatch(r"^[\w\s\'`]+ begins to cast the gate spell\.$", line)
is not None
):
return "spells_gate_npc_casting"
elif re.fullmatch(r"^[a-zA-Z`\s\'\-]+ Gates\.$", line) is not None:
return "spells_gated_npc"
elif (
re.fullmatch(r"^You feel yourself starting to appear\.$", line) is not None
):
return "spells_invis_dropping_you"
elif (
re.fullmatch(
r"^\w+ tries to cast an invisibility spell on you, but you are already invisible\.$",
line,
)
is not None
):
return "spells_invis_already"
elif re.fullmatch(r"^You have been summoned\!$", line) is not None:
return "spells_summoned_you"
elif (
re.fullmatch(r"^You have healed .+ for \d+ point(s|) of damage\.$", line)
is not None
):
return "spells_heal_you"
elif (
re.fullmatch(r"^\w+ has healed you for \d+ point(s|) of damage\.$", line)
is not None
):
return "spells_heal_other"
elif (
re.fullmatch(
r"^Your spell is too powerful for your intended target\.$", line
)
is not None
):
return "spells_too_powerful"
elif (
re.fullmatch(
r"^[a-zA-Z`\s]+ tries to cast a spell on you, but you are protected\.$",
line,
)
is not None
):
return "spells_protected_you"
elif re.fullmatch(r"^You can't cast spells while stunned\!$", line) is not None:
return "spells_stun_cast_block"
return None
except Exception as e:
eqa_settings.log(
"process_log (check_spell): Error on line "
+ str(sys.exc_info()[-1].tb_lineno)
+ ": "
+ str(e)
)
def check_received_chat(line):
"""
Check line for received chat
"""
try:
if (
re.fullmatch(r"^[a-zA-Z\s`]+ tells you, \'Welcome to my bank\!\'$", line)
is not None
):
return "tell_npc_bank_open"
elif (
re.fullmatch(r"^[a-zA-Z\s`]+ tells you, \'Come back soon\!\'$", line)
is not None
):
return "tell_npc_bank_closed"
elif (
re.fullmatch(
r"^[a-zA-Z\s`]+ tells you, \'(That\'ll be|I\'ll give you) .+ (for the|per) .+\'$",
line,
)
is not None
):
return "trade_npc_item_price"
elif (
re.fullmatch(r"^[a-zA-Z\.]+ tells you(, in \w+|), \'(.+|)\'$", line)
is not None
):
return "tell"
elif (
re.fullmatch(
r"^[a-zA-Z\.]+ tells you,in an unknown tongue, \'(.+|)\'$", line
)
is not None
):
return "tell_unknown_tongue"
elif re.fullmatch(r"^[a-zA-Z`\s]+ tells you(,|) \'.+\'$", line) is not None:
return "tell_npc"
elif re.fullmatch(r"^\w+ says(, in \w+|), \'(.+|)\'$", line) is not None:
return "say"
elif re.fullmatch(r"^[a-zA-Z`\s]+ says(,|) \'.+\'$", line) is not None:
return "say_npc"
elif (
re.fullmatch(r"^\w+ says,in an unknown tongue, \'(.+|)\'$", line)
is not None
):
return "say_unknown_tongue"
elif re.fullmatch(r"^\w+ shouts(, in \w+|), \'(.+|)\'$", line) is not None:
return "shout"
elif (
re.fullmatch(r"^\w+ shouts,in an unknown tongue, \'(.+|)\'$", line)
is not None
):
return "shout_unknown_tongue"
elif (
re.fullmatch(r"^[a-zA-Z`\s]+( | )shouts(,|) \'.+(\'|)$", line) is not None
):
return "shout_npc"
elif (
re.fullmatch(r"^\w+ tells the guild(, in \w+|), \'(.+|)\'$", line)
is not None
):
return "guild"
elif (
re.fullmatch(r"^\w+ tells the group(, in \w+|), \'(.+|)\'$", line)
is not None
):
return "group"
elif (
re.fullmatch(r"^\w+ says out of character(, in \w+|), \'(.+|)\'$", line)
is not None
):
return "ooc"
elif (
re.fullmatch(
r"^\w+ auctions(, in \w+|), \'(.+|)(wts|WTS|selling|Selling)(.+|)\'$",
line,
)
is not None
):
return "auction_wts"
elif (
re.fullmatch(
r"^\w+ auctions(, in \w+|), \'(.+|)(wtb|WTB|buying|Buying)(.+|)\'$",
line,
)
is not None
):
return "auction_wtb"
elif re.fullmatch(r"^\w+ auctions(, in \w+|), \'(.+|)\'$", line) is not None:
return "auction"
elif (
re.fullmatch(r"^\w+ auctions,in an unknown tongue, \'(.+|)\'$", line)
is not None
):
return "auction_unknown_tongue"
elif re.fullmatch(r"^[a-zA-Z]+ BROADCASTS, \'(.+|)\'$", line) is not None:
return "broadcast"
return None
except Exception as e:
eqa_settings.log(
"process_log (check_received_chat): Error on line "
+ str(sys.exc_info()[-1].tb_lineno)
+ ": "
+ str(e)
)
def check_sent_chat(line):
"""
Check line for sent chat
"""
try:
if (
re.fullmatch(r"^You told [a-zA-Z\.]+(, \'| \'\[queued\],)(.+|)\'$", line)
is not None
):
return "tell_you"
elif re.fullmatch(r"^You say, \'(.+|)\'$", line) is not None:
return "say_you"
elif re.fullmatch(r"^You shout, \'(.+|)\'$", line) is not None:
return "shout_you"
elif re.fullmatch(r"^You say to your guild, \'(.+|)\'$", line) is not None:
return "guild_you"
elif re.fullmatch(r"^You tell your party, \'(.+|)\'$", line) is not None:
return "group_you"
elif re.fullmatch(r"^You say out of character, \'(.+|)\'$", line) is not None:
return "ooc_you"
elif re.fullmatch(r"^You auction, \'(.+|)\'$", line) is not None:
return "auction_you"
elif re.fullmatch(r"^You petition, \'(.+|)\'$", line) is not None:
return "petition_you"
return None
except Exception as e:
eqa_settings.log(
"process_log (check_sent_chat): Error on line "
+ str(sys.exc_info()[-1].tb_lineno)
+ ": "
+ str(e)
)
def check_ability_output(line):
"""
Check line for ability output
"""
try:
if (
re.fullmatch(
r"^You think you are heading (?:North(?:East|West)?|South(?:East|West)?|(?:Ea|We)st)\.$",
line,
)
is not None
):
return "direction"
elif (
re.fullmatch(r"^You have no idea what direction you are facing\.$", line)
is not None
):
return "direction_miss"
elif re.fullmatch(r"^Forage Error\: Cursor not empty\.$", line) is not None:
return "forage_cursor_empty"
elif re.fullmatch(r"^You must be standing to forage\.$", line) is not None:
return "forage_standing"
elif (
re.fullmatch(
r"^You have scrounged up something that doesn't look edible\.$", line
)
is not None
):
return "forage_not_edible"
elif re.fullmatch(r"^You have scrounged up some .+\.$", line) is not None:
return "forage_edible"
elif (
re.fullmatch(r"^You can\'t try to forage while attacking\.$", line)
is not None
):
return "forage_attacking"
elif re.fullmatch(r"^You fail to locate any food nearby\.$", line) is not None:
return "forage_fail"
elif (
re.fullmatch(
r"^[a-zA-Z`\-\s]+ is (?:behind and to the (?:righ|lef)t\.|ahead and to the (?:righ|lef)t\.|(?:straight ahead|behind you)\.|to the (?:righ|lef)t\.)$",
line,
)
is not None
):
return "tracking"
elif re.fullmatch(r"^Track players \* OFF \*$", line) is not None:
return "tracking_player_off"
elif re.fullmatch(r"^Track players \* ON \*$", line) is not None:
return "tracking_player_on"
elif re.fullmatch(r"^You have lost your tracking target\.$", line) is not None:
return "tracking_target_lost"
elif re.fullmatch(r"^You begin tracking [a-zA-Z\s`]+\.$", line) is not None:
return "tracking_begin"
elif re.fullmatch(r"^\w+ has fallen to the ground\.", line) is not None:
return "feign_failure_other"
elif (
re.fullmatch(
r"^You (?:have moved and are no longer hidden\!\!|are no longer hidden\.)$",
line,
)
is not None
):
return "hide_drop"
elif re.fullmatch(r"^You begin to hide\.\.\.$", line) is not None:
return "hide_enabled"
elif re.fullmatch(r"^You stop hiding\.$", line) is not None:
return "hide_disabled"
elif (
re.fullmatch(r"^You must stand perfectly still to hide\!$", line)
is not None
):
return "hide_moving"
elif (
re.fullmatch(r"^You can't try to hide while attacking.$", line) is not None
):
return "hide_attacking"
elif (
re.fullmatch(r"^You are being bandaged\. Stay relatively still\.$", line)
is not None
):
return "bandage_you_other"
elif re.fullmatch(r"^You begin to bandage yourself\.$", line) is not None:
return "bandage_you_you"
elif re.fullmatch(r"^You must be standing to bind wounds\.$", line) is not None:
return "bandage_block_stand"
elif (
re.fullmatch(
r"^You cannot have your wounds bound above \d+\% hitpoints\.$", line
)
is not None
):
return "bandage_cap_other"
elif (
re.fullmatch(r"^You cannot bind wounds above \d+\% hitpoints\.$", line)
is not None
):
return "bandage_cap_you"
elif (
re.fullmatch(r"^You can't fish while holding something\.$", line)
is not None
):
return "fishing_holding"
elif (
re.fullmatch(r"^You can't fish without a fishing pole, go buy one\.$", line)
is not None
):
return "fishing_no_pole"
elif re.fullmatch(r"^You cast your line\.$", line) is not None:
return "fishing_cast"
elif re.fullmatch(r"^You caught, something\.\.\.$", line) is not None:
return "fishing_caught_something"
elif re.fullmatch(r"^You didn't catch anything\.$", line) is not None:
return "fishing_caught_nothing"
elif re.fullmatch(r"^You lost your bait\!$", line) is not None:
return "fishing_lost_bait"
elif re.fullmatch(r"^Trying to catch land sharks perhaps\?$", line) is not None:
return "fishing_no_water"
elif (
re.fullmatch(
r"^You need to put your fishing pole in your primary hand\.$", line
)
is not None
):
return "fishing_creatively"
elif re.fullmatch(r"^Your fishing pole broke\!$", line) is not None:
return "fishing_pole_broke"
elif (
re.fullmatch(r"^You spill your beer while bringing in your line\.$", line)
is not None
):
return "fishing_spill_beer"
elif (
re.fullmatch(
r"^You must have a lock pick in your inventory to do this\.$", line
)
is not None
):
return "required_pick"
elif re.fullmatch(r"^Ability not ready\.$", line) is not None:
return "ability_not_ready"
elif (
re.fullmatch(
r"^You taunt [a-zA-Z`\s\-]+ to ignore others and attack you\!$", line
)
is not None
):
return "taunt_you"
elif (
re.fullmatch(r"^You must target an NPC to taunt first\.$", line) is not None
):
return "taunt_missing_target"
return None
except Exception as e:
eqa_settings.log(
"process_log (check_sent_chat): Error on line "
+ str(sys.exc_info()[-1].tb_lineno)
+ ": "
+ str(e)
)
def check_command_output(line):
"""
Check line for command output
"""
try:
if (
re.fullmatch(
r"^Your Location is [-]?(?:\d*\.)?\d+\,\ [-]?(?:\d*\.)?\d+\,\ [-]?(?:\d*\.)?\d+$",
line,
)
is not None
):
return "location"
elif (
re.fullmatch(r"^You are now A\.F\.K\. \(Away From Keyboard\)\.", line)
is not None
):
return "you_afk_on"
elif re.fullmatch(r"^You are now Looking For a Group\.", line) is not None:
return "you_lfg_on"