changeset 1728:0eaa1a409dfb

plugin XEP-0277, EXTRA-PEP: get massive blogs from all the roster also retrieve items from a special JIDs list defined in EXTRA-PEP
author souliane <souliane@mailoo.org>
date Tue, 08 Dec 2015 17:41:34 +0100
parents 68e498b3367e
children 9037161e28f0
files src/plugins/plugin_misc_extra_pep.py src/plugins/plugin_xep_0277.py
diffstat 2 files changed, 58 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/plugins/plugin_misc_extra_pep.py	Tue Dec 08 17:41:34 2015 +0100
@@ -0,0 +1,49 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# SAT plugin for displaying messages from extra PEP services
+# Copyright (C) 2015 Adrien Cossa (souliane@mailoo.org)
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from sat.core.i18n import _
+from sat.core.log import getLogger
+log = getLogger(__name__)
+
+
+PLUGIN_INFO = {
+    "name": "Extra PEP",
+    "import_name": "EXTRA-PEP",
+    "type": "MISC",
+    "protocols": [],
+    "dependencies": [],
+    "recommendations": ['XEP-0277'],
+    "main": "ExtraPEP",
+    "handler": "no",
+    "description": _(u"""Display messages from extra PEP services""")
+}
+
+CONFIG_SECTION = "plugin extra pep"
+
+default_conf = {"get_items_from_list": ["salut-a-toi@libervia.org"], }
+
+
+class ExtraPEP(object):
+
+    def __init__(self, host):
+        log.info(_(u"Plugin Extra PEP initialization"))
+        self.host = host
+
+    def getConfig(self, name):
+        return self.host.memory.getConfig(CONFIG_SECTION, name, default_conf[name])
--- a/src/plugins/plugin_xep_0277.py	Tue Dec 08 16:55:54 2015 +0100
+++ b/src/plugins/plugin_xep_0277.py	Tue Dec 08 17:41:34 2015 +0100
@@ -54,7 +54,7 @@
     "type": "XEP",
     "protocols": ["XEP-0277"],
     "dependencies": ["XEP-0163", "XEP-0060", "TEXT-SYNTAXES"],
-    "recommendations": ["XEP-0059"],
+    "recommendations": ["XEP-0059", "EXTRA-PEP"],
     "main": "XEP_0277",
     "handler": "no",
     "description": _("""Implementation of microblogging Protocol""")
@@ -647,6 +647,14 @@
             jids_set = set(publishers)
         else:
             jids_set = client.roster.getJidsSet(publishers_type, publishers)
+            if publishers_type == C.ALL:
+                try:  # display messages from salut-a-toi@libervia.org or other PEP services
+                    services = self.host.plugins["EXTRA-PEP"].getConfig("get_items_from_list")
+                except KeyError:
+                    pass
+                else:
+                    log.debug("Items from the following extra PEP services will be requested as well: %s" % ", ".join(services))
+                    jids_set.update([jid.JID(service) for service in services])
 
         node_data = []
         for jid_ in jids_set: