]> kaliko git repositories - sid.git/blobdiff - sid/plugin.py
sphinx: Add sphinx docstring
[sid.git] / sid / plugin.py
index 3e7c87e63714e57e4bd9775b249239dea9a8a2d3..6db1d5984f07875af599dd694393ba0aeb8f69c2 100644 (file)
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 
 # Copyright (C) 2010, 2011 AnaĆ«l Verrier <elghinn@free.fr>
-# Copyright (C) 2014 kaliko <kaliko@azylum.org>
+# Copyright (C) 2014, 2020 kaliko <kaliko@azylum.org>
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 from .sid import botcmd
 
 class Plugin:
-    """Simple Plugin object to derive from:
-        Exposes the bot object and its logger
-        Provides some send helpers
+    """
+    Simple Plugin object to derive from:
+
+       * Exposes the bot object and its logger
+       * Provides send helpers
+
+    :param sid.sid.MUCBot bot: bot the plugin is load from
     """
 
     def __init__(self, bot):
@@ -29,13 +33,20 @@ class Plugin:
 
     def send(self, dest, msg, mtype='chat'):
         """Send msg to dest
-            msg = {
-                mbody: 'text',
-                mhtml: '<b>text</b>,  # optional'
-            }
+
+        :param str dest: Message recipient
+        :param dict,str msg: Message to send (use dict for xhtml-im)
+
+        .. note::
+          if **msg** is a :py:obj:`dict` to provide xhmlt-im massages::
+
+              msg = {
+                  mbody: 'text',
+                  mhtml: '<b>text</b>,  # optional'
+              }
         """
         if isinstance(msg, str):
-            msg = {'mbody':msg}
+            msg = {'mbody': msg}
         msg.setdefault('mhtml', None)
         self.bot.send_message(mto=dest,
                               mtype=mtype,
@@ -43,7 +54,11 @@ class Plugin:
 
     def reply(self, rcv, msg):
         """Smart reply to message received.
-        Replies <msg> in private or on the muc depending on <rcv>
+
+        Replies ``msg`` in private or on the muc depending on ``rcv``
+
+        :param rcv: The received message (slixmpp object)
+        :param dict,str msg: The message to reply, refer to :py:obj:`sid.plugin.Plugin.send` for ``msg`` format
         """
         to = rcv['from']
         if rcv['type'] == 'groupchat':