Forked from Core0verload/gist:b7b18d45343557c79e80fe5de8d3ba86
Created
April 3, 2016 20:39
-
-
Save optimumtact/ebd703c4ac7a5a5c5f266b4f6ccbf06f to your computer and use it in GitHub Desktop.
Export to BYOND world.Topic() from Python
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
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