21 lines
623 B
Python
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 |