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

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

View File

@ -33,19 +33,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'):
@ -56,8 +53,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
@ -219,7 +216,7 @@ class Encyclopedia(callbacks.Plugin):
irc.reply(', '.join([u.name for u in list(ircdb.users.users.values()) if capab(u.name, 'addeditors')]), private=True)
moderators = wrap(moderators)
def get_target(self, nick, text, target):
def get_target(self, irc, nick, text, target):
ret, retmsg = text, ''
orig_target = target
@ -254,7 +251,7 @@ class Encyclopedia(callbacks.Plugin):
target = nick
retmsg = "<%s> wants you to know: " % nick
if target.lower() != orig_target.lower() and ircutils.isChannel(target):
if target.lower() != orig_target.lower() and irc.isChannel(target):
target = orig_target
retmsg = "(Forwarding to channels is not permitted) "
elif nick.lower() in (target.lower(), retmsg[:-2].lower()) \
@ -388,9 +385,9 @@ class Encyclopedia(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)
@ -414,7 +411,7 @@ class Encyclopedia(callbacks.Plugin):
if not text:
return
target = msg.args[0]
channel = target if ircutils.isChannel(target) else None
channel = msg.channel
if checkAddressed(text, channel):
return
@ -457,7 +454,7 @@ class Encyclopedia(callbacks.Plugin):
# Now switch between actions
ret, retmsg = '', ''
term = self.get_target(msg.nick, text, target)
term = self.get_target(irc, msg.nick, text, target)
lower_term = term[0].lower()
if re.match(r"please\s+see\s+((%s|(the\s+)?bot)(\s*'?s)?\s+\S+|\S+.*\s+\S+\s+(%s|(the\s+)?bot)\b)" % (re.escape(irc.nick), re.escape(irc.nick)), text, re.I):
@ -546,7 +543,7 @@ class Encyclopedia(callbacks.Plugin):
if retmsg and checkUrl(retmsg):
# !ops factoid called with a URL, most likely spam
return
if doChanMsg and channel and not ircutils.isChannel(target) \
if doChanMsg and channel and not irc.isChannel(target) \
and target in irc.state.channels[channel].users:
myqueue(irc, channel, "%s: Please see my private message" % target)
myqueue(irc, target, retmsg + ret[0])