How to use the errbot.re_botcmd function in errbot

To help you get started, we’ve selected a few errbot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github errbotio / errbot / tests / dummy_plugin / dummy.py View on Github external
    @re_botcmd(pattern=r"plz dont match this")
    def re_foo(self, msg, match):
        """This runs re_foo."""
        return 'bar'
github errbotio / errbot / tests / base_backend_tests.py View on Github external
    @re_botcmd(pattern=r'^regex command with prefix$', prefixed=True)
    def regex_command_with_prefix(self, mess, match):
        return "Regex command"
github errbotio / errbot / tests / base_backend_tests.py View on Github external
    @re_botcmd(pattern=r'match_here', matchall=True)
    def regex_command_with_matchall(self, mess, matches):
        return len(matches)
github coala / corobo / plugins / coatils.py View on Github external
    @re_botcmd(pattern=r'ls\s+bears\s+((?:[\w\+]+(?:\s+)?)+)',
               re_cmd_name_help='ls bears [langs]+')
    def ls(self, msg, match):
        """
        List bears of given languages:
        Example: `ls bears python python3`
        """
        langs = list(map(lambda x: x.lower(), match.group(1).split()))

        bears = client.list.bears.get().json()
        bears = [{**{'name': bear}, **content}
                 for bear, content in bears.items()]

        for lang in langs:
            selected_bears = [
                ' | ' + bear['name'] for bear in filter(lambda x: lang in list(
                    map(lambda y: y.lower(), x['languages'])),
github coala / corobo / plugins / ship_it.py View on Github external
    @re_botcmd(pattern=r'ship\s*it',
               re_cmd_name_help='ship it',
               flags=re.IGNORECASE)
    def ship_it(self, msg, match):
        """
        Show motivational ship it squirrel images.
        """
        return '![ship it!]({})'.format(
            self.IMAGES[random.randint(0, len(self.IMAGES) - 1)]
        )
github coala / corobo / plugins / ghetto.py View on Github external
    @re_botcmd(pattern=r'ghetto\s+(.+)',
               re_cmd_name_help='ghetto ',
               flags=re.IGNORECASE)
    def ghetto(self, msg, match):
        """
        Real talk yo
        """
        rq = requests.post('http://www.gizoogle.net/textilizer.php',
                           data={'translatetext': match.group(1)})

        translated_text = re.search(
            r'<textarea>(.+)</textarea>', rq.text)
        if translated_text is not None:
            return translated_text.group(1)
        else:
            return 'Shiznit happens!'
github coala / corobo / plugins / labhub.py View on Github external
    @re_botcmd(pattern=r'^unassign\s+https://(github|gitlab)\.com/([^/]+)/([^/]+)/issues/(\d+)',  # Ignore LineLengthBear, PyCodeStyleBear
               re_cmd_name_help='unassign ',
               flags=re.IGNORECASE)
    def unassign_cmd(self, msg, match):
        """Unassign from an issue."""  # Ignore QuotesBear
        org = match.group(2)
        repo_name = match.group(3)
        issue_number = match.group(4)

        user = msg.frm.nick
        if not user:
            yield 'ERROR: The above command cannot be operated without nick.'
            return

        try:
            assert org == self.GH_ORG_NAME or org == self.GL_ORG_NAME
        except AssertionError:
github coala / corobo / plugins / the_rules.py View on Github external
    @re_botcmd(pattern=r'the\s+rules',
               re_cmd_name_help='the rules',
               flags=re.IGNORECASE,
               template='the_rules.jinja2')
    def the_rules(self, msg, args):
        """
        Show the bot rules.
        """
        return {'rules': True}
github coala / corobo / plugins / nevermind.py View on Github external
    @re_botcmd(pattern=r'^(nm)$|^(nevermind)$', flags=re.IGNORECASE)
    def nevermind(self, message, match):
        """Doesn't mind"""
        return "I'm sorry :("
github coala / corobo / plugins / labhub.py View on Github external
    @re_botcmd(pattern=r'^assign\s+https://(github|gitlab)\.com/([^/]+)/([^/]+/)+issues/(\d+)',  # Ignore LineLengthBear, PyCodeStyleBear
               re_cmd_name_help='assign ',
               flags=re.IGNORECASE)
    def assign_cmd(self, msg, match):
        """Assign to GitLab and GitHub issues."""  # Ignore QuotesBear
        org = match.group(2)
        repo_name = match.group(3)[:-1]
        iss_number = match.group(4)

        user = msg.frm.nick
        if not user:
            yield 'ERROR: The above command cannot be operated without nick.'
            return

        try:
            assert org == self.GH_ORG_NAME or org == self.GL_ORG_NAME
        except AssertionError: