当前位置: 首页>>代码示例>>Python>>正文


Python Command.dispatch_command方法代码示例

本文整理汇总了Python中pajbot.models.command.Command.dispatch_command方法的典型用法代码示例。如果您正苦于以下问题:Python Command.dispatch_command方法的具体用法?Python Command.dispatch_command怎么用?Python Command.dispatch_command使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pajbot.models.command.Command的用法示例。


在下文中一共展示了Command.dispatch_command方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_internal_commands

# 需要导入模块: from pajbot.models.command import Command [as 别名]
# 或者: from pajbot.models.command.Command import dispatch_command [as 别名]
    def load_internal_commands(self, **options):
        if len(self.internal_commands) > 0:
            return self.internal_commands

        self.internal_commands = {}

        self.internal_commands['quit'] = Command.pajbot_command(self.bot, 'quit',
                level=1000,
                command='quit',
                description='Shut down the bot, this will most definitely restart it if set up properly')

        self.internal_commands['1quit'] = self.internal_commands['quit']
        self.internal_commands['ceaseallactionscurrentlybeingacteduponwiththecodeandiapologizeforbeingawhitecisgenderedmaleinthepatriarchy'] = self.internal_commands['quit']

        self.internal_commands['twitterfollow'] = Command.dispatch_command('twitter_follow',
                level=1000,
                description='Start listening for tweets for the given user',
                examples=[
                    CommandExample(None, 'Default usage',
                        chat='user:!twitterfollow forsensc2\n'
                        'bot>user:Now following ForsenSC2',
                        description='Follow ForsenSC2 on twitter so new tweets are output in chat.').parse(),
                    ])

        self.internal_commands['twitterunfollow'] = Command.dispatch_command('twitter_unfollow',
                level=1000,
                description='Stop listening for tweets for the given user',
                examples=[
                    CommandExample(None, 'Default usage',
                        chat='user:!twitterunfollow forsensc2\n'
                        'bot>user:No longer following ForsenSC2',
                        description='Stop automatically printing tweets from ForsenSC2').parse(),
                    ])

        self.internal_commands['add'] = Command.multiaction_command(
                level=100,
                delay_all=0,
                delay_user=0,
                default=None,
                command='add',
                commands={
                    'command': Command.dispatch_command('add_command',
                        level=500,
                        description='Add a command!',
                        examples=[
                            CommandExample(None, 'Create a normal command',
                                chat='user:!add command test Kappa 123\n'
                                'bot>user:Added your command (ID: 7)',
                                description='This creates a normal command with the trigger !test which outputs Kappa 123 to chat').parse(),
                            CommandExample(None, 'Create a command that responds with a whisper',
                                chat='user:!add command test Kappa 123 --whisper\n'
                                'bot>user:Added your command (ID: 7)',
                                description='This creates a command with the trigger !test which responds with Kappa 123 as a whisper to the user who called the command').parse(),
                            ]),
                    'win': Command.dispatch_command('add_win',
                        level=500,
                        description='Add a win to something!'),
                    'funccommand': Command.dispatch_command('add_funccommand',
                        level=2000,
                        description='Add a command that uses a command'),
                    'alias': Command.dispatch_command('add_alias',
                        level=500,
                        description='Adds an alias to an already existing command',
                        examples=[
                            CommandExample(None, 'Add an alias to a command',
                                chat='user:!add alias test alsotest\n'
                                'bot>user:Successfully added the aliases alsotest to test',
                                description='Adds the alias !alsotest to the existing command !test').parse(),
                            CommandExample(None, 'Add multiple aliases to a command',
                                chat='user:!add alias test alsotest newtest test123\n'
                                'bot>user:Successfully added the aliases alsotest, newtest, test123 to test',
                                description='Adds the aliases !alsotest, !newtest, and !test123 to the existing command !test').parse(),
                            ]),

                    })
        self.internal_commands['edit'] = Command.multiaction_command(
                level=100,
                delay_all=0,
                delay_user=0,
                default=None,
                command='edit',
                commands={
                    'command': Command.dispatch_command('edit_command',
                        level=500,
                        description='Edit an already-existing command',
                        examples=[
                            CommandExample(None, 'Change the response',
                                chat='user:!edit command test This is the new response!\n'
                                'bot>user:Updated the command (ID: 29)',
                                description='Changes the text response for the command !test to "This is the new response!"').parse(),
                            CommandExample(None, 'Change the Global Cooldown',
                                chat='user:!edit command test --cd 10\n'
                                'bot>user:Updated the command (ID: 29)',
                                description='Changes the global cooldown for the command !test to 10 seconds').parse(),
                            CommandExample(None, 'Change the User-specific Cooldown',
                                chat='user:!edit command test --usercd 30\n'
                                'bot>user:Updated the command (ID: 29)',
                                description='Changes the user-specific cooldown for the command !test to 30 seconds').parse(),
                            CommandExample(None, 'Change the Level for a command',
                                chat='user:!edit command test --level 500\n'
#.........这里部分代码省略.........
开发者ID:jardg,项目名称:pajbot,代码行数:103,代码来源:command.py

示例2: load_internal_commands

# 需要导入模块: from pajbot.models.command import Command [as 别名]
# 或者: from pajbot.models.command.Command import dispatch_command [as 别名]
    def load_internal_commands(self, **options):
        if len(self.internal_commands) > 0:
            return self.internal_commands

        self.internal_commands = {}

        self.internal_commands["quit"] = Command.pajbot_command(
            self.bot,
            "quit",
            level=1000,
            command="quit",
            description="Shut down the bot, this will most definitely restart it if set up properly",
        )

        self.internal_commands[
            "ceaseallactionscurrentlybeingacteduponwiththecodeandiapologizeforbeingawhitecisgenderedmaleinthepatriarchy"
        ] = self.internal_commands["quit"]

        self.internal_commands["twitterfollow"] = Command.dispatch_command(
            "twitter_follow",
            level=1000,
            description="Start listening for tweets for the given user",
            examples=[
                CommandExample(
                    None,
                    "Default usage",
                    chat="user:!twitterfollow forsensc2\n" "bot>user:Now following ForsenSC2",
                    description="Follow ForsenSC2 on twitter so new tweets are output in chat.",
                ).parse()
            ],
        )

        self.internal_commands["twitterunfollow"] = Command.dispatch_command(
            "twitter_unfollow",
            level=1000,
            description="Stop listening for tweets for the given user",
            examples=[
                CommandExample(
                    None,
                    "Default usage",
                    chat="user:!twitterunfollow forsensc2\n" "bot>user:No longer following ForsenSC2",
                    description="Stop automatically printing tweets from ForsenSC2",
                ).parse()
            ],
        )

        self.internal_commands["add"] = Command.multiaction_command(
            level=100,
            delay_all=0,
            delay_user=0,
            default=None,
            command="add",
            commands={
                "command": Command.dispatch_command(
                    "add_command",
                    level=500,
                    description="Add a command!",
                    examples=[
                        CommandExample(
                            None,
                            "Create a normal command",
                            chat="user:!add command test Kappa 123\n" "bot>user:Added your command (ID: 7)",
                            description="This creates a normal command with the trigger !test which outputs Kappa 123 to chat",
                        ).parse(),
                        CommandExample(
                            None,
                            "Create a command that responds with a whisper",
                            chat="user:!add command test Kappa 123 --whisper\n" "bot>user:Added your command (ID: 7)",
                            description="This creates a command with the trigger !test which responds with Kappa 123 as a whisper to the user who called the command",
                        ).parse(),
                    ],
                ),
                "win": Command.dispatch_command("add_win", level=500, description="Add a win to something!"),
                "funccommand": Command.dispatch_command(
                    "add_funccommand", level=2000, description="Add a command that uses a command"
                ),
                "alias": Command.dispatch_command(
                    "add_alias",
                    level=500,
                    description="Adds an alias to an already existing command",
                    examples=[
                        CommandExample(
                            None,
                            "Add an alias to a command",
                            chat="user:!add alias test alsotest\n"
                            "bot>user:Successfully added the aliases alsotest to test",
                            description="Adds the alias !alsotest to the existing command !test",
                        ).parse(),
                        CommandExample(
                            None,
                            "Add multiple aliases to a command",
                            chat="user:!add alias test alsotest newtest test123\n"
                            "bot>user:Successfully added the aliases alsotest, newtest, test123 to test",
                            description="Adds the aliases !alsotest, !newtest, and !test123 to the existing command !test",
                        ).parse(),
                    ],
                ),
            },
        )
        self.internal_commands["edit"] = Command.multiaction_command(
#.........这里部分代码省略.........
开发者ID:Zob3k,项目名称:pajbot,代码行数:103,代码来源:command.py


注:本文中的pajbot.models.command.Command.dispatch_command方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。