コード例 #1
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)))
コード例 #2
0
 def rollDice(self):
     current = self.diceArea.item(self.currentMacro)
     if current is not None:
         text = UNICODE_STRING(current.text())
         self.rollRequested.emit(text[text.rfind(':') + 1:])