forked from fionafibration/team-frotress-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
102 lines (80 loc) · 2.76 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
# Team Frotress by fionafibration and semper-lux.
# Concept, initial work, and maintained by EmApex.
# Fixed up and finished by jordansds.
from config import *
import time
import logging
import asyncio
import sys
import os
from buttplug import *
import log_tailer
import vibration_handler
if not os.path.isfile("config.py"):
print("Copy config_default.py to config.py and edit it to set up!")
exit()
async def main(logfile):
client = Client("Jabooty Brawl") # :3
connector = WebsocketConnector(INTIFACE_SERVER_ADDR, logger=client.logger)
console = log_tailer.LogTail(logfile)
_ = console.read()
try:
await client.connect(connector)
except:
logging.error("Could not connect!")
return
client.logger.info("Connected to Intiface!")
if len(client.devices) == 0:
logging.error("No devices!")
return
# get steam username to detect killfeed data
name = None
logging.info("Getting name...")
while name is None:
try:
name = STEAM_NAME
except Exception as e:
print(e)
sys.exit()
logging.info(f"Got name: {name}")
logging.info("Ready to play!")
vibe = vibration_handler.VibrationHandler(logging)
killstreak = 0
killtime = 0
while True:
# detect kills and deaths from console log
while True:
line = console.read_line()
if line is None:
break
lineList = line.split("killed")
if len(lineList) == 1:
break
killer = lineList[0][:-1]
deader = lineList[1].split(" with")[0][1:]
#print(killer)
#print(deader)
if killer == name: # we got a kill
#print(time.time() - killtime)
if time.time() - killtime > KILLSTREAK_TIMEOUT:
killstreak = 1
vibe.kill(kstreak = killstreak)
print("Streak reset")
else:
killstreak += 1
vibe.kill(kstreak = killstreak)
print("Streak: " + str(killstreak))
killtime = time.time()
#print(killtime)
if deader == name: # we died :)
print("Death")
vibe.death()
print(line)
# run vibrator
await vibe.run_buzz(devices=client.devices)
await asyncio.sleep(1.0 / UPDATE_SPEED)
if __name__ == "__main__":
print("Ensure Intiface Central is running and has your device connected")
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
with open(CONSOLE_LOG, "r", encoding = "utf-8") as f:
asyncio.run(main(f))