Esempio n. 1
0
def do_command(command, target, source_user, conn_obj, connection,
               to_me=False):
    cmds = CmdsProvider.get_plugins()
    data = {'source_user': source_user,
            'target': target,
            'cmd': command.lower()
            }

    for cmd in cmds:
        # allow a plugin to play with the data before commands are
        # actually processed
        command, data = cmd.pre_process(command, conn_obj, data)
    torun = None
    for cmd in cmds:
        try:
            f, data = cmd.match_command(command, conn_obj, data)
            if torun is None:
                torun = f
        except Exception:
            logging.error(traceback.format_exc())

    # only run the one function if spoken to
    responses = torun(command, data) if to_me and torun is not None else []
    for i, resp in enumerate(responses):
        sleep(0.1 * i)
        connection.privmsg(target, resp)
Esempio n. 2
0
def do_command(command, target, source_user, conn_obj, connection,
               to_me=False):
    cmds = CmdsProvider.get_plugins()
    data = {'source_user': source_user,
            'target': target,
            'cmd': command.lower(),
            'to_me': to_me
            }

    for cmd in cmds:
        # allow a plugin to play with the data before commands are
        # actually processed
        command, data = cmd.pre_process(command, conn_obj, data)
    torun = None
    for cmd in cmds:
        try:
            f, c, data = cmd.match_command(command, conn_obj, data)
        except Exception:
            logging.error(traceback.format_exc())
        else:
            respond_to_public = getattr(cmd, "respond_to_public", False)

            # will only run function if spoken to or respond_to_public is True
            if (torun is None) and (to_me or respond_to_public):
                torun, thecmd = f, c

    responses = torun(thecmd, data) if torun is not None else []
    for i, resp in enumerate(responses):
        sleep(0.1 * i)
        connection.privmsg(target, resp)
Esempio n. 3
0
def do_command(command,
               target,
               source_user,
               conn_obj,
               connection,
               to_me=False):
    cmds = CmdsProvider.get_plugins()
    data = {
        'source_user': source_user,
        'target': target,
        'cmd': command.lower()
    }

    for cmd in cmds:
        # allow a plugin to play with the data before commands are
        # actually processed
        command, data = cmd.pre_process(command, conn_obj, data)
    torun = None
    for cmd in cmds:
        try:
            f, data = cmd.match_command(command, conn_obj, data)
        except Exception:
            logging.error(traceback.format_exc())
        else:
            respond_to_public = getattr(cmd, "respond_to_public", False)

            # will only run function if spoken to or respond_to_public is True
            if (torun is None) and (to_me or respond_to_public):
                torun = f

    responses = torun(command, data) if torun is not None else []
    for i, resp in enumerate(responses):
        sleep(0.1 * i)
        connection.privmsg(target, resp)
 def _get_cmd_dict(self):
     result = {}
     for p in CmdsProvider.get_plugins():
         result.update(p.cmds)
     return result
 def _get_cmd_list(self):
     return sorted(
         list(
             chain.from_iterable(
                 [c.list_commands() for c in CmdsProvider.get_plugins()])))
Esempio n. 6
0
 def _get_cmd_dict(self):
     result = {}
     for p in CmdsProvider.get_plugins():
         result.update(p.cmds)
     return result
Esempio n. 7
0
 def _get_cmd_list(self):
     return sorted(list(chain.from_iterable(
         [c.list_commands() for c in CmdsProvider.get_plugins()])))