comparison src/plugins/plugin_misc_extra_pep.py @ 1741:cc31dd72526d

plugin misc_extra_pep: use a user parameter (jids_list) instead of a general configuration value
author souliane <souliane@mailoo.org>
date Fri, 11 Dec 2015 09:12:11 +0100
parents 0eaa1a409dfb
children 9a48e09044eb
comparison
equal deleted inserted replaced
1740:681fe91abcc0 1741:cc31dd72526d
15 # GNU Affero General Public License for more details. 15 # GNU Affero General Public License for more details.
16 16
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 from sat.core.i18n import _ 20 from sat.core.i18n import _, D_
21 from sat.core.log import getLogger 21 from sat.core.log import getLogger
22 log = getLogger(__name__) 22 log = getLogger(__name__)
23 23
24 24
25 PLUGIN_INFO = { 25 PLUGIN_INFO = {
26 "name": "Extra PEP", 26 "name": "Extra PEP",
27 "import_name": "EXTRA-PEP", 27 "import_name": "EXTRA-PEP",
28 "type": "MISC", 28 "type": "MISC",
29 "protocols": [], 29 "protocols": [],
30 "dependencies": [], 30 "dependencies": [],
31 "recommendations": ['XEP-0277'], 31 "recommendations": [],
32 "main": "ExtraPEP", 32 "main": "ExtraPEP",
33 "handler": "no", 33 "handler": "no",
34 "description": _(u"""Display messages from extra PEP services""") 34 "description": _(u"""Display messages from extra PEP services""")
35 } 35 }
36 36
37 CONFIG_SECTION = "plugin extra pep" 37 PARAM_KEY = u"Misc"
38 38 PARAM_NAME = u"Blog authors following list"
39 default_conf = {"get_items_from_list": ["salut-a-toi@libervia.org"], } 39 PARAM_DEFAULT = ["salut-a-toi@libervia.org"]
40
41 40
42 class ExtraPEP(object): 41 class ExtraPEP(object):
42
43 params = """
44 <params>
45 <individual>
46 <category name="%(category_name)s" label="%(category_label)s">
47 <param name="%(param_name)s" label="%(param_label)s" type="jids_list" security="0">
48 %(jids)s
49 </param>
50 </category>
51 </individual>
52 </params>
53 """ % {
54 'category_name': PARAM_KEY,
55 'category_label': D_(PARAM_KEY),
56 'param_name': PARAM_NAME,
57 'param_label': D_(PARAM_NAME),
58 'jids': "".join(["<jid>%s</jid>" % jid for jid in PARAM_DEFAULT])
59 }
43 60
44 def __init__(self, host): 61 def __init__(self, host):
45 log.info(_(u"Plugin Extra PEP initialization")) 62 log.info(_(u"Plugin Extra PEP initialization"))
46 self.host = host 63 self.host = host
64 host.memory.updateParams(self.params)
47 65
48 def getConfig(self, name): 66 def getFollowedEntities(self, profile_key):
49 return self.host.memory.getConfig(CONFIG_SECTION, name, default_conf[name]) 67 return self.host.memory.getParamA(PARAM_NAME, PARAM_KEY, profile_key=profile_key)