diff --git a/docs/Killswitches.md b/docs/Killswitches.md index 85275819..8864f96c 100644 --- a/docs/Killswitches.md +++ b/docs/Killswitches.md @@ -92,7 +92,7 @@ The current recognised (to EDMC and its internal plugins) killswitch strings are | Kill Switch | Supported Plugins | Description | | :------------------------------------------- | :---------------------: | :---------------------------------------------------------------------------------------- | -| *`plugins.eddn.send` | eddn | Disables all use of the send method on EDDN (effectively disables EDDN updates) | +| `plugins.eddn.send` | eddn | Disables all use of the send method on EDDN (effectively disables EDDN updates) | | `plugins..journal` | eddn, inara, edsm, eddb | Disables all journal processing for the plugin | | `plugins..worker` | edsm, inara | Disables the plugins worker thread (effectively disables updates) (does not close thread) | | `plugins..worker.` | edsm, inara | Disables the plugin worker for the given eventname | diff --git a/plugins/eddn.py b/plugins/eddn.py index e532c8a8..3d0307fa 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -168,10 +168,13 @@ class EDDN: :param cmdr: the CMDR to use as the uploader ID. :param msg: the payload to send. """ - if (res := killswitch.get_disabled('plugins.eddn.send')).disabled: - logger.warning(f"eddn.send has been disabled via killswitch. Returning. ({res.reason})") + should_return, new_data = killswitch.check_killswitch('plugins.eddn.send', msg) + if should_return: + logger.warning('eddn.send has been disabled via killswitch. Returning.') return + msg = new_data + uploader_id = cmdr to_send: OrderedDictT[str, OrderedDict[str, Any]] = OrderedDict([ @@ -787,15 +790,18 @@ def journal_entry( # noqa: C901, CCR001 :param state: `dict` - Current `monitor.state` data. :return: `str` - Error message, or `None` if no errors. """ - if (ks := killswitch.get_disabled("plugins.eddn.journal")).disabled: - logger.warning(f'EDDN journal handler has been disabled via killswitch: {ks.reason}') + + should_return, new_data = killswitch.check_killswitch('plugins.eddn.journal', entry) + if should_return: plug.show_error(_('EDDN journal handler disabled. See Log.')) # LANG: Killswitch disabled EDDN return None - elif (ks := killswitch.get_disabled(f'plugins.eddn.journal.event.{entry["event"]}')).disabled: - logger.warning(f'Handling of event {entry["event"]} disabled via killswitch: {ks.reason}') + should_return, new_data = killswitch.check_killswitch(f'plugins.eddn.journal.event.{entry["event"]}', new_data) + if should_return: return None + entry = new_data + # Recursively filter '*_Localised' keys from dict def filter_localised(d: Mapping[str, Any]) -> OrderedDictT[str, Any]: filtered: OrderedDictT[str, Any] = OrderedDict()