view data/plugin/macro/bbb.py @ 653:127da830be6c

updated copyright
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 19 Apr 2016 16:29:54 +0200
parents 81cb72cfddac
children
line wrap: on
line source
# -*- coding: utf-8 -*-
"""
    MoinMoin - checks activity of BigBlueButton meetings

    @copyright: 2012-2016 MoinMoin:ReimarBauer
    @license: GNU GPL, see COPYING for details.
"""
import urllib
from MoinMoin import wikiutil
from MoinMoin.Page import Page
# pip install bigbluebutton
try:
    from bigbluebutton import Meeting
except ImportError:
    Meeting = None
try:    
    import bbb_settings
except ImportError:
    bbb_settings = None


def macro_bbb(macro):
    """
    Shows a list of all meetings with amount of participant and moderator
    On same directory as wikiconfig.py you need
    a "bbb_settings.py" module with the SALT and the BBB_API_URL.
    
    Example:
    <<bbb>>
    """
    if Meeting is None or bbb_settings is None:
        return u""
    request = macro.request
    _ = request.getText
    meeting = Meeting(bbb_settings.BBB_API_URL, bbb_settings.SALT)
    all_sessions = meeting.get_meetings()
    txt = ['= No active Meetings =']
    txt.append('(!) Create or Recreate a meeting')
    if all_sessions:
        txt = ['= Currently active Meetings =']
    if all_sessions:
        txt.append('|| meeting id || participation count || moderator count || users ||')
        for session in all_sessions:
            meeting_id = session["info"]['meeting_id']
            participation_count = session["info"]['participant_count']
            moderator_count = session["info"]['moderator_count']
            users = session["info"]["users"]
            users_in_meeting = ["%s %s" % (user["name"], user["role"][0]) for user in users]
            
        

            txt.append('|| %(meeting_id)s || %(participation_count)s|| %(moderator_count)s || %(users)s ||' % {"meeting_id": meeting_id,
                                                                                              "participation_count": participation_count,
                                                                                              "moderator_count": moderator_count,
                                                                                              "users": '<<BR>>'.join(users_in_meeting)
                                                                                              })


    raw = '\n'.join(txt)
    Parser = wikiutil.searchAndImportPlugin(request.cfg, "parser", request.page.pi['format'])
    return wikiutil.renderText(request, Parser, raw)