• Strophe
  • Punjab
  • Palaver
  • Speeqe
  • Stanziq
Palaver Logo
  • Login
  • Preferences
  • Help/Guide
  • OpenID Login
  • Wiki
  • Timeline
  • Roadmap
  • View Tickets
  • Search

Context Navigation

  • Start Page
  • Index
  • History
  • Last Change

  1. Palaver Plugins
    1. Room restriction/events plugin
    2. Presence extension plugin
    3. Message plugin
    4. Setup the plugins

Palaver Plugins

Palaver has a plugin system for adding restrictions or code based on rooms actions. You create 'hooks' for when room events happen. There are 3 types of plugins. Room events, Presence, and Message.

Room restriction/events plugin

These plugins allow for you to add code to restrict different kinds of users beyond the basic MUC protocol. You can also use this plugin to gather data on these actions. The plugin hooks into room 'join' and room 'create'.

You need to create a class and add 'join' and 'create' methods.

Example: (NOTE: settings is a fake file containing lists to check against)

from twisted.internet import defer
import sessions

class Plugin(object):
    """
    A plugin class for palaver to check if we have permissions to join and create rooms.

    """
    
                
    def join(self, user, room = None, host = None):
        """ Return True or False based on permissions. """
        if host in settings.FREE_CHAT_SERVERS:
            return defer.succeed(True)
       

    def create(self, room, user, legacy=None, host=None):
        if user in settings.COMPONENTS:
            return defer.succeed(True)

Presence extension plugin

Example:

class Plugin(object):
    """
    A plugin class for palaver to send extended presence information.
    """
            
    def member_info(self, user, room = None, host = None):
        """ This plugin method needs to return a list of domish.Elements to add to the presence element broadcasted """
        return [] 

Message plugin

Example:

class Plugin(object):
    """
    A plugin class for palaver to perform actions based on messages. 
    Return True to pass the message through
    Return False to block the message
    """
                    
    def message(self, user, msg):
        if user in COMPONENTS:
            return defer.succeed(True)


Setup the plugins

To enable the plugins you have to add them to your .tac file.

Example :

...
from plugins import presence, room, message
plugins = {'extended-presence': presence.Plugin(),
           'join-room': room.Plugin(),
           'create-room': room.Plugin(),
           'groupchat': message.Plugin(),
           }

...

Download in other formats:

  • Plain Text

Trac Powered

Powered by Trac 0.11.5
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/