<commit_before>"""
An example client. Run simpleserv.py first before running this.
"""
from __future__ import unicode_literals

import json

from twisted.internet import reactor, protocol


# a client protocol

class NethackClient(protocol.Protocol):
    """Once connected, send a message, then print the result."""

    def connectionMade(self):
        self.send_message('auth', username='Qalthos', password='password')

    def dataReceived(self, data):
        "As soon as any data is received, write it back."
        print "Server said:", data

    def connectionLost(self, reason):
        print "Connection lost"

    # Nethack Protocol Wrapper
    def send_message(self, command, **kw):
        data = json.dumps({command: kw})
        print "Client says:", data
        self.transport.write(data.encode('utf8'))


class NethackFactory(protocol.ClientFactory):<commit_msg>A few sample commands.<commit_after>"""
An example client. Run simpleserv.py first before running this.
"""
from __future__ import unicode_literals

import json

from twisted.internet import reactor, protocol


# a client protocol

class NethackClient(protocol.Protocol):
    """Once connected, send a message, then print the result."""

    def connectionMade(self):
        running = True
        self.send_message("auth", username="rossdylan", password="<PASSWORD>")
        self.send_message("start_game", alignment=0, gender=0, name="herpderp",
                          race=0, role=0)
        self.send_message("get_roles")
        self.send_message("exit_game", exit_type=2)
        #~ self.transport.loseConnection()

    def dataReceived(self, data):
        "As soon as any data is received, write it back."
        print "Server said:", data

    def connectionLost(self, reason):
        print "Connection lost"

    # Nethack Protocol Wrapper
    def send_message(self, command, **kw):
        data = json.dumps({command: kw})
        print "Client says:", data
        self.transport.write(data.encode('utf8'))


class NethackFactory(protocol.ClientFactory):
{'fraction_non_alphanumeric': 0.11051606621226874, 'fraction_numerical': 0.0034079844206426485, 'mean_word_length': 3.4288793103448274, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3784208', 'n_tokens_mistral': 582, 'n_tokens_neox': 562, 'n_words': 174}