-
Notifications
You must be signed in to change notification settings - Fork 0
/
bakkes_patchplugin.py
49 lines (40 loc) · 1.35 KB
/
bakkes_patchplugin.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
"""Script to hotswap plugin from bakkesmod process.
1. Connects to BakkesMod rcon
2. Unloads plugin
3. Replaces DLL file
4. Loads plugin
TODO: save config?
"""
import sys, os, shutil, websockets, time
import asyncio
from time import sleep
bakkesmod_plugin_folder = "C:/Program Files (x86)/Steam/steamapps/common/rocketleague/Binaries/Win64/bakkesmod/plugins/"
bakkesmod_server = 'ws://127.0.0.1:9002'
rcon_password = 'password'
swap_file = "build/bin/Release/SuperSonicML.dll"
def replace_plugin_file():
filename = os.path.basename(swap_file)
dst_file = bakkesmod_plugin_folder + filename
print(dst_file)
if os.path.exists(dst_file):
os.remove(dst_file)
shutil.copyfile(swap_file, dst_file)
async def main_loop():
try:
async with websockets.connect(bakkesmod_server, timeout=.1) as websocket:
await websocket.send('rcon_password ' + rcon_password)
auth_status = await websocket.recv()
assert auth_status == 'authyes'
sleep(0.1)
filename = os.path.basename(swap_file)
plugin_name = filename[0:filename.index('.')]
print("Copying " + filename + "")
await websocket.send("plugin unload " + plugin_name)
time.sleep(0.4)
replace_plugin_file()
time.sleep(0.1)
await websocket.send("plugin load " + plugin_name)
except:
replace_plugin_file()
if __name__ == '__main__':
asyncio.get_event_loop().run_until_complete(main_loop())