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)
This commit is contained in:
Krytarik Raido 2021-04-22 21:13:04 +02:00
parent 34203f7b11
commit 8ffed09aef
2 changed files with 16 additions and 12 deletions

View File

@ -24,7 +24,7 @@ import supybot
import supybot.world as world import supybot.world as world
from importlib import reload from importlib import reload
__version__ = "3.3.1" __version__ = "3.4.0"
__author__ = supybot.Author("Krytarik Raido", "krytarik", "krytarik@gmail.com") __author__ = supybot.Author("Krytarik Raido", "krytarik", "krytarik@gmail.com")
__contributors__ = { __contributors__ = {
supybot.Author("Dennis Kaarsemaker", "Seveas", "dennis@kaarsemaker.net"): ['Original Author'], supybot.Author("Dennis Kaarsemaker", "Seveas", "dennis@kaarsemaker.net"): ['Original Author'],

View File

@ -278,21 +278,25 @@ class Encyclopedia(callbacks.Plugin):
def get_factoids(self, name, channel, display=None): def get_factoids(self, name, channel, display=None):
factoids = FactoidSet() factoids = FactoidSet()
factoids.global_primary = self.get_single_factoid(channel, name, deleted=bool(display)) if not display or display == 'alias':
factoids.global_secondary = self.get_single_factoid(channel, name + '-also', deleted=bool(display)) deleted = False
if channel: else:
factoids.channel_primary = self.get_single_factoid(channel, name + '-' + channel.lower(), deleted=bool(display)) deleted = True
factoids.channel_secondary = self.get_single_factoid(channel, name + '-' + channel.lower() + '-also', deleted=bool(display)) 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: if not display:
self.increment_factoid_popularity(factoids, channel) self.increment_factoid_popularity(factoids, channel)
factoids.global_primary = self.resolve_alias(channel, factoids.global_primary) factoids.global_primary = self.resolve_alias(channel, factoids.global_primary)
factoids.global_secondary = self.resolve_alias(channel, factoids.global_secondary) factoids.global_secondary = self.resolve_alias(channel, factoids.global_secondary)
if channel: if channel:
factoids.channel_primary = self.resolve_alias(channel, factoids.channel_primary) factoids.channel_primary = self.resolve_alias(channel, factoids.channel_primary)
factoids.channel_secondary = self.resolve_alias(channel, factoids.channel_secondary) factoids.channel_secondary = self.resolve_alias(channel, factoids.channel_secondary)
elif display == 'info': elif display == 'info':
factoids.global_primary = self.factoid_info(channel, factoids.global_primary) factoids.global_primary = self.factoid_info(channel, factoids.global_primary)
factoids.global_secondary = self.factoid_info(channel, factoids.global_secondary) factoids.global_secondary = self.factoid_info(channel, factoids.global_secondary)
if channel: if channel:
factoids.channel_primary = self.factoid_info(channel, factoids.channel_primary) factoids.channel_primary = self.factoid_info(channel, factoids.channel_primary)
factoids.channel_secondary = self.factoid_info(channel, factoids.channel_secondary) factoids.channel_secondary = self.factoid_info(channel, factoids.channel_secondary)
@ -455,7 +459,7 @@ class Encyclopedia(callbacks.Plugin):
if not text: if not text:
return return
irc = callbacks.NestedCommandsIrcProxy(irc, msg, []) irc = callbacks.ReplyIrcProxy(irc, msg)
# Now switch between actions # Now switch between actions
ret, retmsg = '', '' ret, retmsg = '', ''
@ -591,7 +595,7 @@ class Encyclopedia(callbacks.Plugin):
if not text.lower().startswith('delete '): if not text.lower().startswith('delete '):
return return
name = text[7:].strip() name = text[7:].strip()
factoid = self.get_single_factoid(channel, name) factoid = self.get_single_factoid(channel, name, deleted=True)
if not factoid: if not factoid:
return "I know nothing about '%s' yet, %s" % (name, editor) return "I know nothing about '%s' yet, %s" % (name, editor)
retmsg = "I'll delete that, %s" % editor retmsg = "I'll delete that, %s" % editor