Encyclopedia, PackageInfo: Add '!more' command.

So unprivileged users can page through multi-message outputs.

Also make PackageInfo stop processing requests twice in case of
privileged users PM'ing the bot with unprefixed commands, and make it
possible to address the bot with prefixed commands for unprivileged use.
This commit is contained in:
Krytarik Raido 2022-10-10 23:56:04 +02:00
parent cccf339e2e
commit bfa65ed8c3
5 changed files with 30 additions and 13 deletions

View File

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

View File

@ -205,7 +205,7 @@ conf.registerChannelValue(Encyclopedia, 'remotedb',
registry.String('https://ubottu.com/ubuntu.db', 'Remote location of the master database', private=True))
conf.registerChannelValue(Encyclopedia, 'ignores',
registry.SpaceSeparatedListOfStrings(['info', 'depends', 'find'], 'Factoid names to ignore', private=True))
registry.SpaceSeparatedListOfStrings(['info', 'depends', 'find', 'more'], 'Factoid names to ignore', private=True))
conf.registerChannelValue(Encyclopedia, 'repeatdelay',
registry.Integer(60, "Number of seconds to wait between repeated factoid calls"))

View File

@ -432,17 +432,21 @@ class Encyclopedia(callbacks.Plugin):
if not channel:
args = text.lower().split(None, 2)
for c in irc.callbacks:
if (args[0] == c.name().lower() and len(args) > 1
and c.isCommandMethod(args[1])) \
or c.isCommandMethod(args[0]):
return
if args[0] != "more":
for c in irc.callbacks:
if (args[0] == c.name().lower() and len(args) > 1
and c.isCommandMethod(args[1])) \
or c.isCommandMethod(args[0]):
return
prefixchar = self.registryValue('prefixchar', channel)
prefixed = False
if text[0] == prefixchar:
text = text[1:].strip()
prefixed = True
elif re.match(r'^%s[\W\s]\s*%s' % (re.escape(irc.nick), re.escape(prefixchar)), text, re.I):
text = re.sub(r'^%s[\W\s]\s*%s\s*' % (re.escape(irc.nick), re.escape(prefixchar)), '', text, flags=re.I)
prefixed = True
elif channel:
return
if not text:
@ -479,6 +483,10 @@ class Encyclopedia(callbacks.Plugin):
ret = "Search factoids for term: !search <term>"
target = term[1]
retmsg = term[2]
elif lower_term == "more":
if prefixed or defaultIgnored(msg.prefix):
callbacks.NestedCommandsIrcProxy(irc, msg, ["Misc", "more"])
return
elif re.match(r"^seen\b", lower_term): # Some people expect a '!seen <nick>' command
ret = "I have no seen command"
retmsg = "%s: " % msg.nick if term[2] else '' # Redirect back at the caller, rather than the target

View File

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

View File

@ -221,20 +221,29 @@ class PackageInfo(callbacks.Plugin):
if not text:
return
channel = msg.channel
if text[0] == self.registryValue("prefixchar", channel, irc.network):
prefixchar = self.registryValue("prefixchar", channel, irc.network)
prefixed = False
if text[0] == prefixchar:
text = text[1:].strip()
prefixed = True
elif re.match(r'^%s[\W\s]\s*%s' % (re.escape(irc.nick), re.escape(prefixchar)), text, re.I):
text = re.sub(r'^%s[\W\s]\s*%s\s*' % (re.escape(irc.nick), re.escape(prefixchar)), '', text, flags=re.I)
prefixed = True
elif channel or text[0] in conf.supybot.reply.whenAddressedBy.chars():
return
if not (prefixed or defaultIgnored(msg.prefix)):
return
if not text:
return
(cmd, rest) = (text.split(None, 1) + [None])[:2]
if not cmd:
return
cmd = cmd.lower()
if not (cmd in ("info", "depends", "find") and rest):
return
(package, release) = (rest.split(None, 1) + [''])[:2]
callbacks.NestedCommandsIrcProxy(irc, msg, ["PackageInfo", cmd, package, release])
if cmd in ("info", "depends", "find") and rest:
(package, release) = (rest.split(None, 1) + [''])[:2]
callbacks.NestedCommandsIrcProxy(irc, msg, ["PackageInfo", cmd, package, release])
elif cmd == "more":
callbacks.NestedCommandsIrcProxy(irc, msg, ["Misc", "more"])
def inFilter(self, irc, msg):
if not (msg.prefix and msg.args):