コード例 #1
0
    def help(self, mask, target, args):
        """Show help

            %%help [<cmd>]
        """
        if args['<cmd>']:
            predicates, meth = self.get(args['<cmd>'], (None, None))
            if meth is not None:
                doc = meth.__doc__ or ''
                doc = [l.strip() for l in doc.split('\n') if l.strip()]
                buf = ''
                for line in doc:
                    if '%%' not in line and buf is not None:
                        buf += line + ' '
                    else:
                        if buf is not None:
                            for b in utils.split_message(buf, 160):
                                yield b
                            buf = None
                        line = line.replace('%%', self.context.config.cmd)
                        yield line
        else:
            cmds = ', '.join([self.cmd + k for k in sorted(self.keys())])
            lines = utils.split_message('Available commands: ' + cmds, 160)
            for line in lines:
                yield line
            url = self.config.get('url')
            if url:
                yield 'Full help is available at ' + url
コード例 #2
0
ファイル: command.py プロジェクト: Mika64/irc3
    def help(self, mask, target, args):
        """Show help

            %%help [<cmd>]
        """
        if args['<cmd>']:
            predicates, meth = self.get(args['<cmd>'], (None, None))
            if meth is not None:
                doc = meth.__doc__ or ''
                doc = [l.strip() for l in doc.split('\n') if l.strip()]
                buf = ''
                for line in doc:
                    if '%%' not in line and buf is not None:
                        buf += line + ' '
                    else:
                        if buf is not None:
                            for b in utils.split_message(buf, 160):
                                yield b
                            buf = None
                        line = line.replace('%%', self.bot.config.cmd)
                        yield line
        else:
            cmds = ', '.join([self.cmd + k for k in sorted(self.keys())])
            lines = utils.split_message('Available commands: ' + cmds, 160)
            for line in lines:
                yield line
            url = self.config.get('url')
            if url:
                yield 'Full help is available at ' + url
コード例 #3
0
    def help(self, mask, target, args):
        """Show help

            %%help [<cmd>]
        """
        if args['<cmd>']:
            args = args['<cmd>']
            # Strip out self.context.config.cmd from args so we can use
            # both !help !foo and !help foo
            if args.startswith(self.context.config.cmd):
                args = args[len(self.context.config.cmd):]
            args = self.aliases.get(args, args)
            predicates, meth = self.get(args, (None, None))
            if meth is not None:
                doc = meth.__doc__ or ''
                doc = [
                    line.strip() for line in doc.split('\n') if line.strip()
                ]
                buf = ''
                for line in doc:
                    if '%%' not in line and buf is not None:
                        buf += line + ' '
                    else:
                        if buf is not None:
                            for b in utils.split_message(buf, 160):
                                yield b
                            buf = None
                        line = line.replace('%%', self.context.config.cmd)
                        yield line
                aliases = predicates.get('aliases', None)
                if aliases is not None:
                    yield 'Aliases: {0}'.format(','.join(sorted(aliases)))
            else:
                yield ('No such command. Try %shelp for an '
                       'overview of all commands.' % self.context.config.cmd)
        else:
            cmds = sorted((k for (k, (p, m)) in self.items()
                           if p.get('show_in_help_list', True)))
            cmds_str = ', '.join([self.cmd + k for k in cmds])
            lines = utils.split_message('Available commands: %s ' % cmds_str,
                                        160)
            for line in lines:
                yield line
            url = self.config.get('url')
            if url:
                yield 'Full help is available at ' + url
コード例 #4
0
ファイル: command.py プロジェクト: gawel/irc3
    def help(self, mask, target, args):
        """Show help

            %%help [<cmd>]
        """
        if args['<cmd>']:
            args = args['<cmd>']
            # Strip out self.context.config.cmd from args so we can use
            # both !help !foo and !help foo
            if args.startswith(self.context.config.cmd):
                args = args[len(self.context.config.cmd):]
            args = self.aliases.get(args, args)
            predicates, meth = self.get(args, (None, None))
            if meth is not None:
                doc = meth.__doc__ or ''
                doc = [l.strip() for l in doc.split('\n') if l.strip()]
                buf = ''
                for line in doc:
                    if '%%' not in line and buf is not None:
                        buf += line + ' '
                    else:
                        if buf is not None:
                            for b in utils.split_message(buf, 160):
                                yield b
                            buf = None
                        line = line.replace('%%', self.context.config.cmd)
                        yield line
                aliases = predicates.get('aliases', None)
                if aliases is not None:
                    yield 'Aliases: {0}'.format(','.join(sorted(aliases)))
            else:
                yield ('No such command. Try %shelp for an '
                       'overview of all commands.'
                       % self.context.config.cmd)
        else:
            cmds = sorted((k for (k, (p, m)) in self.items()
                           if p.get('show_in_help_list', True)))
            cmds_str = ', '.join([self.cmd + k for k in cmds])
            lines = utils.split_message(
                'Available commands: %s ' % cmds_str, 160)
            for line in lines:
                yield line
            url = self.config.get('url')
            if url:
                yield 'Full help is available at ' + url
コード例 #5
0
ファイル: __init__.py プロジェクト: Harmon758/irc3
 def notice(self, client, message):
     """send a notice to client"""
     if client and message:
         messages = utils.split_message(message, self.config.max_length)
         for msg in messages:
             client.fwrite(':{c.srv} NOTICE {c.nick} :{msg}', msg=msg)
コード例 #6
0
 def callFTU(self, messages, max_length=10):
     return list(split_message(' '.join(messages), max_length))
コード例 #7
0
ファイル: test_utils.py プロジェクト: valhallasw/irc3
 def callFTU(self, messages, **kwargs):
     return list(split_message(' '.join(messages), 80))
コード例 #8
0
ファイル: test_utils.py プロジェクト: gordonzola/irc3
 def callFTU(self, messages, **kwargs):
     return list(split_message(' '.join(messages), 80))
コード例 #9
0
ファイル: test_utils.py プロジェクト: chassing/irc3
 def callFTU(self, messages, max_length=10):
     return list(split_message(' '.join(messages), max_length))
コード例 #10
0
 def notice(self, client, message):
     """send a notice to client"""
     if client and message:
         messages = utils.split_message(message, self.config.max_length)
         for msg in messages:
             client.fwrite(':{c.srv} NOTICE {c.nick} :{msg}', msg=msg)