This repository has been archived by the owner on Feb 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from tkbstudios/rewrite
Rewrite
- Loading branch information
Showing
9 changed files
with
180 additions
and
479 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
on: | ||
push: | ||
|
||
jobs: | ||
build: | ||
runs-on: ['windows-latest'] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.11 | ||
|
||
- run: pip install -r requirements.txt pyinstaller | ||
- run: pyinstaller --onefile --icon=tkbstudios.ico tinet-bridge.py | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: tinet-bridge | ||
path: dist/tinet-bridge.exe | ||
|
||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
if: "contains(github.event.head_commit.message, 'release')" | ||
with: | ||
files: dist/tinet-bridge.exe | ||
tag_name: V${{ github.run_number }} | ||
token: ${{ secrets.CUSTOM_GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# this is a test plugin | ||
|
||
class TINETBridgePlugin: | ||
def __init__(self): | ||
self.plugin_name = "TestPlugin" | ||
print(f"Successfully loaded {self.plugin_name}") | ||
|
||
def custom_print(self, message): | ||
print(f"[{self.plugin_name}]: {message}") | ||
|
||
def log_call(self, log_message): | ||
self.custom_print(log_message) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
pyserial>=3.5 | ||
python-dotenv>=1.0.0 | ||
colorama>=0.4.6 | ||
requests>=2.31.0 | ||
pyserial==3.5 | ||
pyserial-asyncio==0.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import math | ||
import time | ||
import serial | ||
import serial.tools.list_ports | ||
|
||
#--- bridge config ---# | ||
|
||
# enable HTTP requests, be careful only using with programs you trust! | ||
ENABLE_HTTP = False | ||
|
||
#---------------------# | ||
|
||
|
||
def find_serial_port(): | ||
while True: | ||
time.sleep(0.2) | ||
ports = list(serial.tools.list_ports.comports()) | ||
for port in ports: | ||
if "USB Serial Device" in port.description or "TI-84" in port.description: | ||
return port | ||
|
||
|
||
if __name__ == "__main__": | ||
serial_port = find_serial_port() | ||
time.sleep(2) | ||
serial_connection = serial.Serial(serial_port.device, 115200, timeout=0.2) | ||
serial_connection.write(b"BRIDGE_CONNECTED\n") | ||
username = "" | ||
while True: | ||
data = serial_connection.readline() | ||
if data: | ||
decoded_data = data.decode(errors='ignore').strip() | ||
if decoded_data == "CONNECT_TCP": | ||
print("Connect to TCP server") | ||
serial_connection.write(b"TCP_CONNECTED\n") | ||
elif decoded_data.startswith("LOGIN:"): | ||
login_data = decoded_data.replace("LOGIN:", "").split(":", 2) | ||
# hides the key from the console | ||
login_data[2] = login_data[2][:4] + ("*" * 50) + login_data[2][-4:] | ||
username = login_data[1] | ||
print(f"Login data: {login_data}") | ||
serial_connection.write(b"LOGIN_SUCCESS\n") | ||
elif decoded_data == "BRIDGE_PING": | ||
serial_connection.write(b"BRIDGE_PONG\n") | ||
elif decoded_data.startswith("RTC_CHAT:"): | ||
chat_data = decoded_data.replace("RTC_CHAT:", "").split(":", 1) | ||
print(f"Chat data: {chat_data}") | ||
recipient, message = chat_data | ||
chat_broadcast_str = f"RTC_CHAT:{recipient}:{math.floor(time.time())}:{username}:{message}" | ||
serial_connection.write(chat_broadcast_str.encode()) | ||
time.sleep(2) | ||
serial_connection.write(b"RTC_CHAT:global:0:testuser:long message that should be parsed entirely..") | ||
else: | ||
print(decoded_data) |
Oops, something went wrong.