forked from HeroCC/RedditSteamGameInfo
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
1325 lines (1276 loc) · 91.1 KB
/
main.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
# Reddit FreeGameFindings Bot
# Resolves Steam URLs from submissions, and comments information about them
import os
import re
import threading
import time
from humanfriendly import format_timespan
import praw
from prawcore.exceptions import PrawcoreException
from keep_alive import keep_alive
from SteamGame import SteamGame
from SteamRemovedGame import SteamRemovedGame
from SteamSearchGame import SteamSearchGame
from GOGGame import GOGGame
from AlienwareArena import AlienwareArena
from iGames import iGames
from Keyhub import Keyhub
from EpicGame import EpicGame
BLOCKED_USER_FILE = 'blockedusers.txt' # Will not reply to these people
SUBLIST = "FreeGameFindings"
BOT_USERNAME = os.getenv("RSGIB_USERNAME")
STEAM_APPURL_REGEX = r"((https?:\/\/)?)(store.steampowered.com(\/agecheck)?\/app\/\d+)"
STEAMDB_APPURL_REGEX = r"((https?:\/\/)?)(steamdb.info\/app\/\d+)"
STEAM_TITLE_REGEX = r"\[.*(Steam).*\]\s*\((Game|DLC|Beta|Alpha)\)"
STEAM_PLATFORM_REGEX = r"\[.*(Steam).*\]"
INDIEGALA_URL_REGEX = r"((https?:\/\/)?)(freebies.indiegala.com\/)"
INDIEGALA_TITLE_REGEX = r"\[.*(Indiegala).*\]\s*\((Game)\)"
EPIC_URL_REGEX = r"((https?:\/\/)?)(epicgames.com\/)"
EPIC_TITLE_REGEX = r"\[.*(Epic).*\]\s*\((Game)\)"
GOG_URL_REGEX = r"((https?:\/\/)?)(gog.com\/\w*\/*game)"
GOG_TITLE_REGEX = r"\[.*(GOG).*\]\s*\((Game|DLC|Beta|Alpha|Other)\)"
ALIENWARE_URL_REGEX = r"(https?:\/\/)?(\b)?\.?(alienwarearena.com\/\w+)"
STEELSERIES_URL_REGEX = r"((https?:\/\/)?)(games.steelseries.com\/giveaway\/\d+)"
CRUCIAL_URL_REGEX = r"((https?:\/\/)?)(games.crucial.com\/promotions\/\d+)"
IGAMES_URL_REGEX = r"((https?:\/\/)?)(igames.gg\/promotions\/\d+)"
KEYHUB_URL_REGEX = r"((https?:\/\/)?)(key-hub.eu\/giveaway\/\d+)"
GLEAMIO_URL_REGEX = r"((https?:\/\/)?)(gleam.io)"
RANDOM_TITLE_REGEX = r"(Random).*(Game)"
def fitscriteria(s):
with open(BLOCKED_USER_FILE) as blocked_users:
if s.author.name in blocked_users.read():
return False
if hasbotalreadyreplied(s):
return False
if not hasbotalreadyreplied(s):
return True
return False
def hasbotalreadyreplied(s):
if type(s).__name__ == "Submission":
for comment in s.comments:
if comment.author == BOT_USERNAME:
return True
elif type(s).__name__ == "Comment":
comment = reddit.comment(s.id)
try:
comment.refresh()
except praw.exceptions.ClientException:
try:
comment.refresh()
except praw.exceptions.ClientException:
# ignore comment
return True
if comment.author == BOT_USERNAME:
return True
submission_title = str(comment.submission.title)
megathread = submission_title.lower().replace(" ", "").find("megathread")
if megathread != -1:
# has not replied, but skip megathreads
return True
for reply in comment.replies:
if reply.author == BOT_USERNAME:
return True
return False
def buildcommenttext_awa(g, source):
commenttext = ''
if source == "new":
commenttext += "**Giveaway details**\n\n"
if isinstance(g.keys_tier, list) and len(g.keys_tier) > 0 and (g.keys_tier[0][1] != '0' or (len(g.keys_tier) > 1 and g.keys_tier[1][1] != '0')):
if source == "update" or len(g.keys_tier) != 0:
commenttext += "* Available keys: " + g.keys_tier[0][1] + "\n"
commenttext += "* Tier required: " + g.keys_tier[0][0] + "\n"
else:
return None
if source == "new":
if len(g.country_names_with_keys) != 0 and len(g.country_names_with_keys) <= 10:
commenttext += "* Keys available for: " + ', '.join(g.country_names_with_keys) + "\n"
elif len(g.country_names_without_keys) != 0:
commenttext += "* No keys for: " + ', '.join(g.country_names_without_keys) + "\n"
elif len(g.country_names_with_keys) > 10 and len(g.country_names_without_keys) == 0:
commenttext += "* Keys available for all countries\n"
commenttext += "* Total keys: " + g.keys_tier[0][1] + "\n"
elif isinstance(g.keys_tier, list) and source == "update" and len(g.keys_tier) > 0 and g.keys_tier[0][1] == '0':
commenttext += "* Available keys: " + g.keys_tier[0][1] + "\n"
commenttext += "* Tier required: " + g.keys_tier[0][0] + "\n"
else:
return None
if source == "new":
commenttext += '\n*Updating available keys every minute*\n'
commenttext += '\n***\n'
return commenttext
def buildcommenttext_igames(g, source):
commenttext = ''
if source == "new":
commenttext += "**Giveaway details**\n\n"
if isinstance(g.key_amount, str) and ((g.key_total != "0" and source == "update") or source == "new") and not g.gg_app:
commenttext += "* Available keys: " + g.key_amount
if g.key_claimed != "0":
commenttext += "\n"
commenttext += "* Keys already claimed: " + g.key_claimed
if source != "update":
commenttext += "\n"
if g.key_claimed != "0" and g.key_total != "0":
commenttext += "* Total keys: " + g.key_total + "\n"
else:
return None
if source == "new":
commenttext += '\n*Updating available keys every minute*\n'
commenttext += '\n***\n'
return commenttext
def buildcommenttext_keyhub(g, source):
commenttext = ''
if source == "new":
commenttext += "**Giveaway details**\n\n"
if isinstance(g.key_amount, str) and ((g.key_amount != "0" and source == "new") or source == "update"):
commenttext += "* Available keys: " + g.key_amount + "\n"
if source == "new":
commenttext += "* Steam level required: " + g.level + "\n"
commenttext += "* Total keys: " + g.key_amount + "\n"
else:
return None
if source == "new":
commenttext += '\n*Updating available keys every minute*\n'
commenttext += '\n***\n'
return commenttext
def buildcommenttext_gog(g):
commenttext = ''
if isinstance(g.title, str):
commenttext += '**' + g.title + '**'
commenttext += '\n\n'
commenttext += '[GOG Store Page](' + "https://www.gog.com/game/" + g.gog_link + ")"
if g.steamgame.appid != 0:
commenttext += " | [Steam Store Page](" + "https://store.steampowered.com/app/" + g.steamgame.appid + ")"
if g.gettype == "game" and g.pcgamingwiki:
commenttext += " | [PCGamingWiki](https://www.pcgamingwiki.com/api/appid.php?appid=" + g.steamgame.appid + ')'
commenttext += '\n\n'
if g.steamreviews:
commenttext += ' * '
commenttext += 'GOG Reviews: '
commenttext += g.reviewsummary
if g.reviewdetails:
commenttext += g.reviewdetails
if g.steamreviews:
commenttext += '\n'
commenttext += ' * Steam Reviews: '
commenttext += g.steamreviews
commenttext += '\n\n'
if g.blurb:
commenttext += '*' + g.blurb + '*\n\n'
if g.releasedate:
commenttext += ' * '
if g.gettype == "dlc":
commenttext += 'DLC '
commenttext += 'Release Date: ' + g.releasedate
commenttext += '\n'
if g.developers:
commenttext += ' * Developer'
if len(g.developers) > 1:
commenttext += 's'
commenttext += ': ' + ", ".join(g.developers) + '\n'
if g.features:
commenttext += ' * GOG Features: ' + ", ".join(g.features) + '\n'
if g.os:
commenttext += ' * Operating System'
if len(g.os) > 1:
commenttext += 's'
commenttext += ': ' + ", ".join(g.os) + '\n'
if g.genres_tags and len(g.genres_tags) != 0:
commenttext += ' * Genre/Tags: ' + ", ".join(g.genres_tags) + '\n'
commenttext += '\n***\n'
return commenttext
def buildcommenttext_epic(g):
commenttext = ''
if isinstance(g.checkout_link, str) and g.checkout_link != "":
commenttext += "**Giveaway details**\n\n"
commenttext += "* Instant checkout: " + g.checkout_link
commenttext += "\n"
if g.blacklisted_countries != "":
commenttext += "* Blacklisted countries: " + ', '.join(g.blacklisted_countries)
commenttext += "\n"
commenttext += '\n***\n'
else:
return None
return commenttext
def buildcommenttext(g, removed, source):
commenttext = ''
javascripttext = ''
if isinstance(g.title, str):
if source == "Indiegala" or source == "Epic":
commenttext += '*Game with the same name on Steam:* '
if removed:
commenttext += '*Removed from Steam - this is information from ' + g.date + ':*\n\n'
commenttext += '**' + g.title + '**'
if g.nsfw:
commenttext += ' *(NSFW)*'
commenttext += '\n\n'
if g.gettype == "dlc":
commenttext += '* DLC links: '
elif g.gettype == "music":
commenttext += '* Soundtrack links: '
elif g.gettype == "mod":
commenttext += '* Mod links: '
commenttext += '[Store Page'
if removed:
commenttext += ' (archived)'
commenttext += ']('
if not removed:
commenttext += g.url.replace("?cc=us", "")
else:
commenttext += g.url
commenttext += ') | '
if g.gettype == "game" or g.gettype == "mod":
commenttext += '[Community Hub](https://steamcommunity.com/app/' + g.appID + ') | '
commenttext += '[SteamDB](https://steamdb.info/app/' + g.appID + ')'
if g.gettype == "game" and g.pcgamingwiki:
commenttext += ' | [PCGamingWiki](https://www.pcgamingwiki.com/api/appid.php?appid=' + g.appID + ')'
commenttext += '\n'
if (g.gettype == "dlc" or g.gettype == "mod") and g.basegame is not None:
commenttext += '* '
if g.basegame[2] == "Free":
commenttext += 'Free'
else:
commenttext += 'Paid'
commenttext += ' Base Game: **' + g.basegame[1] + '** - '
if removed:
commenttext += '[Store Page (archived)](' + g.basegame[6]
else:
commenttext += '[Store Page](https://store.steampowered.com/app/' + g.basegame[0]
commenttext += ') | [Community Hub](https://steamcommunity.com/app/' + g.basegame[0] + ') | [SteamDB](https://steamdb.info/app/' + g.basegame[0] + ')'
if g.basegame[6]:
commenttext += ' | [PCGamingWiki](https://www.pcgamingwiki.com/api/appid.php?appid=' + g.basegame[0] + ')'
commenttext += '\n\n'
elif g.gettype == "music" and g.basegame is not None:
if removed:
commenttext += '* Base game ([' + g.basegame[1] + '](' + g.basegame[6] + ')) not required\n\n'
else:
commenttext += '* Base game ([' + g.basegame[1] + '](https://store.steampowered.com/app/' + g.basegame[0] + ')) not required\n\n'
else:
commenttext += '\n'
if not g.unreleased and (g.reviewsummary != "" or g.reviewdetails != ""):
if g.gettype == "dlc":
commenttext += 'DLC '
commenttext += 'Reviews: '
if g.reviewdetails != "" and g.lowreviews:
commenttext += g.reviewdetails
if not removed:
commenttext += " ^(includes key reviews)"
elif g.reviewdetails != "" and g.reviewdetails is not None:
if "user reviews" in g.reviewsummary:
commenttext += g.reviewdetails
else:
commenttext += g.reviewsummary + g.reviewdetails
else:
commenttext += g.reviewsummary
if g.steamdbrating:
commenttext += ' | SteamDB Rating: ' + g.steamdbrating + '%'
commenttext += '\n\n'
if g.blurb != "":
commenttext += '*' + g.blurb + '*\n\n'
if g.unreleased:
if g.unreleasedtext is None:
commenttext += " * Isn't released yet\n"
else:
commenttext += ' * ' + g.unreleasedtext
if g.isearlyaccess:
commenttext += ' (Early Access)'
commenttext += '\n'
if not removed and not (g.unreleased and g.price[0] == "No price found"):
commenttext += ' * '
if g.gettype == "dlc" and g.price[0] == "Free" and g.price[1] == "" and g.basegame is not None and g.basegame[2] == "Free" and g.basegame[3] == "":
commenttext += 'Game and '
if g.gettype == "dlc":
commenttext += 'DLC '
elif g.gettype == "music":
commenttext += 'Soundtrack '
commenttext += 'Price: '
if g.price[1] != "":
commenttext += '~~' + g.price[1] + '~~ '
commenttext += g.price[0]
if not g.isfree() and g.price[0] != ("Free" and "No price found"):
commenttext += ' USD'
if g.price[0] != "No price found" and g.price[1] != "" and g.discountamount:
commenttext += ' (' + g.discountamount + ')'
commenttext += '\n'
if (g.gettype == "dlc" or g.gettype == "mod") and g.basegame is not None and len(g.basegame) > 2 and (g.price[0] != "Free" or g.price[1] != "" or g.basegame[3] != "" or g.basegame[2] != "Free"):
commenttext += ' * Game Price: '
if g.basegame[3] != "":
commenttext += '~~' + g.basegame[3] + '~~ '
commenttext += g.basegame[2]
if not g.basegame[4] and g.basegame[2] != ("Free" and "No price found"):
commenttext += ' USD'
if g.basegame[2] != "No price found" and g.basegame[3] != "" and g.basegame[5]:
commenttext += ' (' + g.basegame[5] + ')'
commenttext += '\n'
if not g.unreleased and g.releasedate:
commenttext += ' * '
if g.gettype == "dlc":
commenttext += 'DLC '
commenttext += 'Release Date: ' + g.releasedate
if g.isearlyaccess:
commenttext += ' (Early Access)'
commenttext += '\n'
if g.developers:
commenttext += ' * Developer'
if g.developers_num > 1:
commenttext += 's'
commenttext += ': ' + g.developers + '\n'
if g.usertags and g.usertags != "":
commenttext += ' * Genre/Tags: ' + g.usertags + '\n'
elif g.genres:
commenttext += ' * Genre: ' + g.genres + '\n'
if g.gettype == "game" and source == "Steam":
if not g.unreleased:
if int(g.achievements) == 1:
commenttext += ' * Has ' + str(g.achievements) + ' achievement\n'
if int(g.achievements) > 1:
commenttext += ' * Has ' + str(g.achievements) + ' achievements\n'
if len(g.cards) == 4 and g.cards[0] != 0:
if int(g.achievements) == 0:
commenttext += ' * Has no achievements\n'
commenttext += ' * Has ' + str(g.cards[0]) + ' trading cards'
if g.cards[1] != 0 and not g.isfree():
commenttext += ' (drops ' + str(g.cards[1]) + ')'
elif g.cards[1] != 0 and g.isfree():
commenttext += ' (no drops)'
if not g.cards[3]:
commenttext += ' [non-marketable]'
if g.cards[3]:
commenttext += ' [^(view on Steam Market)](' + g.cards[2] + ')'
commenttext += '\n'
if len(g.cards) == 3 and g.cards[0] != 0:
if int(g.achievements) == 0:
commenttext += ' * Has no achievements\n'
commenttext += ' * Has trading cards'
commenttext += ' [^(view on Steam Market)](' + g.cards[2] + ')'
commenttext += '\n'
if g.cards[0] == 0:
commenttext += ' * Has no trading cards'
if int(g.achievements) == 0:
commenttext += ' or achievements'
commenttext += '\n'
if not g.unreleased and g.plusone:
commenttext += ' * Gives'
elif g.unreleased and g.plusone:
commenttext += ' * Full game license (no beta testing) will give'
else:
commenttext += ' * Does not give'
commenttext += ' +1 game count [^(what is +1?)](https://www.reddit.com/r/FreeGameFindings/wiki/faq/#wiki_what_is_.2B1.3F)\n'
if (g.isfree() or g.price[0] == "Free") and not g.unreleased and (source == "Steam" or g.gettype != "dlc" or (g.gettype == "dlc" and (g.isfree() or g.price[0] == "Free") and g.basegame is not None and len(g.basegame) > 2 and g.basegame[4])):
commenttext += ' * Can be added to ASF clients with `!addlicense asf '
if g.gettype == "dlc" and g.basegame is not None and len(g.basegame) > 2 and g.basegame[4]:
commenttext += "a/" + g.basegame[0] + ","
commenttext += g.asf[0] + '`\n'
if g.asf[1] == "sub":
javascripttext = f'javascript:AddFreeLicense({g.asf[0].strip("s/")})'
commenttext += f' * Can be added in browsers/mobile with `{javascripttext}`\n'
commenttext += '\n***\n'
return commenttext, javascripttext
def buildfootertext():
footertext = "^(I am a bot) Comments? Suggestions? [Let the FGF mods know!](https://www.reddit.com/message/compose?to=%2Fr%2FFreeGameFindings&subject=FGF%20bot) | [Source](https://github.com/Saulios/RedditSteamGameInfo)"
return footertext
def repostwatch_title(title):
repost_title_regex = r"[.;?!]$"
if re.search(repost_title_regex, title):
return True
else:
return False
def repostwatch_duplicate(submission):
for duplicate in submission.duplicates():
if duplicate.subreddit == SUBLIST:
created_time = duplicate.created_utc
now = time.time()
age = now - created_time
days_364 = 31449600
days_366 = 31622400
if days_364 <= age <= days_366:
return True
else:
return False
def buildcommenttext_repost(submission):
commenttext = 'I have detected that this may be a false submission from a repost bot, and have therefore removed this submission as a precaution.\n\nIf this is a mistake, please send a message to us with [this link]'
commenttext += '(https://www.reddit.com/message/compose?to=%2Fr%2Ffreegamefindings&subject=FGF%20bot%20removed%20my%20post%2C%20please%20approve%20it%20if%20it%20conforms%20to%20the%20subreddit%20rules.&message=FGF%20bot%20removed%20my%20post%2C%20please%20approve%20it%20if%20it%20conforms%20to%20the%20subreddit%20rules.%20https://www.reddit.com' + submission.permalink + ')'
commenttext += ' and we will approve it as soon as possible.'
return commenttext
class SubWatch(threading.Thread):
def run(self):
print('Started watching subs: ' + SUBLIST)
subreddit = reddit.subreddit(SUBLIST)
while True:
try:
for submission in subreddit.stream.submissions():
if submission.banned_by is not None:
continue
if (
re.search(STEAM_APPURL_REGEX, submission.url)
or re.search(STEAMDB_APPURL_REGEX, submission.url)
):
appid = re.search('\d+', submission.url).group(0)
source_platform = "Steam"
if fitscriteria(submission):
commenttext, javascripttext = buildcommenttext(SteamGame(appid), False, source_platform)
if commenttext is not None and commenttext != "":
commenttext += buildfootertext()
if len(commenttext) < 10000:
print('Commenting on post ' + str(submission) + ' after finding game ' + appid, flush=True)
botcomment = submission.reply(commenttext)
if javascripttext is not None and javascripttext != "":
botcomment.reply(javascripttext)
if "*(NSFW)*" in commenttext and submission.over_18 is False:
# Set post as NSFW
submission.mod.nsfw()
if "* Paid Base Game:" in commenttext:
# Check for paid base game DLC
flair_text = submission.link_flair_text
if flair_text is None:
# if no flair exists
new_text = "Paid Base Game"
submission.mod.flair(text=new_text, css_class="BasePaid", flair_template_id="129ebd48-becd-11ed-9399-b250c43c4702")
elif "paid base game" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = flair_text + " | Paid Base Game"
submission.mod.flair(text=new_text, flair_template_id=flair_id)
elif re.search(STEAM_TITLE_REGEX, submission.title, re.IGNORECASE):
title_split = re.split(STEAM_TITLE_REGEX, submission.title, flags=re.IGNORECASE)
game_name = title_split[-1].strip()
if fitscriteria(submission) and game_name != "":
game = SteamSearchGame(game_name, False)
appid = game.appid
source_platform = "Steam"
if appid != 0:
commenttext, javascripttext = buildcommenttext(SteamGame(appid), False, source_platform)
if commenttext is not None and commenttext != "":
commenttext_awa = ""
if re.search(ALIENWARE_URL_REGEX, submission.url):
commenttext_awa = buildcommenttext_awa(AlienwareArena(submission.url, "new"), "new")
if commenttext_awa is not None and commenttext_awa != "":
commenttext = commenttext_awa + commenttext
commenttext_igames = ""
g_website = "steelseries"
if re.search(CRUCIAL_URL_REGEX, submission.url):
g_website = "crucial"
elif re.search(IGAMES_URL_REGEX, submission.url):
g_website = "igames"
if (
re.search(STEELSERIES_URL_REGEX, submission.url)
or re.search(CRUCIAL_URL_REGEX, submission.url)
or re.search(IGAMES_URL_REGEX, submission.url)
):
g_id = re.search('\d+', submission.url).group(0)
commenttext_igames = buildcommenttext_igames(iGames(g_id, g_website), "new")
if commenttext_igames is not None and commenttext_igames != "":
commenttext = commenttext_igames + commenttext
commenttext_keyhub = ""
if re.search(KEYHUB_URL_REGEX, submission.url):
commenttext_keyhub = buildcommenttext_keyhub(Keyhub(submission.url, "new"), "new")
if commenttext_keyhub is not None and commenttext_keyhub != "":
commenttext = commenttext_keyhub + commenttext
commenttext += buildfootertext()
if len(commenttext) < 10000:
print('Commenting on post ' + str(submission) + ' after finding game ' + game_name, flush=True)
botcomment = submission.reply(commenttext)
if javascripttext is not None and javascripttext != "":
botcomment.reply(javascripttext)
if commenttext_awa is not None and commenttext_awa != "":
flair_text = submission.link_flair_text
tier_number = commenttext_awa.split("Tier required: ")[1].split()[0]
if "Tier required: 1" not in commenttext_awa and "* Keys available for all countries\n" not in commenttext_awa:
# flair post with prior work required, regional issues and add tier
if flair_text is None:
# if no flair exists
new_text = "Tier " + tier_number + "+ | Prior Work Required | Regional Issues"
submission.mod.flair(text=new_text, css_class="restoften", flair_template_id="b204d6b4-0b90-11e4-9095-12313b0add52")
elif "prior work" not in flair_text.lower() and "regional" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = "Tier " + tier_number + "+ | Prior Work Required | Regional Issues | " + flair_text
submission.mod.flair(text=new_text, flair_template_id=flair_id)
elif "regional" not in flair_text.lower():
# if regional not yet in flair
flair_id = submission.link_flair_template_id
new_text = "Tier " + tier_number + "+ | Regional Issues | " + flair_text
submission.mod.flair(text=new_text, flair_template_id=flair_id)
if "Tier required: 1" not in commenttext_awa and "* Keys available for all countries\n" in commenttext_awa:
# flair post with prior work required and add tier
if flair_text is None:
# if no flair exists
new_text = "Tier " + tier_number + "+ | Prior Work Required"
submission.mod.flair(text=new_text, css_class="restoften", flair_template_id="b204d6b4-0b90-11e4-9095-12313b0add52")
elif "prior work" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = "Tier " + tier_number + "+ | Prior Work Required | " + flair_text
submission.mod.flair(text=new_text, flair_template_id=flair_id)
if "* Keys available for all countries\n" not in commenttext_awa and "Tier required: 1" in commenttext_awa:
# flair post with regional issues
if flair_text is None:
# if no flair exists
submission.mod.flair(text="Regional Issues", css_class="Regionlocked", flair_template_id="b3a089de-2437-11e6-8bda-0e93018c4773")
elif "regional" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = flair_text + " | Regional Issues"
submission.mod.flair(text=new_text, flair_template_id=flair_id)
if commenttext_keyhub is not None and commenttext_keyhub != "":
flair_text = submission.link_flair_text
level_number = commenttext_keyhub.split("Steam level required: ")[1].split()[0]
if flair_text is None:
# if no flair exists
new_text = "Steam level " + level_number + "+"
submission.mod.flair(text=new_text, css_class="ReadComments", flair_template_id="c7e83006-e1b5-11e4-b507-22000b2681f9")
elif "level" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = "Steam level " + level_number + "+ | " + flair_text
submission.mod.flair(text=new_text, flair_template_id=flair_id)
if "*(NSFW)*" in commenttext and submission.over_18 is False:
# Set post as NSFW
submission.mod.nsfw()
if "* Paid Base Game:" in commenttext:
# Check for paid base game DLC
flair_text = submission.link_flair_text
if flair_text is None:
# if no flair exists
new_text = "Paid Base Game"
submission.mod.flair(text=new_text, css_class="BasePaid", flair_template_id="129ebd48-becd-11ed-9399-b250c43c4702")
elif "paid base game" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = flair_text + " | Paid Base Game"
submission.mod.flair(text=new_text, flair_template_id=flair_id)
else:
game = SteamSearchGame(game_name, True)
appid = game.appid
if appid != 0:
# try for only removed store page
commenttext, javascripttext = buildcommenttext(SteamGame(appid), False, source_platform)
if commenttext is None or commenttext == "":
# not available on Steam
commenttext, javascripttext = buildcommenttext(SteamRemovedGame(appid), True, source_platform)
if commenttext is not None and commenttext != "":
commenttext_awa = ""
if re.search(ALIENWARE_URL_REGEX, submission.url):
commenttext_awa = buildcommenttext_awa(AlienwareArena(submission.url, "new"), "new")
if commenttext_awa is not None and commenttext_awa != "":
commenttext = commenttext_awa + commenttext
commenttext_igames = ""
g_website = "steelseries"
if re.search(CRUCIAL_URL_REGEX, submission.url):
g_website = "crucial"
elif re.search(IGAMES_URL_REGEX, submission.url):
g_website = "igames"
if (
re.search(STEELSERIES_URL_REGEX, submission.url)
or re.search(CRUCIAL_URL_REGEX, submission.url)
or re.search(IGAMES_URL_REGEX, submission.url)
):
g_id = re.search('\d+', submission.url).group(0)
commenttext_igames = buildcommenttext_igames(iGames(g_id, g_website), "new")
if commenttext_igames is not None and commenttext_igames != "":
commenttext = commenttext_igames + commenttext
commenttext_keyhub = ""
if re.search(KEYHUB_URL_REGEX, submission.url):
commenttext_keyhub = buildcommenttext_keyhub(Keyhub(submission.url, "new"), "new")
if commenttext_keyhub is not None and commenttext_keyhub != "":
commenttext = commenttext_keyhub + commenttext
commenttext += buildfootertext()
if len(commenttext) < 10000:
print('Commenting on post ' + str(submission) + ' after finding removed game ' + game_name, flush=True)
botcomment = submission.reply(commenttext)
if javascripttext is not None and javascripttext != "":
botcomment.reply(javascripttext)
flair_text = submission.link_flair_text
if commenttext.startswith("*Removed from Steam"):
if flair_text is None:
# flair post with delisted if no flair exists
submission.mod.flair(text="Delisted Game", css_class="DelistedGame", flair_template_id="9a5196c4-8865-11ec-8a1f-8261ed8ecd20")
elif "delisted" not in flair_text.lower():
# flair post with delisted if not yet in flair
flair_id = submission.link_flair_template_id
new_text = flair_text + " | Delisted Game"
submission.mod.flair(text=new_text, flair_template_id=flair_id)
if commenttext_awa is not None and commenttext_awa != "":
tier_number = commenttext_awa.split("Tier required: ")[1].split()[0]
if "Tier required: 1" not in commenttext_awa and "* Keys available for all countries\n" not in commenttext_awa:
# flair post with prior work required, regional issues and add tier
if flair_text is None:
# if no flair exists
new_text = "Tier " + tier_number + "+ | Prior Work Required | Regional Issues"
submission.mod.flair(text=new_text, css_class="restoften", flair_template_id="b204d6b4-0b90-11e4-9095-12313b0add52")
elif "prior work" not in flair_text.lower() and "regional" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = "Tier " + tier_number + "+ | Prior Work Required | Regional Issues" + flair_text
submission.mod.flair(text=new_text, flair_template_id=flair_id)
elif "regional" not in flair_text.lower():
# if regional not yet in flair
flair_id = submission.link_flair_template_id
new_text = "Tier " + tier_number + "+ | Regional Issues | " + flair_text
submission.mod.flair(text=new_text, flair_template_id=flair_id)
if "Tier required: 1" not in commenttext_awa and "* Keys available for all countries\n" in commenttext_awa:
# flair post with prior work required and add tier
if flair_text is None:
# if no flair exists
new_text = "Tier " + tier_number + "+ | Prior Work Required"
submission.mod.flair(text=new_text, css_class="restoften", flair_template_id="b204d6b4-0b90-11e4-9095-12313b0add52")
elif "prior work" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = "Tier " + tier_number + "+ | Prior Work Required | " + flair_text
submission.mod.flair(text=new_text, flair_template_id=flair_id)
if "* Keys available for all countries\n" not in commenttext_awa and "Tier required: 1" in commenttext_awa:
# flair post with regional issues
if flair_text is None:
# if no flair exists
submission.mod.flair(text="Regional Issues", css_class="Regionlocked", flair_template_id="b3a089de-2437-11e6-8bda-0e93018c4773")
elif "regional" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = flair_text + " | Regional Issues"
submission.mod.flair(text=new_text, flair_template_id=flair_id)
if commenttext_keyhub is not None and commenttext_keyhub != "":
flair_text = submission.link_flair_text
level_number = commenttext_keyhub.split("Steam level required: ")[1].split()[0]
if flair_text is None:
# if no flair exists
new_text = "Steam level " + level_number + "+"
submission.mod.flair(text=new_text, css_class="ReadComments", flair_template_id="c7e83006-e1b5-11e4-b507-22000b2681f9")
elif "level" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = "Steam level " + level_number + "+ | " + flair_text
submission.mod.flair(text=new_text, flair_template_id=flair_id)
if "*(NSFW)*" in commenttext and submission.over_18 is False:
# Set post as NSFW
submission.mod.nsfw()
if "* Paid Base Game:" in commenttext:
# Check for paid base game DLC
flair_text = submission.link_flair_text
if flair_text is None:
# if no flair exists
new_text = "Paid Base Game"
submission.mod.flair(text=new_text, css_class="BasePaid", flair_template_id="129ebd48-becd-11ed-9399-b250c43c4702")
elif "paid base game" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = flair_text + " | Paid Base Game"
submission.mod.flair(text=new_text, flair_template_id=flair_id)
elif (
re.search(STEELSERIES_URL_REGEX, submission.url)
or re.search(CRUCIAL_URL_REGEX, submission.url)
or re.search(IGAMES_URL_REGEX, submission.url)
or re.search(ALIENWARE_URL_REGEX, submission.url)
or re.search(KEYHUB_URL_REGEX, submission.url)
):
# Not found on archive.org, post steamdb and key availability part
commenttext += '*Removed from Steam, no information found on archive.org*\n\n'
commenttext += '**' + game_name +'**\n\n'
commenttext += '[Community Hub](https://steamcommunity.com/app/' + game.appid + ') | '
commenttext += '[SteamDB](https://steamdb.info/app/' + game.appid + ')\n\n***\n'
g_website = "steelseries"
if re.search(CRUCIAL_URL_REGEX, submission.url):
g_website = "crucial"
elif re.search(IGAMES_URL_REGEX, submission.url):
g_website = "igames"
if (
re.search(STEELSERIES_URL_REGEX, submission.url)
or re.search(CRUCIAL_URL_REGEX, submission.url)
or re.search(IGAMES_URL_REGEX, submission.url)
):
g_id = re.search('\d+', submission.url).group(0)
commenttext = buildcommenttext_igames(iGames(g_id, g_website), "new")
if re.search(ALIENWARE_URL_REGEX, submission.url):
g_website = "alienware"
commenttext = buildcommenttext_awa(AlienwareArena(submission.url, "new"), "new")
if re.search(KEYHUB_URL_REGEX, submission.url):
g_website = "keyhub"
commenttext = buildcommenttext_keyhub(Keyhub(submission.url, "new"), "new")
if commenttext is not None and commenttext != "":
commenttext += buildfootertext()
if len(commenttext) < 10000:
print('Commenting on post ' + str(submission) + ' after finding ' + g_website + ' domain', flush=True)
submission.reply(body=commenttext)
flair_text = submission.link_flair_text
if commenttext.startswith("*Removed from Steam"):
if flair_text is None:
# flair post with delisted if no flair exists
submission.mod.flair(text="Delisted Game", css_class="DelistedGame", flair_template_id="9a5196c4-8865-11ec-8a1f-8261ed8ecd20")
elif "delisted" not in flair_text.lower():
# flair post with delisted if not yet in flair
flair_id = submission.link_flair_template_id
new_text = flair_text + " | Delisted Game"
submission.mod.flair(text=new_text, flair_template_id=flair_id)
if g_website == "alienware" and commenttext is not None and commenttext != "":
tier_number = commenttext.split("Tier required: ")[1].split()[0]
if "Tier required: 1" not in commenttext and "* Keys available for all countries\n" not in commenttext:
# flair post with prior work required, regional issues and add tier
if flair_text is None:
# if no flair exists
new_text = "Tier " + tier_number + "+ | Prior Work Required | Regional Issues"
submission.mod.flair(text=new_text, css_class="restoften", flair_template_id="b204d6b4-0b90-11e4-9095-12313b0add52")
elif "prior work" not in flair_text.lower() and "regional" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = "Tier " + tier_number + "+ | Prior Work Required | Regional Issues" + flair_text
submission.mod.flair(text=new_text, flair_template_id=flair_id)
elif "regional" not in flair_text.lower():
# if regional not yet in flair
flair_id = submission.link_flair_template_id
new_text = "Tier " + tier_number + "+ | Regional Issues | " + flair_text
submission.mod.flair(text=new_text, flair_template_id=flair_id)
if "Tier required: 1" not in commenttext and "* Keys available for all countries\n" in commenttext:
# flair post with prior work required and add tier
if flair_text is None:
# if no flair exists
new_text = "Tier " + tier_number + "+ | Prior Work Required"
submission.mod.flair(text=new_text, css_class="restoften", flair_template_id="b204d6b4-0b90-11e4-9095-12313b0add52")
elif "prior work" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = "Tier " + tier_number + "+ | Prior Work Required | " + flair_text
submission.mod.flair(text=new_text, flair_template_id=flair_id)
if "* Keys available for all countries\n" not in commenttext and "Tier required: 1" in commenttext:
# flair post with regional issues
if flair_text is None:
# if no flair exists
submission.mod.flair(text="Regional Issues", css_class="Regionlocked", flair_template_id="b3a089de-2437-11e6-8bda-0e93018c4773")
elif "regional" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = flair_text + " | Regional Issues"
submission.mod.flair(text=new_text, flair_template_id=flair_id)
if g_website == "keyhub" and commenttext is not None and commenttext != "":
flair_text = submission.link_flair_text
level_number = commenttext.split("Steam level required: ")[1].split()[0]
if flair_text is None:
# if no flair exists
new_text = "Steam level " + level_number + "+"
submission.mod.flair(text=new_text, css_class="ReadComments", flair_template_id="c7e83006-e1b5-11e4-b507-22000b2681f9")
elif "level" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = "Steam level " + level_number + "+ | " + flair_text
submission.mod.flair(text=new_text, flair_template_id=flair_id)
if "*(NSFW)*" in commenttext and submission.over_18 is False:
# Set post as NSFW
submission.mod.nsfw()
elif (
re.search(STEELSERIES_URL_REGEX, submission.url)
or re.search(CRUCIAL_URL_REGEX, submission.url)
or re.search(IGAMES_URL_REGEX, submission.url)
or re.search(ALIENWARE_URL_REGEX, submission.url)
or re.search(KEYHUB_URL_REGEX, submission.url)
):
# Not found on steam-tracker, still post key availability part
g_website = "steelseries"
if re.search(CRUCIAL_URL_REGEX, submission.url):
g_website = "crucial"
elif re.search(IGAMES_URL_REGEX, submission.url):
g_website = "igames"
if (
re.search(STEELSERIES_URL_REGEX, submission.url)
or re.search(CRUCIAL_URL_REGEX, submission.url)
or re.search(IGAMES_URL_REGEX, submission.url)
):
g_id = re.search('\d+', submission.url).group(0)
commenttext = buildcommenttext_igames(iGames(g_id, g_website), "new")
if re.search(ALIENWARE_URL_REGEX, submission.url):
g_website = "alienware"
commenttext = buildcommenttext_awa(AlienwareArena(submission.url, "new"), "new")
if re.search(KEYHUB_URL_REGEX, submission.url):
g_website = "keyhub"
commenttext = buildcommenttext_keyhub(Keyhub(submission.url, "new"), "new")
if commenttext is not None and commenttext != "":
commenttext += buildfootertext()
if len(commenttext) < 10000:
print('Commenting on post ' + str(submission) + ' after finding ' + g_website + ' domain', flush=True)
submission.reply(body=commenttext)
flair_text = submission.link_flair_text
if g_website == "alienware" and commenttext is not None and commenttext != "":
tier_number = commenttext.split("Tier required: ")[1].split()[0]
if "Tier required: 1" not in commenttext and "* Keys available for all countries\n" not in commenttext:
# flair post with prior work required, regional issues and add tier
if flair_text is None:
# if no flair exists
new_text = "Tier " + tier_number + "+ | Prior Work Required | Regional Issues"
submission.mod.flair(text=new_text, css_class="restoften", flair_template_id="b204d6b4-0b90-11e4-9095-12313b0add52")
elif "prior work" not in flair_text.lower() and "regional" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = "Tier " + tier_number + "+ | Prior Work Required | Regional Issues" + flair_text
submission.mod.flair(text=new_text, flair_template_id=flair_id)
elif "regional" not in flair_text.lower():
# if regional not yet in flair
flair_id = submission.link_flair_template_id
new_text = "Tier " + tier_number + "+ | Regional Issues | " + flair_text
submission.mod.flair(text=new_text, flair_template_id=flair_id)
if "Tier required: 1" not in commenttext and "* Keys available for all countries\n" in commenttext:
# flair post with prior work required and add tier
if flair_text is None:
# if no flair exists
new_text = "Tier " + tier_number + "+ | Prior Work Required"
submission.mod.flair(text=new_text, css_class="restoften", flair_template_id="b204d6b4-0b90-11e4-9095-12313b0add52")
elif "prior work" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = "Tier " + tier_number + "+ | Prior Work Required | " + flair_text
submission.mod.flair(text=new_text, flair_template_id=flair_id)
if "* Keys available for all countries\n" not in commenttext and "Tier required: 1" in commenttext:
# flair post with regional issues
if flair_text is None:
# if no flair exists
submission.mod.flair(text="Regional Issues", css_class="Regionlocked", flair_template_id="b3a089de-2437-11e6-8bda-0e93018c4773")
elif "regional" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = flair_text + " | Regional Issues"
submission.mod.flair(text=new_text, flair_template_id=flair_id)
if g_website == "keyhub" and commenttext is not None and commenttext != "":
flair_text = submission.link_flair_text
level_number = commenttext.split("Steam level required: ")[1].split()[0]
if flair_text is None:
# if no flair exists
new_text = "Steam level " + level_number + "+"
submission.mod.flair(text=new_text, css_class="ReadComments", flair_template_id="c7e83006-e1b5-11e4-b507-22000b2681f9")
elif "level" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = "Steam level " + level_number + "+ | " + flair_text
submission.mod.flair(text=new_text, flair_template_id=flair_id)
if "*(NSFW)*" in commenttext and submission.over_18 is False:
# Set post as NSFW
submission.mod.nsfw()
elif re.search(INDIEGALA_TITLE_REGEX, submission.title, re.IGNORECASE) and re.search(INDIEGALA_URL_REGEX, submission.url):
title_split = re.split(INDIEGALA_TITLE_REGEX, submission.title, flags=re.IGNORECASE)
source_platform = "Indiegala"
game_name = title_split[-1].strip()
if fitscriteria(submission) and game_name != "":
game = SteamSearchGame(game_name, False, "non-Steam")
if game.appid == 0:
game = SteamSearchGame(game_name, True, "non-Steam")
appid = game.appid
if appid != 0:
commenttext, javascripttext = buildcommenttext(SteamGame(appid), False, source_platform)
if commenttext is not None and commenttext != "":
commenttext += buildfootertext()
if len(commenttext) < 10000:
print('Commenting on post ' + str(submission) + ' after finding game ' + game_name, flush=True)
submission.reply(body=commenttext)
if "*(NSFW)*" in commenttext and submission.over_18 is False:
# Set post as NSFW
submission.mod.nsfw()
elif re.search(EPIC_TITLE_REGEX, submission.title, re.IGNORECASE) and re.search(EPIC_URL_REGEX, submission.url):
title_split = re.split(EPIC_TITLE_REGEX, submission.title, flags=re.IGNORECASE)
source_platform = "Epic"
game_name = title_split[-1].strip()
if fitscriteria(submission) and game_name != "":
game = SteamSearchGame(game_name, False, "non-Steam")
if game.appid == 0:
game = SteamSearchGame(game_name, True, "non-Steam")
appid = game.appid
commenttext = buildcommenttext_epic(EpicGame(game_name))
if commenttext is not None and commenttext != "":
if appid != 0:
steam_commenttext, javascripttext = buildcommenttext(SteamGame(appid), False, source_platform)
if steam_commenttext is not None and steam_commenttext != "":
commenttext += steam_commenttext
commenttext += buildfootertext()
elif appid != 0:
steam_commenttext, javascripttext = buildcommenttext(SteamGame(appid), False, source_platform)
if steam_commenttext is not None and steam_commenttext != "":
steam_commenttext += buildfootertext()
commenttext = steam_commenttext
if commenttext is not None and commenttext != "" and len(commenttext) < 10000:
print('Commenting on post ' + str(submission) + ' after finding game ' + game_name, flush=True)
submission.reply(body=commenttext)
flair_text = submission.link_flair_text
if "*(NSFW)*" in commenttext and submission.over_18 is False:
# Set post as NSFW
submission.mod.nsfw()
if "* Blacklisted countries" in commenttext:
# flair post with regional issues
if flair_text is None:
# if no flair exists
submission.mod.flair(text="Regional Issues", css_class="Regionlocked", flair_template_id="b3a089de-2437-11e6-8bda-0e93018c4773")
elif "regional" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = flair_text + " | Regional Issues"
submission.mod.flair(text=new_text, flair_template_id=flair_id)
elif re.search(ALIENWARE_URL_REGEX, submission.url):
if fitscriteria(submission):
commenttext = buildcommenttext_awa(AlienwareArena(submission.url, "new"), "new")
if commenttext is not None and commenttext != "":
commenttext += buildfootertext()
if len(commenttext) < 10000:
print('Commenting on post ' + str(submission) + ' after finding Alienware Arena domain', flush=True)
submission.reply(body=commenttext)
flair_text = submission.link_flair_text
if commenttext != "":
tier_number = commenttext.split("Tier required: ")[1].split()[0]
if "Tier required: 1" not in commenttext and "* Keys available for all countries\n" not in commenttext:
# flair post with prior work required, regional issues and add tier
if flair_text is None:
# if no flair exists
new_text = "Tier " + tier_number + "+ | Prior Work Required | Regional Issues"
submission.mod.flair(text=new_text, css_class="restoften", flair_template_id="b204d6b4-0b90-11e4-9095-12313b0add52")
elif "prior work" not in flair_text.lower() and "regional" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = "Tier " + tier_number + "+ | Prior Work Required | Regional Issues" + flair_text
submission.mod.flair(text=new_text, flair_template_id=flair_id)
elif "regional" not in flair_text.lower():
# if regional not yet in flair
flair_id = submission.link_flair_template_id
new_text = "Tier " + tier_number + "+ | Regional Issues | " + flair_text
submission.mod.flair(text=new_text, flair_template_id=flair_id)
if "Tier required: 1" not in commenttext and "* Keys available for all countries\n" in commenttext:
# flair post with prior work required and add tier
if flair_text is None:
# if no flair exists
new_text = "Tier " + tier_number + "+ | Prior Work Required"
submission.mod.flair(text=new_text, css_class="restoften", flair_template_id="b204d6b4-0b90-11e4-9095-12313b0add52")
elif "prior work" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = "Tier " + tier_number + "+ | Prior Work Required | " + flair_text
submission.mod.flair(text=new_text, flair_template_id=flair_id)
if "* Keys available for all countries\n" not in commenttext and "Tier required: 1" in commenttext:
# flair post with regional issues
if flair_text is None:
# if no flair exists
submission.mod.flair(text="Regional Issues", css_class="Regionlocked", flair_template_id="b3a089de-2437-11e6-8bda-0e93018c4773")
elif "regional" not in flair_text.lower():
# if not yet in flair
flair_id = submission.link_flair_template_id
new_text = flair_text + " | Regional Issues"
submission.mod.flair(text=new_text, flair_template_id=flair_id)
elif (
re.search(STEELSERIES_URL_REGEX, submission.url)
or re.search(CRUCIAL_URL_REGEX, submission.url)
or re.search(IGAMES_URL_REGEX, submission.url)
):
if fitscriteria(submission):
g_website = "steelseries"
if re.search(CRUCIAL_URL_REGEX, submission.url):
g_website = "crucial"
elif re.search(IGAMES_URL_REGEX, submission.url):
g_website = "igames"
g_id = re.search('\d+', submission.url).group(0)
commenttext = buildcommenttext_igames(iGames(g_id, g_website), "new")
if commenttext is not None and commenttext != "":
commenttext += buildfootertext()
if len(commenttext) < 10000:
print('Commenting on post ' + str(submission) + ' after finding ' + g_website + ' domain', flush=True)
submission.reply(body=commenttext)