From 8ffed09aef71782adf62dbc442c3e2c35c3f0aa2 Mon Sep 17 00:00:00 2001 From: Krytarik Raido Date: Thu, 22 Apr 2021 21:13:04 +0200 Subject: [PATCH] Encyclopedia: Various improvements. * Improve handling of aliases. * Make 'delete' work without prior 'unforget' * Fix issue of passing empty commands to bot just to allow multi-message output (about to be fixed by pending upstream change) --- Encyclopedia/__init__.py | 2 +- Encyclopedia/plugin.py | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Encyclopedia/__init__.py b/Encyclopedia/__init__.py index 7e4b08e..60bd257 100644 --- a/Encyclopedia/__init__.py +++ b/Encyclopedia/__init__.py @@ -24,7 +24,7 @@ import supybot import supybot.world as world from importlib import reload -__version__ = "3.3.1" +__version__ = "3.4.0" __author__ = supybot.Author("Krytarik Raido", "krytarik", "krytarik@gmail.com") __contributors__ = { supybot.Author("Dennis Kaarsemaker", "Seveas", "dennis@kaarsemaker.net"): ['Original Author'], diff --git a/Encyclopedia/plugin.py b/Encyclopedia/plugin.py index 115cf41..b018db1 100644 --- a/Encyclopedia/plugin.py +++ b/Encyclopedia/plugin.py @@ -278,21 +278,25 @@ class Encyclopedia(callbacks.Plugin): def get_factoids(self, name, channel, display=None): factoids = FactoidSet() - factoids.global_primary = self.get_single_factoid(channel, name, deleted=bool(display)) - factoids.global_secondary = self.get_single_factoid(channel, name + '-also', deleted=bool(display)) - if channel: - factoids.channel_primary = self.get_single_factoid(channel, name + '-' + channel.lower(), deleted=bool(display)) - factoids.channel_secondary = self.get_single_factoid(channel, name + '-' + channel.lower() + '-also', deleted=bool(display)) + if not display or display == 'alias': + deleted = False + else: + deleted = True + factoids.global_primary = self.get_single_factoid(channel, name, deleted) + factoids.global_secondary = self.get_single_factoid(channel, name + '-also', deleted) + if channel and not display: + factoids.channel_primary = self.get_single_factoid(channel, name + '-' + channel.lower(), deleted) + factoids.channel_secondary = self.get_single_factoid(channel, name + '-' + channel.lower() + '-also', deleted) if not display: self.increment_factoid_popularity(factoids, channel) - factoids.global_primary = self.resolve_alias(channel, factoids.global_primary) - factoids.global_secondary = self.resolve_alias(channel, factoids.global_secondary) + factoids.global_primary = self.resolve_alias(channel, factoids.global_primary) + factoids.global_secondary = self.resolve_alias(channel, factoids.global_secondary) if channel: factoids.channel_primary = self.resolve_alias(channel, factoids.channel_primary) factoids.channel_secondary = self.resolve_alias(channel, factoids.channel_secondary) elif display == 'info': - factoids.global_primary = self.factoid_info(channel, factoids.global_primary) - factoids.global_secondary = self.factoid_info(channel, factoids.global_secondary) + factoids.global_primary = self.factoid_info(channel, factoids.global_primary) + factoids.global_secondary = self.factoid_info(channel, factoids.global_secondary) if channel: factoids.channel_primary = self.factoid_info(channel, factoids.channel_primary) factoids.channel_secondary = self.factoid_info(channel, factoids.channel_secondary) @@ -455,7 +459,7 @@ class Encyclopedia(callbacks.Plugin): if not text: return - irc = callbacks.NestedCommandsIrcProxy(irc, msg, []) + irc = callbacks.ReplyIrcProxy(irc, msg) # Now switch between actions ret, retmsg = '', '' @@ -591,7 +595,7 @@ class Encyclopedia(callbacks.Plugin): if not text.lower().startswith('delete '): return name = text[7:].strip() - factoid = self.get_single_factoid(channel, name) + factoid = self.get_single_factoid(channel, name, deleted=True) if not factoid: return "I know nothing about '%s' yet, %s" % (name, editor) retmsg = "I'll delete that, %s" % editor