Beispiel #1
0
def trigger(request, key='', verb='', **kwargs):
    """Retrieve a factoid record from the database."""
    factoid = get_object_or_404(Factoid,
            fact__iexact=normalize_factoid_key(key))
    try:
        text = factoid.factoidresponse_set.filter(
            verb__contains=verb,disabled__exact=None).order_by("?")[0]
    except IndexError:
        # If it can't find the verb you asked for, it'll try anything.
        try:
            text = factoid.factoidresponse_set.filter(
                disabled__exact=None).order_by("?")[0]
        except IndexError:
            raise Http404
    if not text.tag:
        template = 'factoid.irc'
    else:
        template = 'factoid-%s.irc' % text.tag.lower()
    context = Context(request.__dict__)
    rendered = Template(text.text).render(context)
    d = {'factoid': key, 'verb': text.verb, 'text': rendered}
    if text.tag == 'action':
        method='ACTION'
    else:
        method='PRIVMSG'
    return render_to_response(request.reply_recipient, template, d,
                              method=method)
Beispiel #2
0
def trigger(request, key='', verb='', **kwargs):
    """Retrieve a factoid record from the database."""
    factoid = get_object_or_404(Factoid,
                                fact__iexact=normalize_factoid_key(key))
    try:
        text = factoid.factoidresponse_set.filter(
            verb__contains=verb, disabled__exact=None).order_by("?")[0]
    except IndexError:
        # If it can't find the verb you asked for, it'll try anything.
        try:
            text = factoid.factoidresponse_set.filter(
                disabled__exact=None).order_by("?")[0]
        except IndexError:
            raise Http404
    if not text.tag:
        template = 'factoid.irc'
    else:
        template = 'factoid-%s.irc' % text.tag.lower()
    context = Context(request.__dict__)
    rendered = Template(text.text).render(context)
    d = {'factoid': key, 'verb': text.verb, 'text': rendered}
    if text.tag == 'action':
        method = 'ACTION'
    else:
        method = 'PRIVMSG'
    return render_to_response(request.reply_recipient,
                              template,
                              d,
                              method=method)
Beispiel #3
0
def reload(request, *args, **kwargs):
    return render_to_response(request.reply_recipient,
                              "reload.irc", {},
                              method='RESET')
Beispiel #4
0
def reload(request, *args, **kwargs):
    return render_to_response(request.reply_recipient, "reload.irc", {},
            method='RESET')