Skip to content

Instantly share code, notes, and snippets.

@thorsummoner

thorsummoner/mcad

Created Apr 22, 2018
Embed
What would you like to do?
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