Various: Follow upstream bot development.

Specifically, use msg.channel and make network-aware where easily possible.

* Bugtracker
* Encyclopedia
* PackageInfo
This commit is contained in:
Krytarik Raido
2020-10-23 06:23:04 +02:00
parent fdbaa3fc36
commit 32f2c9ac3f
6 changed files with 71 additions and 74 deletions

View File

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

View File

@ -30,19 +30,16 @@ def stripNick(nick):
nick = nick[:-1]
return nick
def defaultIgnored(hostmask, recipient):
def defaultIgnored(hostmask):
if not conf.supybot.defaultIgnore():
return False
if conf.version <= '0.83.4.1' \
and ircutils.isChannel(recipient):
return False
try:
user = ircdb.users.getUser(hostmask)
except KeyError:
return True
return False
def checkIgnored(hostmask, recipient):
def checkIgnored(hostmask, channel):
try:
user = ircdb.users.getUser(hostmask)
if user._checkCapability('owner'):
@ -53,8 +50,8 @@ def checkIgnored(hostmask, recipient):
pass
if ircdb.ignores.checkIgnored(hostmask):
return True
if ircutils.isChannel(recipient):
c = ircdb.channels.getChannel(recipient)
if channel:
c = ircdb.channels.getChannel(channel)
if c.checkIgnored(hostmask):
return True
return False
@ -90,7 +87,7 @@ class PackageInfo(callbacks.Plugin):
def __getRelease(self, irc, release, channel, doError=True):
if release:
release = release.strip()
defaultRelease = self.registryValue("defaultRelease", channel)
defaultRelease = self.registryValue("defaultRelease", channel, irc.network)
if not defaultRelease:
if doError:
irc.error("'supybot.plugins.PackageInfo.defaultRelease' is not set")
@ -108,7 +105,7 @@ class PackageInfo(callbacks.Plugin):
return (package, True)
return (package, False)
def __handleRest(self, msg, target, reply, rest):
def __handleRest(self, irc, msg, target, reply, rest):
targeto = target
prefix = ''
if rest[0] == '|':
@ -126,7 +123,7 @@ class PackageInfo(callbacks.Plugin):
target = msg.nick
prefix = "<%s> wants you to know: " % msg.nick
if target.lower() != targeto.lower() and ircutils.isChannel(target):
if target.lower() != targeto.lower() and irc.isChannel(target):
target = targeto
prefix = "(Forwarding to channels is not permitted) "
elif msg.nick.lower() in (target.lower(), prefix[:-2].lower()) \
@ -141,8 +138,8 @@ class PackageInfo(callbacks.Plugin):
Look up information for <package>, optionally in <release>
"""
channel = msg.args[0] if ircutils.isChannel(msg.args[0]) else None
if not self.registryValue("enabled", channel):
channel = msg.channel
if not self.registryValue("enabled", channel, irc.network):
return
(release, rest) = self.__getRelease(irc, release, channel)
if not release:
@ -151,7 +148,7 @@ class PackageInfo(callbacks.Plugin):
target = ircutils.replyTo(msg)
reply = self.Apt.info(package, release, isSource)
if rest:
(target, reply) = self.__handleRest(msg, target, reply, rest)
(target, reply) = self.__handleRest(irc, msg, target, reply, rest)
queue(irc, target, reply)
info = wrap(real_info, ['anything', optional('text')])
@ -160,8 +157,8 @@ class PackageInfo(callbacks.Plugin):
Look up dependencies for <package>, optionally in <release>
"""
channel = msg.args[0] if ircutils.isChannel(msg.args[0]) else None
if not self.registryValue("enabled", channel):
channel = msg.channel
if not self.registryValue("enabled", channel, irc.network):
return
(release, rest) = self.__getRelease(irc, release, channel)
if not release:
@ -170,7 +167,7 @@ class PackageInfo(callbacks.Plugin):
target = ircutils.replyTo(msg)
reply = self.Apt.depends(package, release, isSource)
if rest:
(target, reply) = self.__handleRest(msg, target, reply, rest)
(target, reply) = self.__handleRest(irc, msg, target, reply, rest)
queue(irc, target, reply)
depends = wrap(real_depends, ['anything', optional('text')])
@ -180,8 +177,8 @@ class PackageInfo(callbacks.Plugin):
Search for <package> or, if that fails, <filename> in packages,
optionally in <release>
"""
channel = msg.args[0] if ircutils.isChannel(msg.args[0]) else None
if not self.registryValue("enabled", channel):
channel = msg.channel
if not self.registryValue("enabled", channel, irc.network):
return
(release, rest) = self.__getRelease(irc, release, channel)
if not release:
@ -189,7 +186,7 @@ class PackageInfo(callbacks.Plugin):
target = ircutils.replyTo(msg)
reply = self.Apt.find(package, release)
if rest:
(target, reply) = self.__handleRest(msg, target, reply, rest)
(target, reply) = self.__handleRest(irc, msg, target, reply, rest)
queue(irc, target, reply)
find = wrap(real_find, ['anything', optional('text')])
@ -199,8 +196,8 @@ class PackageInfo(callbacks.Plugin):
text = msg.args[1].strip()
if not text:
return
channel = msg.args[0] if ircutils.isChannel(msg.args[0]) else None
if text[0] == self.registryValue("prefixchar", channel):
channel = msg.channel
if text[0] == self.registryValue("prefixchar", channel, irc.network):
text = text[1:].strip()
elif channel or text[0] in conf.supybot.reply.whenAddressedBy.chars():
return
@ -221,9 +218,9 @@ class PackageInfo(callbacks.Plugin):
return msg
if not ircutils.isUserHostmask(msg.prefix):
return msg
if not defaultIgnored(msg.prefix, msg.args[0]):
if not defaultIgnored(msg.prefix):
return msg
if checkIgnored(msg.prefix, msg.args[0]):
if checkIgnored(msg.prefix, msg.channel):
return msg
if msg.command == "PRIVMSG":
self.doPrivmsg(irc, msg)