Create config, remove need for touch, dont crash when logging in
Signed-off-by: Skylar "The Cobra" Widulski <cobra@vern.cc>
This commit is contained in:
parent
53b02dcd33
commit
09fbe66e2f
|
@ -20,14 +20,12 @@ ec_password XXXXXXXX
|
|||
```
|
||||
It is very important that you are not binding on a public-facing IP.
|
||||
|
||||
Next, initialize the files needed:
|
||||
|
||||
Then, edit the config to fit your use-case.
|
||||
```
|
||||
touch next_batch
|
||||
cp config.py.example config.py
|
||||
$EDITOR config.py
|
||||
```
|
||||
|
||||
Then, edit the script variables to fit your use-case.
|
||||
|
||||
Finally, run the script:
|
||||
|
||||
```
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
mx_room_id = "!roomid:matrix.org"
|
||||
mx_user_id = "@my-teeworlds-bridge:matrix.org"
|
||||
mx_homeserver = "https://matrix-client.matrix.org"
|
||||
mx_pass = "XXXXXXXXX"
|
||||
|
||||
econ_host = "127.0.0.1"
|
||||
econ_port = 8303
|
||||
econ_pass = "XXXXXXXXXXX"
|
|
@ -24,6 +24,10 @@ from promise import Promise
|
|||
import json
|
||||
import os
|
||||
import sys
|
||||
from config import mx_room_id, mx_user_id, mx_homeserver, mx_pass,
|
||||
econ_host, econ_port, econ_pass
|
||||
|
||||
source_url = 'http://git.vern.cc/cobra/teeworlds-bridge'
|
||||
|
||||
CHAT_PATTERN = re.compile(
|
||||
r'^\[\S+\]\[chat\]: \d+:\d+:(.+?): (.*)$'
|
||||
|
@ -44,16 +48,6 @@ MAP_PATTERN = re.compile(
|
|||
r'^\[\S+\]\[server\]: maps/(.+?)\.map crc is .+'
|
||||
)
|
||||
|
||||
mx_room_id = "!roomid:matrix.org"
|
||||
mx_user_id = "@my-teeworlds-bridge:matrix.org"
|
||||
mx_homeserver = "https://matrix-client.matrix.org"
|
||||
mx_pass = "XXXXXXXXX"
|
||||
|
||||
econ_host = "127.0.0.1"
|
||||
econ_port = 8303
|
||||
econ_pass = "XXXXXXXXXXX"
|
||||
|
||||
|
||||
def acquire(*modes):
|
||||
def outer(f):
|
||||
@functools.wraps(f)
|
||||
|
@ -205,8 +199,7 @@ class TeeworldsBridge:
|
|||
print(response)
|
||||
if isinstance(response, nio.LoginResponse):
|
||||
write_creds(response, "https://mtrx.vern.cc")
|
||||
print("Logged in. Restart the program")
|
||||
exit()
|
||||
print("Logged in.")
|
||||
else:
|
||||
async with aiofiles.open("teeworlds.json", "r") as f:
|
||||
contents = await f.read()
|
||||
|
@ -216,9 +209,11 @@ class TeeworldsBridge:
|
|||
self.client.user_id = config["user_id"]
|
||||
self.client.device_id = config["device_id"]
|
||||
|
||||
with open("next_batch","r") as next_batch_token:
|
||||
with open("next_batch","a+") as next_batch_token:
|
||||
self.client.next_batch = next_batch_token.read()
|
||||
|
||||
await self.client.room_send(mx_room_id, message_type="m.room.message", content={"msgtype": "m.text", "body": f"Starting Teeworlds bridge. Source code: {source_url}"})
|
||||
|
||||
while (True):
|
||||
sync_response = await self.client.sync(30000)
|
||||
|
||||
|
|
Loading…
Reference in New Issue