view data/plugin/macro/ @ 442:0d04cca7b0da

qwebirc macro: usage and configuration docs
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 03 Oct 2009 20:00:43 +0200
parents da901fe39fa9
children 87173eb0f02d
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
    MoinMoin - embed a qwebirc based IRC chat iframe


    # . in nick name will give some random number:

    # maybe nice for a wiki homepage:

    # choose a random nickname, but still show dialogue (so you can change it):

    The macro has a (small) builtin list of qwebirc based chat servers, but you
    can use your own by defining it in your wiki config:

    qwebirc_servers = {
        # server name: web based service url
        'freenode': '',
        # add your own ones here

    @copyright: 2009 MoinMoin:ThomasWaldmann
    @license: GNU GPL, see COPYING for details.

# "known" qwebirc servers, use cfg.qwebirc_servers to give more
builtin_servers = {
    'freenode': '',

from MoinMoin import wikiutil

def macro_qwebirc(macro,
                  nick=u'', randomnick=0, prompt=0, width=647, height=400):
    """ Embed a qwebirc based IRC chat iframe """
    request = macro.request
    cfg = request.cfg
    servers = getattr(cfg, 'qwebirc_servers', builtin_servers)

        base_url = servers[server]
    except KeyError:
        # unknown server (we only allow specific server urls to avoid XSS)
        return u'qwebirc: unknown server (choose from %r)' % servers.keys()

    qs = dict(width=width, height=height)
    if channels:
        qs['channels'] = channels
    if nick:
        qs['nick'] = nick
    if randomnick:
        qs['randomnick'] = randomnick
    if prompt:
        qs['prompt'] = prompt
    qs = wikiutil.makeQueryString(qs)
    html = u"""<iframe src="%(base_url)s?%(qs)s" width="%(width)d" height="%(height)d"></iframe>\n""" % locals()
    return macro.formatter.rawHTML(html)