It's a beta for now, but sounds good already.
It adds two nodes "hello" and "quote"
If you send "<hello/>" it will reply "<world>Hello World</world>" ...
If you send "<quote>" it will reply with a random quote "<quote>Balblablabla</quote>"
Very simple plugin but shows you how to add actions and nodes easyly with Palabre
WARNING ! Don't use this one on production environments !
IF database access is configured in palabre.conf, it allows you to send ANY sql query in a <db/> node !
example : <db>SELECT * FROM my_table</db>
(WARNING, request could be DROP DATABASE ....)
And it will reply :
You can send "SHOW TABLES" or "SHOW COLUMNS my_table" and it will work too ...
self.name = "yourModule"
3. Then specify when your module should be called.
Two options are available : self.server.registerAction() and seld.server.registerNode()
If you want your plugin to be called every time Palabre executes a specific action (example when server startup, when a client connects, when a client Leaves, when a client sends a password for connection, ...)
Example : Do something when server starts :
Then add in your __init__ method :
self.server.registerAction('onStartup',self.name) And Create a method called : 'onStartup'
def onStartup(self,params):
# Do something
self.server.logger.info('My Module is loaded')
return
If you want to add an action when clients sends a specific node, add in __init__ :
self.server.regsiterNode('mynode',self.name):And create a method called 'doNode'
def doNode(self,nodeName,node, client):
if nodeName == 'mynode':
client.clientSendMessage('<anynode>You sent MYNODE !</anynode>')
4. In palabre.conf edit the [modules] section and add your module name to the list :
[modules]
list = helloworld,yourModule
Restart Palabre ... and You're done !
Further documentation will come when Palabre 0.6 will be stable
Please feel free to report to the forum.
Célio