Beispiel #1
0
black_list = ["recv23", "recv21", "recv1F", "recv1C", "recv20", "recv28"]


def t(*args, **kwargs):
    pid = args[0]

    if not pid in black_list:
        print pid, kwargs

HOST = "localhost"
PORT = 25565
try:
    with open(".credentials") as f:
        USERNAME, PASSWORD = f.read().split("\n")[:2]
except IOError:
    USERNAME = raw_input("Username: ")
    PASSWORD = getpass()

connection = SimpleClient()
connection.eventmanager.got_event.add_handler(t)
connection.connect(HOST, PORT, USERNAME, PASSWORD)

try:
    while True:
        # This is only needed because connection is in a seperate thread
        time.sleep(999)

except KeyboardInterrupt:
    connection.disconnect()
Beispiel #2
0
# Function in standard python to get passwords the unixy way

username = raw_input("Username: "******"Server (IP): ")
port = int(raw_input("Server (Port): "))  # Remember to turn to integer


class Events(object):
    @staticmethod
    def recv_chat_message(message):
        message = fix_message(message)  # Fix escapes, colors, etc
        print "CHAT: %s" % message

    @staticmethod
    def recv_client_disconnect(reason):
        print "We got kicked: %s" % reason

client = SimpleClient()
client.eventmanager.apply(Events())
client.connect(host, port, username, password)
# Server connection.

raw_input()  # Since connection runs in a seperate thread, we can't just CTRL-C
client.disconnect()  # We can call the wrapper function, disconnect, to nicely
# disconnect, it also has a force KWarg

# For a better chat client, see: https://github.com/dkkline/pyCraft
Beispiel #3
0
    if not pid in black_list:
        print pid, kwargs


if len(sys.argv) == 1:  # Interactive mode
    HOST = raw_input("HOST: ") or "localhost"
    PORT = int(raw_input("PORT: ") or 25565)

else:
    HOST = sys.argv[1]
    PORT = int(sys.argv[2])

try:
    with open(".credentials") as f:
        USERNAME, PASSWORD = f.read().split("\n")[:2]
except IOError:
    USERNAME = raw_input("Username: ")
    PASSWORD = getpass()

connection = SimpleClient()
connection.eventmanager.got_event.add_handler(t)
connection.connect(HOST, PORT, USERNAME, PASSWORD)

try:
    while True:
        # This is only needed because connection is in a seperate thread
        time.sleep(999)

except KeyboardInterrupt:
    connection.disconnect()