Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Core0verload/b7b18d45343557c79e80fe5de8d3ba86 to your computer and use it in GitHub Desktop.
Save Core0verload/b7b18d45343557c79e80fe5de8d3ba86 to your computer and use it in GitHub Desktop.
Export to BYOND world.Topic() from Python
import socket
import struct
import urllib.parse
def byond_export(host, port, string):
packet_id = b'\x83'
try:
sock = socket.create_connection((host, port))
except socket.error:
return
packet = struct.pack('>xcH5x', packet_id, len(string)+6) + bytes(string, encoding='ascii') + b'\x00'
sock.send(packet)
data = sock.recv(512)
sock.close()
data = str(data[5:-1], encoding='ascii')
return data
d = byond_export('localhost', '1337', '?status')
d = urllib.parse.parse_qs(d, keep_blank_values=True)
print(d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment