-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathEEParser.py
52 lines (44 loc) · 2.09 KB
/
EEParser.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
import os
import re
import SelfTexting
import config
from time import sleep
import DiscordWebhook
import logging
logging.basicConfig(format='{levelname:7} {message}', style='{', level=logging.DEBUG)
class WarframeLogParser:
def __init__(self, log_path):
self.log_path = log_path
def clean_username(self, username):
# Encode and decode to clean up some garbage unicode that gets attached to the end of the username
return username.encode("ascii", "ignore").decode("ascii")
def process_line(self, line):
# Adding tab with channel name: FAlextremeYT to index 10
# This line fits all our criteria, it gets called when you receive a new whisper from someone,
# the username is in cleartext, and any tabs with an index of 6 or above are reserved for usernames so no false alarms from other chat windows.
result = re.search(r'( F)(.*\S)( to index (?:[1-9]|[1-9]\d)$)', line)
if result is not None:
username = self.clean_username(result.group(2))
logging.debug(username)
print(username)
SelfTexting.send_push("WFTrade", f"Whisper(s) from {username}")
DiscordWebhook.sendMessage(f"You have whisper(s) from {username}")
def follow_and_parse_log(self):
with open(self.log_path, 'r', encoding='latin-1') as file:
# Uncomment the line below if you want to start reading from the end of the file
file.seek(0, os.SEEK_END)
while config.getConfigStatus("runningWarframeScreenDetect"):
line = file.readline()
if line:
self.process_line(line)
else:
sleep(0.1)
# Example usage:
if __name__ == "__main__":
appdata_path = '/appdata_warframe'
log_path = os.path.join(appdata_path, 'EE.log')
if not os.path.exists(log_path):
log_path = os.path.join(os.getenv('LOCALAPPDATA'), 'Warframe', 'EE.log')
logging.debug(log_path)
parser = WarframeLogParser(log_path)
parser.follow_and_parse_log()