Converts a message to/from dvorak.

    Syntax: {command} <--nick <nick>|msg>
9521
def cmd(send, msg, args):
    
    parser = arguments.ArgParser(args['config'])
    parser.add_argument('--nick', action=arguments.NickParser)
    parser.add_argument('msg', nargs='*')
    try:
        cmdargs = parser.parse_args(msg)
    except arguments.ArgumentException as e:
        send(str(e))
        return
    if cmdargs.msg:
        if cmdargs.nick:
            send('--nick cannot be combined with a message')
        else:
            send(translate(" ".join(cmdargs.msg), False).strip())
    else:
        log = get_log(args['db'], cmdargs.nick, args['target'])
        if not log:
            send("Couldn't find a message from %s :(" % cmdargs.nick)
        else:
            send(translate(log))
357776
def messageReceived(self, value, sender, target):
        
        if value.type != AMP_MESSAGE_TYPE:
            raise UnknownMessageType()
        inputBox = self._boxFromData(value.data)
        thunk = commandMethod.responderForName(self, inputBox[COMMAND])
        placeholder = _ProtocolPlaceholder(sender, target)
        arguments = thunk.command.parseArguments(inputBox, placeholder)
        try:
            result = thunk(**arguments)
        except tuple(thunk.command.errors.keys()), knownError:
            errorCode = thunk.command.errors[knownError.__class__]
            raise RevertAndRespond(
                Value(AMP_ANSWER_TYPE,
                         Box(_error_code=errorCode,
                             _error_description=str(knownError)).serialize()))
        else:
            response = thunk.command.makeResponse(result, None)
            return Value(AMP_ANSWER_TYPE, response.serialize())
205969
def cmd(send, msg, args):
    
    parser = arguments.ArgParser(args['config'])
    parser.add_argument('channel', nargs='+', action=arguments.ChanParser)
    try:
        cmdargs = parser.parse_args(msg)
    except arguments.ArgumentException as e:
        send(str(e))
        return
    for chan in cmdargs.channels:
        args['handler'].do_part(chan, args['nick'], args['target'], args['type'], send, args['handler'].connection)
733403
def cmd(send, msg, args):
    
    implements = ['the golden gate bridge', 'a large trout', 'a clue-by-four', 'a fresh haddock', 'moon', 'an Itanium', 'fwilson', 'a wombat']
    methods = ['around a bit', 'upside the head']
    if not msg:
        channel = args['target'] if args['target'] != 'private' else args['config']['core']['channel']
        with args['handler'].data_lock:
            users = list(args['handler'].channels[channel].users())
        slap = 'slaps %s %s with %s'
        send(slap % (choice(users), choice(methods), choice(implements)), 'action')
    else:
        reason = ''
        method = choice(methods)
        implement = ''
        msg = msg.split()
        slapee = msg[0]
        # Basic and stupid NLP!
        i = 1
        args = False
        while i < len(msg):
            if msg[i] == 'for':
                args = True
                if reason:
                    send("Invalid Syntax: You can only have one for clause!")
                    return
                i += 1
                while i < len(msg):
                    if msg[i] == 'with':
                        break
                    reason += " "
                    reason += msg[i]
                    i += 1
                reason = reason.strip()
            elif msg[i] == 'with':
                args = True
                if implement:
                    send("Invalid Synatx: You can only have one with clause!")
                    return
                i += 1
                while i < len(msg):
                    if msg[i] == 'for':
                        break
                    implement += msg[i]
                    implement += ' '
                    i += 1
                implement = implement.strip()
            elif not args:
                slapee += ' ' + msg[i]
            i += 1

        if not implement:
            implement = choice(implements)
        if reason:
            slap = 'slaps %s %s with %s for %s' % (slapee, method, implement, reason)
        else:
            slap = 'slaps %s %s with %s' % (slapee, method, implement)
        send(slap, 'action')
416107
function convertShortcut(shortcut) {
          var i, value, replace = {};

          if (Env.mac) {
            replace = {
              alt: '&#x2325;',
              ctrl: '&#x2318;',
              shift: '&#x21E7;',
              meta: '&#x2318;'
            };
          } else {
            replace = {
              meta: 'Ctrl'
            };
          }

          shortcut = shortcut.split('+');

          for (i = 0; i < shortcut.length; i++) {
            value = replace[shortcut[i].toLowerCase()];

            if (value) {
              shortcut[i] = value;
            }
          }

          return shortcut.join('+');
        }
1226092
def cmd(send, msg, args):
    
    if args['type'] == 'privmsg':
        send('Filters must be set in channels, not via private message.')
        return
    isadmin = args['is_admin'](args['nick'])
    parser = arguments.ArgParser(args['config'])
    parser.add_argument('--channel', nargs='?', default=args['target'])
    group = parser.add_mutually_exclusive_group()
    group.add_argument('filter', nargs='?')
    group.add_argument('--show', action='store_true')
    group.add_argument('--list', action='store_true')
    group.add_argument('--reset', '--clear', action='store_true')
    group.add_argument('--chain')
    if not msg:
        send(get_filters(args['handler'], args['target']))
        return
    try:
        cmdargs = parser.parse_args(msg)
    except arguments.ArgumentException as e:
        send(str(e))
        return
    if cmdargs.list:
        send("Available filters are %s" % ", ".join(textutils.output_filters.keys()))
    elif cmdargs.reset and isadmin:
        args['handler'].outputfilter[cmdargs.channel].clear()
        send("Okay!")
    elif cmdargs.chain and isadmin:
        if not args['handler'].outputfilter[cmdargs.channel]:
            send("Must have a filter set in order to chain.")
            return
        filter_list, output = textutils.append_filters(cmdargs.chain)
        if filter_list is not None:
            args['handler'].outputfilter[cmdargs.channel].extend(filter_list)
        send(output)
    elif cmdargs.show:
        send(get_filters(args['handler'], cmdargs.channel))
    elif isadmin:
        # If we're just adding a filter without chain, blow away any existing filters.
        filter_list, output = textutils.append_filters(cmdargs.filter)
        if filter_list is not None:
            args['handler'].outputfilter[cmdargs.channel].clear()
            args['handler'].outputfilter[cmdargs.channel].extend(filter_list)
        send(output)
    else:
        send('This command requires admin privileges.')
541776
def cmd(send, msg, args):
    
    session = args['db']
    parser = arguments.ArgParser(args['config'])
    parser.add_argument('--approve', action='store_true')
    parser.add_argument('--nick', nargs='?')
    parser.add_argument('--offset', nargs='?', type=int, default=0)
    parser.add_argument('quote', nargs='*')
    group = parser.add_mutually_exclusive_group()
    group.add_argument('--list', action='store_true')
    group.add_argument('--add', action='store_true')
    group.add_argument('--delete', '--remove', type=int)
    group.add_argument('--edit', type=int)
    group.add_argument('--search', nargs='*')

    if not msg:
        send(do_get_quote(session))
        return

    try:
        cmdargs = parser.parse_args(msg)
    except arguments.ArgumentException as e:
        send(str(e))
        return

    if cmdargs.add:
        if args['type'] == 'privmsg':
            send("You want everybody to know about your witty sayings, right?")
        else:
            if cmdargs.nick is None:
                send('You must specify a nick.')
            elif not cmdargs.quote:
                send('You must specify a quote.')
            else:
                isadmin = args['is_admin'](args['nick']) or not args['config']['feature']['quoteapprove']
                approved = cmdargs.approve or not args['config']['feature']['quoteapprove']
                do_add_quote(cmdargs.nick, " ".join(cmdargs.quote), session, isadmin, approved, send, args)
    elif cmdargs.list:
        send(do_list_quotes(session, args['config']['core']['url']))
    elif cmdargs.delete:
        send(do_delete_quote(args, session, cmdargs.delete))
    elif cmdargs.edit:
        if args['is_admin'](args['nick']):
            send(do_update_quote(session, cmdargs.edit, cmdargs.nick, cmdargs.quote))
        else:
            send("You aren't allowed to edit quotes. Please ask a bot admin to do it")
    elif cmdargs.search:
        if cmdargs.approve or cmdargs.nick:
            send("Invalid option for --search")
        else:
            send(search_quote(session, cmdargs.offset, cmdargs.search))
    else:
        if msg.isdigit():
            send(do_get_quote(session, int(msg)))
        else:
            if not re.match(args['config']['core']['nickregex'], msg):
                send('Invalid nick %s.' % msg)
            else:
                send(get_quotes_nick(session, msg))
225386
def format_npm_command_for_logging(command):
    """"""
    if platform.system().lower() == 'windows':
        if command[0] == 'npx.cmd' and command[1] == '-c':
            return "npx.cmd -c \"%s\"" % " ".join(command[2:])
        return " ".join(command)
    # Strip out redundant npx quotes not needed when executing the command
    # directly
    return " ".join(command).replace('\'\'', '\'')
1061831
def cmd(send, msg, args):
    
    command = msg.split()
    msg = " ".join(command[1:])
    if not command:
        send("Which poll?")
        return
    else:
        command = command[0]
    # FIXME: integrate this with ArgParser
    if command.isdigit():
        if args['type'] == 'privmsg':
            send("We don't have secret ballots in this benevolent dictatorship!")
        else:
            send(vote(args['db'], args['nick'], int(command), msg))
        return
    isadmin = args['is_admin'](args['nick'])
    parser = arguments.ArgParser(args['config'])
    parser.set_defaults(session=args['db'], msg=msg, nick=args['nick'])
    subparser = parser.add_subparsers()
    start_parser = subparser.add_parser('start', config=args['config'], aliases=['open', 'add', 'create'])
    start_parser.set_defaults(func=start_poll, send=send, isadmin=isadmin, type=args['type'])
    tally_parser = subparser.add_parser('tally')
    tally_parser.set_defaults(func=tally_poll, send=send)
    list_parser = subparser.add_parser('list', config=args['config'])
    list_parser.set_defaults(func=list_polls)
    retract_parser = subparser.add_parser('retract')
    retract_parser.set_defaults(func=retract)
    end_parser = subparser.add_parser('end', aliases=['close'])
    end_parser.set_defaults(func=end_poll, isadmin=isadmin)
    delete_parser = subparser.add_parser('delete')
    delete_parser.set_defaults(func=delete_poll, isadmin=isadmin)
    edit_parser = subparser.add_parser('edit')
    edit_parser.set_defaults(func=edit_poll, isadmin=isadmin)
    reopen_parser = subparser.add_parser('reopen')
    reopen_parser.set_defaults(func=reopen, isadmin=isadmin)
    try:
        cmdargs = parser.parse_args(command)
    except arguments.ArgumentException as e:
        send(str(e))
        return
    send(cmdargs.func(cmdargs))
1050521
def _ConvertAnyMessage(self, value, message):
    """"""
    if isinstance(value, dict) and not value:
      return
    try:
      type_url = value['@type']
    except KeyError:
      raise ParseError('@type is missing when parsing any message.')

    sub_message = _CreateMessageFromTypeUrl(type_url)
    message_descriptor = sub_message.DESCRIPTOR
    full_name = message_descriptor.full_name
    if _IsWrapperMessage(message_descriptor):
      self._ConvertWrapperMessage(value['value'], sub_message)
    elif full_name in _WKTJSONMETHODS:
      methodcaller(
          _WKTJSONMETHODS[full_name][1], value['value'], sub_message)(self)
    else:
      del value['@type']
      self._ConvertFieldValuePair(value, sub_message)
    # Sets Any message
    message.value = sub_message.SerializeToString()
    message.type_url = type_url
219246
String formatMessage(int msgLogLevel, String module, String msg) {
        return getLevelTag(msgLogLevel) + module + ": " + msg;
    }
16793
def cmd(send, msg, args):
    
    parser = arguments.ArgParser(args['config'])
    parser.add_argument('stock', nargs='?', default=random_stock())
    try:
        cmdargs = parser.parse_args(msg)
    except arguments.ArgumentException as e:
        send(str(e))
        return
    send(gen_stock(cmdargs.stock))
638911
def cmd(send, msg, args):
    
    key = args['config']['api']['bitlykey']
    parser = arguments.ArgParser(args['config'])
    parser.add_argument('--blacklist')
    parser.add_argument('--unblacklist')

    try:
        cmdargs, msg = parser.parse_known_args(msg)
        msg = ' '.join(msg)
    except arguments.ArgumentException as e:
        send(str(e))
        return
    if cmdargs.blacklist:
        if args['is_admin'](args['nick']):
            send(blacklist_word(args['db'], cmdargs.blacklist))
        else:
            send("Blacklisting is admin-only")
    elif cmdargs.unblacklist:
        if args['is_admin'](args['nick']):
            send(unblacklist_word(args['db'], cmdargs.unblacklist))
        else:
            send("Unblacklisting is admin-only")
    else:
        defn, url = get_urban(msg, args['db'], key)
        send(defn)
        if url:
            send("See full definition at %s" % url)
1060580
function formatMessage(msg) {
		var args = arguments;
		return msg.replace(/\$\{([^\}]+)\}/g, function(str, index) { return args[(index << 0) + 1]; });
	}
1106815
def command_msg(housecode, command):
        """"""
        house_byte = 0
        if isinstance(housecode, str):
            house_byte = insteonplm.utils.housecode_to_byte(housecode) << 4
        elif isinstance(housecode, int) and housecode < 16:
            house_byte = housecode << 4
        else:
            house_byte = housecode
        return X10Received(house_byte + command, 0x80)
610195
def cmd(send, msg, args):
    
    parser = arguments.ArgParser(args['config'])
    parser.add_argument('speaker', nargs='?', default=args['config']['core']['channel'])
    parser.add_argument('--length', type=int, choices=[1, 2], default=2)
    parser.add_argument('--start', nargs='*')
    try:
        cmdargs = parser.parse_args(msg)
    except arguments.ArgumentException as e:
        send(str(e))
        return
    if args['db'].query(Babble).count():
        send(build_msg(args['db'], cmdargs.speaker, cmdargs.length, cmdargs.start))
    else:
        send("Please run ./scripts/gen_babble.py to initialize the babble cache")
615011
def cmd(send, msg, args):
    
    parser = arguments.ArgParser(args['config'])
    parser.add_argument('channel', action=arguments.ChanParser)
    parser.add_argument('message', nargs='+')
    try:
        cmdargs = parser.parse_args(msg)
    except arguments.ArgumentException as e:
        send(str(e))
        return
    cmdargs.message = ' '.join(cmdargs.message)
    send(cmdargs.message, target=cmdargs.channels[0])
    send("%s sent message %s to %s" % (args['nick'], cmdargs.message, cmdargs.channels[0]), target=args['config']['core']['ctrlchan'])