How to use the errbot.templating.tenv 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 coala / corobo / plugins / explain.py View on Github external
def explain(self, msg, match):
        """Explain various terms."""  # Ignore QuotesBear
        user = msg.frm.nick
        response = ''
        filename = 'explain/{}.jinja2.md'.format(match.group(1).lower())
        if match.group(1).lower() in self.KNOWN_KEYS:
            if match.group(2):
                response += '@{}: \n'.format(match.group(2))
            response += tenv().get_template(filename).render(
                username=user,
                target=match.group(2),
                bot_prefix=self.bot_config.BOT_PREFIX,
            )
        else:
            response = self.ERROR_MSG

        return response
github coala / corobo / plugins / labhub.py View on Github external
if not iss.assignees:
                if eligible(user, iss):
                    iss.assign(user)
                    yield ('Congratulations! You\'ve been assigned to the '
                           'issue. :tada:')
                else:
                    yield 'You are not eligible to be assigned to this issue.'
                    yield tenv().get_template(
                        'labhub/errors/not-eligible.jinja2.md'
                    ).render(
                        organization=self.GH_ORG_NAME,
                    )
            elif user in iss.assignees:
                yield ('The issue is already assigned to you.')
            else:
                yield tenv().get_template(
                    'labhub/errors/already-assigned.jinja2.md'
                ).render(
                    username=user,
                )
github daenney / err-repohook / providers.py View on Github external
def render_template(self, template='generic', **kwargs):
        kwargs['repo_name'] = kwargs.get('repo_name') or self.name
        return tenv().get_template('{0}.html'.format(template)).render(**kwargs)
github coala / corobo / plugins / spam.py View on Github external
def callback_message(self, msg):
        """
        Alert the user that his/her message is too long or has too
        many lines.
        """

        if (len(msg.body) > self.config['MAX_MSG_LEN'] or
                msg.body.count('\n') >= self.config['MAX_LINES']):
            user = msg.frm.nick
            response = tenv().get_template(
                'spam_alert.jinja2.md'
            ).render(
                target=user
            )
            self.send(msg.frm, response)
github errbotio / errbot / errbot / errBot.py View on Github external
def process_reply(reply_):
            # integrated templating
            if template_name:
                reply_ = tenv().get_template(template_name + '.md').render(**reply_)

            # Reply should be all text at this point (See https://github.com/gbin/err/issues/96)
            return str(reply_)
github coala / corobo / plugins / labhub.py View on Github external
invite(invitee, team)
            yield tenv().get_template(
                'labhub/promotions/{}.jinja2.md'.format(team)
            ).render(
                target=invitee,
            )
        elif is_developer:
            if team == 'newcomers':
                invite(invitee, team)
                yield tenv().get_template(
                    'labhub/promotions/{}.jinja2.md'.format(team)
                ).render(
                    target=invitee,
                )
            else:
                yield tenv().get_template(
                    'labhub/errors/not-eligible-invite.jinja2.md'
                ).render(
                    action='invite someone to developers or maintainers',
                    designation='maintainer',
                    target=inviter,
                )
        else:
            yield tenv().get_template(
                'labhub/errors/not-eligible-invite.jinja2.md'
            ).render(
                action='invite other people',
                designation='developer/maintainer',
                target=inviter,
            )
github br0ziliy / err-ansible / lib / utils.py View on Github external
def get_template(backend, func):
    """ Selects a template based on the current backend """
    templates = [
        "".join([backend, "_", func, ".md"]),
        "".join(["default_", func, ".md"])
    ]
    return tenv().get_or_select_template(templates).name
github coala / corobo / plugins / labhub.py View on Github external
def callback_message(self, msg):
        """Invite the user whose message includes the holy 'hello world'"""
        if re.search(r'hello\s*,?\s*world', msg.body, flags=re.IGNORECASE):
            user = msg.frm.nick
            if (not self.is_team_member(user, 'newcomers')
                    and user not in self.hello_world_users):
                response = tenv().get_template(
                    'labhub/hello-world.jinja2.md'
                ).render(
                    target=user,
                )
                self.send(msg.frm, response)
                self.hello_world_users.add(user)