changeset 441:da901fe39fa9

qwebirc macro: make server and channels required params
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 03 Oct 2009 19:25:46 +0200
parents 24897c510f52
children 0d04cca7b0da
files data/plugin/macro/qwebirc.py
diffstat 1 files changed, 6 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/macro/qwebirc.py	Sat Oct 03 19:11:38 2009 +0200
+++ b/data/plugin/macro/qwebirc.py	Sat Oct 03 19:25:46 2009 +0200
@@ -8,36 +8,26 @@
 
 # "known" qwebirc servers, you can use cfg.qwebirc_servers to give
 # your own dictionary:
-servers = {
+builtin_servers = {
     'freenode': 'http://webchat.freenode.net/',
 }
 
-# default server (if none is specified in the macro call, you can use
-# cfg.qwebirc_server_default to give your own default server:
-server_default = 'freenode'
-
 
 from MoinMoin import wikiutil
 
 
-def macro_qwebirc(macro, channels=u'', nick=u'', randomnick=0, prompt=0,
-                  width=647, height=400, server=u''):
+def macro_qwebirc(macro,
+                  server=wikiutil.required_arg(unicode),
+                  channels=wikiutil.required_arg(unicode),
+                  nick=u'', randomnick=0, prompt=0, width=647, height=400):
     """ Embed a qwebirc based IRC chat iframe
 
         <<qwebirc()>>
     """
     request = macro.request
     cfg = request.cfg
-    try:
-        servers = getattr(cfg, 'qwebirc_servers')
-    except AttributeError:
-        pass # use "servers" from globals
+    servers = getattr(cfg, 'qwebirc_servers', builtin_servers)
 
-    if not server:
-        try:
-            server = getattr(cfg, 'qwebirc_server_default')
-        except AttributeError:
-            server = server_default
     try:
         base_url = servers[server]
     except KeyError: