summaryrefslogtreecommitdiff
path: root/doc/source/dev/plugin.rst
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2013-04-13 22:56:00 +0200
committermathieui <mathieui@mathieui.net>2013-04-13 22:56:00 +0200
commitf262d9f779292593cf043cc01b15ef785480bdd9 (patch)
treeb065013c692e840e6d6ac6cc9378f52dbb4fc25d /doc/source/dev/plugin.rst
parentd676c2ee7b6207ff0b2a7b384052ab07c08bf43a (diff)
downloadpoezio-f262d9f779292593cf043cc01b15ef785480bdd9.tar.gz
poezio-f262d9f779292593cf043cc01b15ef785480bdd9.tar.bz2
poezio-f262d9f779292593cf043cc01b15ef785480bdd9.tar.xz
poezio-f262d9f779292593cf043cc01b15ef785480bdd9.zip
Add the last pages, and the plugin examples
Diffstat (limited to 'doc/source/dev/plugin.rst')
-rw-r--r--doc/source/dev/plugin.rst31
1 files changed, 31 insertions, 0 deletions
diff --git a/doc/source/dev/plugin.rst b/doc/source/dev/plugin.rst
index 7978a5e9..323a058a 100644
--- a/doc/source/dev/plugin.rst
+++ b/doc/source/dev/plugin.rst
@@ -1,6 +1,9 @@
Plugin API documentation
========================
+BasePlugin
+----------
+
.. module:: plugin
.. autoclass:: BasePlugin
@@ -34,8 +37,36 @@ The :py:class:`~PluginAPI` object is an a interface through which the :py:class:
(and inheritors) *should* go to interact with poezio. If it is not sufficient, then the ``core``
member can be used.
+PluginAPI
+---------
+
.. autoclass:: PluginAPI
:members:
:undoc-members:
+Example plugins
+---------------
+
+**Example 1:** Add a simple command that sends "Hello World!" into the conversation
+
+.. code-block:: python
+
+ class Plugin(BasePlugin):
+ def init(self):
+ self.add_command('hello', self.command_hello, "Send 'Hello World!'")
+
+ def command_hello(self, arg):
+ self.core.send_message('Hello World!')
+
+**Example 2:** Adds an event handler that sends “tg” to a groupchat when a message is received from someone named “Partauche”
+
+.. code-block:: python
+
+ class Plugin(BasePlugin):
+ def init(self):
+ self.add_event_handler('muc_msg', self.on_groupchat_message)
+
+ def on_groupchat_message(self, message, tab):
+ if message['mucnick'] == "Partauche":
+ tab.command_say('tg')