This repository has been archived on 2026-05-21. You can view files and clone it, but cannot push or open issues or pull requests.
TyChat-TUI/protocols/text_protocol.py

21 lines
623 B
Python

class Plugin:
def __init__(self):
self.name = "Raw Text Protocol"
def encode(self, text: str) -> bytes:
return text.encode('utf-8')
def decode(self, data: bytes) -> str:
return data.decode('utf-8')
def generate_service_signal(self, signal_type: str) -> bytes:
return f"SIG:{signal_type}".encode('utf-8')
def detect_service_signal(self, data: bytes) -> str:
try:
decoded = data.decode('utf-8')
if decoded.startswith("SIG:"):
return decoded.split(":", 1)[1]
return None
except:
return None