Handles quotes.
    Syntax: {command} <number|nick>, !quote --add <quote> --nick <nick> (--approve), !quote --list, !quote --delete <number>, !quote --edit <number> <quote> --nick <nick>
    !quote --search (--offset <num>) <number>
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))
840029
function doQuotes(route, args, count) {
    var bot = this,
        username = args.shift(),
        user;

    count = count || 1;

    function getQuote (err, quotes) {
        if (quotes.length) {
            var quote, output = [];
            for (var i = 0; i < quotes.length; i++) {
                quote = quotes[i];
                output.push(quote.nick + ': ' + quote.text);
            }
            route.indirect().send(output.join('\n'));
        } else {
            var name = 'anyone';
            if (user) {
                name = user.nick;
            }
            route.send('?quotes_nobody_said_that', name);
        }
    }

    if (username !== 'anyone') {
        user = bot.users.getUserMatch(username);

        if (!user) {
            user = bot.db.schemas.quote.getQuoteNick(username, function (err, user) {
                if (!user) {
                    args.unshift(username);
                    bot.db.schemas.quote.random(args.join(' '), null, count, getQuote);
                } else {
                    bot.db.schemas.quote.random(args.join(' '), username, count, getQuote);
                }
            });
        } else {
            bot.db.schemas.quote.random(args.join(' '), user.nick, count, getQuote);
        }
    } else {
        bot.db.schemas.quote.random(args.join(' '), null, count, getQuote);
    }
}
158704
def add_command_meta(name, command, is_alias=false) #:nodoc:
      syntax = command[:syntax]

      @commands[:meta][name] = {
        :syntax      => syntax.is_a?(Array) ? syntax : [syntax],
        :description => command[:description],
        :is_public   => command[:is_public] || false,
        :is_alias    => is_alias
      }
    end
456218
def _remove_quotes(word):
    
    if not word or len(word) <= 2:
        return word

    if word[0] == word[-1] and word[0] in ["'", '"']:
        return word[1:-1]

    return word
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)
1133021
def handle_command_event(self, event, command, args):
        
        argspec = getargspec(command)
        num_all_args = len(argspec.args) - 2  # Ignore self/event args
        num_pos_args = num_all_args - len(argspec.defaults or [])
        if num_pos_args <= len(args) <= num_all_args:
            response = command(self, event, *args)
        elif num_all_args == num_pos_args:
            s = "s are" if num_all_args != 1 else " is"
            response = "%s arg%s required" % (num_all_args, s)
        else:
            bits = (num_pos_args, num_all_args)
            response = "between %s and %s args are required" % bits
        response = "%s: %s" % (self.get_nickname(event), response)
        self.message_channel(response)
355221
private void execCommand(String command,List args) 
		throws NoSuchMethodException,IllegalAccessException,InvocationTargetException
	{
		Class[] template = new Class[ args.size() ];
		for (int i=0; i<args.size(); i++) {
			template[i] = String.class;
		}
		Method m = MatchExptScript.class.getMethod(command, template );
		m.invoke(this, args.toArray(new String[0]));
	}
779790
function adjustCommandArgument(argObj) {
  if (typeof argObj === "number") {
    return argObj.toString()
  } else if (typeof argObj === "string") {
    return argObj
  } else if (!argObj) {
    return ""
  } else {
    throw new RedisCommandError(`Argument: ${inspect(argObj)}`)
  }
}
1177819
def quote(bot, mask, target, args):
    
    msg = ' '.join(args['<args>'])
    bot.log.info('quote> %r', msg)
    bot.send(msg)
1008774
def cmd(send, msg, args):
    
    if not msg or len(msg.split()) < 2:
        send("Pester needs at least two arguments.")
        return
    match = re.match('(%s+) (.*)' % args['config']['core']['nickregex'], msg)
    if match:
        message = match.group(2) + " "
        send('%s: %s' % (match.group(1), message * 3))
    else:
        send("Invalid Syntax.")
359586
def quote(myitem, elt=True):
    ''''''
    if elt and '<' in myitem and len(myitem) > 24 and myitem.find(']]>') == -1:
        return '<![CDATA[%s]]>' % (myitem)
    else:
        myitem = myitem.replace('&', '&amp;').\
            replace('<', '&lt;').replace(']]>', ']]&gt;')
    if not elt:
        myitem = myitem.replace('"', '&quot;')
    return myitem
1329940
def handle_command_def(self, line):
        """"""
        cmd, arg, line = self.parseline(line)
        if not cmd:
            return
        if cmd == 'silent':
            self.commands_silent[self.commands_bnum] = True
            return # continue to handle other cmd def in the cmd list
        elif cmd == 'end':
            self.cmdqueue = []
            return 1 # end of cmd list
        cmdlist = self.commands[self.commands_bnum]
        if arg:
            cmdlist.append(cmd+' '+arg)
        else:
            cmdlist.append(cmd)
        # Determine if we must stop
        try:
            func = getattr(self, 'do_' + cmd)
        except AttributeError:
            func = self.default
        # one of the resuming commands
        if func.__name__ in self.commands_resuming:
            self.commands_doprompt[self.commands_bnum] = False
            self.cmdqueue = []
            return 1
        return
1065208
def set_command_execute(editor, variables):
    
    option = variables.get('set_option')
    value = variables.get('set_value')

    if option in SET_COMMANDS:
        # Call the correct handler.
        if option in SET_COMMANDS_TAKING_VALUE:
            SET_COMMANDS[option](editor, value)
        else:
            SET_COMMANDS[option](editor)
    else:
        editor.show_message('Unknown option: %s' % option)
381319
def _autoinsert_quotes(self, key):
        """"""
        char = {Qt.Key_QuoteDbl: '"', Qt.Key_Apostrophe: '\''}[key]

        line_text = self.editor.get_text('sol', 'eol')
        line_to_cursor = self.editor.get_text('sol', 'cursor')
        cursor = self.editor.textCursor()
        last_three = self.editor.get_text('sol', 'cursor')[-3:]
        last_two = self.editor.get_text('sol', 'cursor')[-2:]
        trailing_text = self.editor.get_text('cursor', 'eol').strip()

        if self.editor.has_selected_text():
            text = self.editor.get_selected_text()
            self.editor.insert_text("{0}{1}{0}".format(char, text))
            # keep text selected, for inserting multiple quotes
            cursor.movePosition(QTextCursor.Left, QTextCursor.MoveAnchor, 1)
            cursor.movePosition(QTextCursor.Left, QTextCursor.KeepAnchor,
                                len(text))
            self.editor.setTextCursor(cursor)
        elif self.editor.in_comment():
            self.editor.insert_text(char)
        elif (len(trailing_text) > 0 and
                not unmatched_quotes_in_line(line_to_cursor) == char and
                not trailing_text[0] in (',', ':', ';', ')', ']', '}')):
            self.editor.insert_text(char)
        elif (unmatched_quotes_in_line(line_text) and
                (not last_three == 3*char)):
            self.editor.insert_text(char)
        # Move to the right if we are before a quote
        elif self.editor.next_char() == char:
            cursor.movePosition(QTextCursor.NextCharacter,
                                QTextCursor.KeepAnchor, 1)
            cursor.clearSelection()
            self.editor.setTextCursor(cursor)
        # Automatic insertion of triple double quotes (for docstrings)
        elif last_three == 3*char:
            self.editor.insert_text(3*char)
            cursor = self.editor.textCursor()
            cursor.movePosition(QTextCursor.PreviousCharacter,
                                QTextCursor.KeepAnchor, 3)
            cursor.clearSelection()
            self.editor.setTextCursor(cursor)
        # If last two chars are quotes, just insert one more because most
        # probably the user wants to write a docstring
        elif last_two == 2*char:
            self.editor.insert_text(char)
            self.editor.delayed_popup_docstring()
        # Automatic insertion of quotes
        else:
            self.editor.insert_text(2*char)
            cursor = self.editor.textCursor()
            cursor.movePosition(QTextCursor.PreviousCharacter)
            self.editor.setTextCursor(cursor)
756277
def handle_command(command):
  
  try:
    cmds = command.split(None, 1)
    cmd = cmds[0]
    if cmd == 'new':
      add_task(get_arg(cmds))
    elif cmd == 'done':
      mark_done(int(get_arg(cmds)))
    elif cmd == 'list':
      for task in format_tasks(list_tasks()):
        print task
    elif cmd == 'delete':
      delete_task(int(get_arg(cmds)))
    else:
      print_usage()
  except Exception, e:  # pylint: disable=broad-except
    print e
    print_usage()
454654
def cmd(send, msg, args):
    
    if not msg:
        send("Invalid Syntax.")
        return
    char = msg[0]
    msg = [x.replace(r'\/', '/') for x in re.split(r'(?<!\\)\%s' % char, msg[1:], maxsplit=2)]
    # fix for people who forget a trailing slash
    if len(msg) == 2 and args['config']['feature'].getboolean('lazyregex'):
        msg.append('')
    # not a valid sed statement.
    if not msg or len(msg) < 3:
        send("Invalid Syntax.")
        return
    if args['type'] == 'privmsg':
        send("Don't worry, %s is not a grammar Nazi." % args['botnick'])
        return
    string = msg[0]
    replacement = msg[1]
    modifiers = get_modifiers(msg[2], args['nick'], args['config']['core']['nickregex'])
    if modifiers is None:
        send("Invalid modifiers.")
        return

    try:
        regex = re.compile(string, re.IGNORECASE) if modifiers['ignorecase'] else re.compile(string)
        log = get_log(args['db'], args['target'], modifiers['nick'])
        workers = args['handler'].workers
        result = workers.run_pool(do_replace, [log, args['config']['core'], char, regex, replacement])
        try:
            msg = result.get(5)
        except multiprocessing.TimeoutError:
            workers.restart_pool()
            send("Sed regex timed out.")
            return
        if msg:
            send(msg)
        else:
            send("No match found.")
    except sre_constants.error as ex:
        raise CommandFailedException(ex)
1027930
function ForCommand(value, engine) {
        var rule = new RegExp(
            stringFormat(
                /* jshint ignore:start */
                '^\\s*({0}[\\s\\S]+{1})\\s+as\\s+{0}([0-9a-z_]+){1}\\s*(,\\s*{0}([0-9a-z_]+){1})?\\s*$',
                /* jshint ignore:end */
                regexpLiteral(engine.options.variableOpen),
                regexpLiteral(engine.options.variableClose)
            ),
            'i'
        );


        var match = value.match(rule);
        if (!match) {
            throw new Error('Invalid ' + this.type + ' syntax: ' + value);
        }

        this.list = match[1];
        this.item = match[2];
        this.index = match[4];
        Command.call(this, value, engine);
        this.cloneProps = ['list', 'item', 'index'];
    }