Skip to content

Instantly share code, notes, and snippets.

@thorsummoner
Created April 22, 2018 22:13
Show Gist options
  • Save thorsummoner/f813655849e598de29b977b84255d7cc to your computer and use it in GitHub Desktop.
Save thorsummoner/f813655849e598de29b977b84255d7cc to your computer and use it in GitHub Desktop.
Minecraft Server Advertizements
#!/usr/bin/env python3
import time
import socket
servers = [
["MOTD", 25565],
]
BROADCAST_IP = "255.255.255.255"
BROADCAST_PORT = 4445
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
while 1:
for server in servers:
msg = "[MOTD]%s[/MOTD][AD]%d[/AD]" % (server[0], server[1])
sock.sendto(msg.encode('utf-8'), (BROADCAST_IP, BROADCAST_PORT))
time.sleep(1.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment