From f9dca68fb0b9ead1e89fad31071e05a5fec992f8 Mon Sep 17 00:00:00 2001 From: dece Date: Mon, 16 May 2022 12:02:45 +0200 Subject: [PATCH] plugin: allow plugins to write to other storages --- edmond/plugin.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/edmond/plugin.py b/edmond/plugin.py index 2c01b0d..92c06d6 100644 --- a/edmond/plugin.py +++ b/edmond/plugin.py @@ -105,12 +105,13 @@ class Plugin: ns = self.name return self.bot.storage.get(ns, {}).get(key, default) - def set_storage_value(self, key, value): + def set_storage_value(self, key, value, ns=None): """Set a value in the plugin persistent storage.""" - if self.name not in self.bot.storage: - self.bot.storage[self.name] = {key: value} + name = ns or self.name + if name not in self.bot.storage: + self.bot.storage[name] = {key: value} else: - self.bot.storage[self.name][key] = value + self.bot.storage[name][key] = value def append_storage_list_value(self, key, value): """Append a value to a list in the plugin persistent storage."""