summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2011-11-13 00:57:54 +0100
committermathieui <mathieui@mathieui.net>2011-11-13 00:57:54 +0100
commitaac980cd4c55c5e49ee2f571f808a48ed349550a (patch)
treec1edb620b54a9e1cf201bfa931cd72c25aa04830 /src
parent572cc678a079aa24fffebda5c76f4e5cb35893c5 (diff)
downloadpoezio-aac980cd4c55c5e49ee2f571f808a48ed349550a.tar.gz
poezio-aac980cd4c55c5e49ee2f571f808a48ed349550a.tar.bz2
poezio-aac980cd4c55c5e49ee2f571f808a48ed349550a.tar.xz
poezio-aac980cd4c55c5e49ee2f571f808a48ed349550a.zip
Add a /set_plugin command
Diffstat (limited to 'src')
-rw-r--r--src/core.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/core.py b/src/core.py
index 1f93324d..dd2690f4 100644
--- a/src/core.py
+++ b/src/core.py
@@ -135,6 +135,7 @@ class Core(object):
'plugins': (self.command_plugins, _('Usage: /plugins\nPlugins: Show the plugins in use.'), None),
'presence': (self.command_presence, _('Usage: /presence <JID> [type] [status]\nPresence: Send a directed presence to <JID> and using [type] and [status] if provided.'), None),
'rawxml': (self.command_rawxml, _('Usage: /rawxml\nRawXML: Send a custom xml stanza.'), None),
+ 'set_plugin': (self.command_set_plugin, _("Usage: /set_plugin <plugin> <option> [value]\nSet Plugin: Set the value of the option in a plugin configuration file."), None),
}
self.key_func = {
@@ -1519,6 +1520,30 @@ class Core(object):
msg = "%s=%s" % (option, value)
self.information(msg, 'Info')
+ def command_set_plugin(self, arg):
+ """
+ /set_plugin <plugin> <option> [value]
+ """
+ args = arg.split()
+ if len(args) != 3 and len(args) != 2:
+ self.command_help('set_plugin')
+ return
+ plugin_name = args[0]
+ if not plugin_name in self.plugin_manager.plugins:
+ return
+ plugin = self.plugin_manager.plugins[plugin_name]
+ option = args[1]
+ if len(args) == 3:
+ value = args[2]
+ else:
+ value = ''
+ plugin.config.set_and_save(option, value, plugin_name)
+ if not plugin.config.write():
+ self.core.information('Could not save the plugin config', 'Error')
+ return
+ msg = "%s=%s" % (option, value)
+ self.information(msg, 'Info')
+
def close_tab(self, tab=None):
"""
Close the given tab. If None, close the current one