コード例 #1
0
def clientConnect(client, username):
	"""Occurs when the client is ready to start sending data."""
	#print "Client connected."
	renameuser(localhandle(), username)
	_closeAllMaps()
	setUwidgetLocal()
	say(translate('remote', "Welcome, {name}!").format(name=username))
	client.preemptivelyOpenTransferSocket()
コード例 #2
0
def emote(message):
    if not message:
        say(
            translate(
                'chat', "Syntax: /me DOES ACTION. Displays '[HANDLE] DOES "
                "ACTION' in italic font."))
    else:
        sendEmote(message)
コード例 #3
0
def randomname(message):
    if len(message) <= 0:
        say(
            translate(
                'chat',
                "Syntax: /generate NAMETYPE. For a list of available generators, see /generate keys. Use /generate help NAMETYPE for more information on a generator."
            ))
    else:
        generateName(*splitword(message.lower()))
コード例 #4
0
def clientDisconnect(client, errorMessage):
	"""Occurs when the client connection disconnects without being told to.

	errorMessage -- a human-readable error message for why the connection failed

	"""
	#print "Client disconnected."
	say(translate('remote', "Disconnected. {0}").format(errorMessage))
	clearUserList()
コード例 #5
0
def respondError(message, *args, **kwargs):
	"""Responds as an error message.

	message -- the error message to send
		should be fake translated so it is
		done on the client instead of the server.

	Extra arguments are passed to format the translated string.

	"""
	say(translate('error', message).format(*args, **kwargs))
コード例 #6
0
def whisper(message):
    if not message:
        say(
            translate(
                'chat', "Syntax: /whisper HANDLE MESSAGE. Sends a message "
                "only to the specified user. Spaces MUST be correct."
                " Handle may be caps-sensitive."))
    else:
        target, rest = splitword(message)
        if target.lower() == localuser().username:
            emote(translate('chat', "mutters something."))
        elif not rest:
            say(
                translate('chat', "What do you want to tell {target}?").format(
                    target=target))
        else:
            sendWhisper(target, rest)
コード例 #7
0
def chat(st):
    """Parses and executes chat commands."""
    st = UNICODE_STRING(st)

    if (len(st) <= 0):
        return
    if ('<' in st and '>' not in st) or ('<' in st and '>' in st
                                         and '<' in st[st.rfind('>'):]):
        say(
            translate(
                'chat',
                "Please type &#60; if you wish to include < in your message."))
        return

    if st[0] != '/' or len(st) > 1 and st[1] == '/':
        if len(st) > 1 and st[1] == '/':
            st = st[1:]
        command = 'say'
        message = st.strip()
    else:
        command, message = splitword(st[1:])
        command = UNICODE_STRING(command).lower()
    #print command, message

    if command in chatCommands:
        chatCommands[command](message)
    else:
        if command not in ('help', '?'):
            say(
                translate('chatdoc', "Invalid command.",
                          'Unknown chat command name.'))
        elif message in chatCommands:
            say(translate('chatdoc', chatCommands[message].documentation))
            return
        say(
            translate(
                'chatdoc', "Command Help:<br>"
                "Typing ordinary text and pressing 'enter' "
                "will display to all players. Other commands may be invoked "
                "with '/' plus the name of the command plus any arguments."
                "<dl><dt>Commands</dt><dd>{commandList}</dd></dl><br>").format(
                    commandList=translate(
                        'chatdoc', '</dd><dd>',
                        'Goes inbetween the commands in the commandList.').
                    join(chatCommandNames)))
コード例 #8
0
def dreams(message):
    dr = getDreams()
    for user, amount in dr.items():
        say("%s: %s" % (user, BASE_STRING(amount)))
コード例 #9
0
def respondEmote(username, message):
	say(translate('remote', '<i>{name} {emote}</i>').format(
		name=linkedName(username),
		emote=message))
コード例 #10
0
def respondSay(username, message):
	say(translate('remote', '{name}: {sayText}').format(
		name=linkedName(username),
		sayText=message))
コード例 #11
0
def respondDice(username, message):
	say(translate('remote', '{sayText}').format(
		sayText=message))
	ICSay(translate('remote', '{sayText}').format(
		sayText=message))
コード例 #12
0
def disconnectionMessage(message, error, *args, **kwargs):
	"""Special translation for a disconnection message."""
	#print "Server dropped user."
	error = translate('socket', error)
	say(translate('error', message).format(*args, error=disconnect, **kwargs))
コード例 #13
0
def respondUserJoin(username):
	say(translate('remote', "{name} has joined!").format(name=username))
	addUserToList(username)
コード例 #14
0
def respondWhisperTarget(sender, message):
	say(translate('remote', '{username} whispers: {message}').format(
		username=linkedName(sender),
		message=message))
コード例 #15
0
def respondWhisperSender(target, message):
	say(translate('remote', 'To {username}: {message}').format(
		username=linkedName(target),
		message=message))