-
Notifications
You must be signed in to change notification settings - Fork 0
/
listener.py
30 lines (23 loc) · 842 Bytes
/
listener.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
from mitmproxy import http
from json import dumps, dump
from pynput.keyboard import Key, Listener
from codingame import CustomCodinGameClient
from dotenv import load_dotenv
import os
import pprint
import time
# Load environment variables from .env file
load_dotenv()
# Access environment variables
ID = os.environ.get('ID')
COOKIE = os.environ.get('COOKIE')
# Initialize the Client
client = CustomCodinGameClient(ID, COOKIE)
# Functions
## Handle the request
def response(flow: http.HTTPFlow) -> None:
if flow.response:
open("listener.log", "at").write(f'services/TestSession/startTestSession in {flow.request.url}\n')
if "services/TestSession/startTestSession" in str(flow.request.url):
client.store_clash_info(flow.response.json())
open("listener.log", "at").write("Storing the data...\n")