Various: Follow upstream bot development.
Specifically, use msg.channel and make network-aware where easily possible. * Bugtracker * Encyclopedia * PackageInfo
This commit is contained in:
@ -24,7 +24,7 @@ import supybot.world as world
|
|||||||
|
|
||||||
from imp import reload
|
from imp import reload
|
||||||
|
|
||||||
__version__ = "4.4.0"
|
__version__ = "4.5.0"
|
||||||
__author__ = supybot.Author("Krytarik Raido", "krytarik", "krytarik@tuxgarage.com")
|
__author__ = supybot.Author("Krytarik Raido", "krytarik", "krytarik@tuxgarage.com")
|
||||||
__contributors__ = {
|
__contributors__ = {
|
||||||
supybot.Author("Dennis Kaarsemaker", "Seveas", "dennis@kaarsemaker.net"): ['Original Author'],
|
supybot.Author("Dennis Kaarsemaker", "Seveas", "dennis@kaarsemaker.net"): ['Original Author'],
|
||||||
|
@ -30,19 +30,16 @@ from .config import registerBugtracker, default_bugtrackers
|
|||||||
from .trackers import defined_bugtrackers
|
from .trackers import defined_bugtrackers
|
||||||
from . import trackers
|
from . import trackers
|
||||||
|
|
||||||
def defaultIgnored(hostmask, recipient):
|
def defaultIgnored(hostmask):
|
||||||
if not conf.supybot.defaultIgnore():
|
if not conf.supybot.defaultIgnore():
|
||||||
return False
|
return False
|
||||||
if conf.version <= '0.83.4.1' \
|
|
||||||
and ircutils.isChannel(recipient):
|
|
||||||
return False
|
|
||||||
try:
|
try:
|
||||||
user = ircdb.users.getUser(hostmask)
|
user = ircdb.users.getUser(hostmask)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def checkIgnored(hostmask, recipient):
|
def checkIgnored(hostmask, channel):
|
||||||
try:
|
try:
|
||||||
user = ircdb.users.getUser(hostmask)
|
user = ircdb.users.getUser(hostmask)
|
||||||
if user._checkCapability('owner'):
|
if user._checkCapability('owner'):
|
||||||
@ -53,8 +50,8 @@ def checkIgnored(hostmask, recipient):
|
|||||||
pass
|
pass
|
||||||
if ircdb.ignores.checkIgnored(hostmask):
|
if ircdb.ignores.checkIgnored(hostmask):
|
||||||
return True
|
return True
|
||||||
if ircutils.isChannel(recipient):
|
if channel:
|
||||||
c = ircdb.channels.getChannel(recipient)
|
c = ircdb.channels.getChannel(channel)
|
||||||
if c.checkIgnored(hostmask):
|
if c.checkIgnored(hostmask):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@ -97,11 +94,11 @@ class Bugtracker(callbacks.PluginRegexp):
|
|||||||
supylog.warning("Bugtracker: Unknown trackertype '%s' (%s)" % (trackers[name].trackertype(), name))
|
supylog.warning("Bugtracker: Unknown trackertype '%s' (%s)" % (trackers[name].trackertype(), name))
|
||||||
self.shorthand = utils.abbrev(list(self.db.keys()))
|
self.shorthand = utils.abbrev(list(self.db.keys()))
|
||||||
|
|
||||||
def is_ok(self, channel, tracker, bugid):
|
def is_ok(self, channel, network, tracker, bugid):
|
||||||
"""Flood/repeat protection"""
|
"""Flood/repeat protection"""
|
||||||
now = time.time()
|
now = time.time()
|
||||||
for k in list(self.shown.keys()):
|
for k in list(self.shown.keys()):
|
||||||
if self.shown[k] < now - self.registryValue('repeatdelay', channel):
|
if self.shown[k] < now - self.registryValue('repeatdelay', channel, network):
|
||||||
self.shown.pop(k)
|
self.shown.pop(k)
|
||||||
if (channel, tracker, bugid) not in self.shown:
|
if (channel, tracker, bugid) not in self.shown:
|
||||||
self.shown[(channel, tracker, bugid)] = now
|
self.shown[(channel, tracker, bugid)] = now
|
||||||
@ -152,7 +149,7 @@ class Bugtracker(callbacks.PluginRegexp):
|
|||||||
self.shorthand = utils.abbrev(list(self.db.keys()))
|
self.shorthand = utils.abbrev(list(self.db.keys()))
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
s = self.registryValue('replyNoBugtracker', msg.args[0] if ircutils.isChannel(msg.args[0]) else None)
|
s = self.registryValue('replyNoBugtracker', msg.channel, irc.network)
|
||||||
irc.error(s % name)
|
irc.error(s % name)
|
||||||
remove = wrap(remove, [('checkCapability', 'admin'), 'text'])
|
remove = wrap(remove, [('checkCapability', 'admin'), 'text'])
|
||||||
|
|
||||||
@ -181,7 +178,7 @@ class Bugtracker(callbacks.PluginRegexp):
|
|||||||
self.aliases[a] = newname
|
self.aliases[a] = newname
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
s = self.registryValue('replyNoBugtracker', msg.args[0] if ircutils.isChannel(msg.args[0]) else None)
|
s = self.registryValue('replyNoBugtracker', msg.channel, irc.network)
|
||||||
irc.error(s % oldname)
|
irc.error(s % oldname)
|
||||||
rename = wrap(rename, [('checkCapability', 'admin'), 'something', 'something', additional('text')])
|
rename = wrap(rename, [('checkCapability', 'admin'), 'something', 'something', additional('text')])
|
||||||
|
|
||||||
@ -207,7 +204,7 @@ class Bugtracker(callbacks.PluginRegexp):
|
|||||||
self.aliases[alias] = name
|
self.aliases[alias] = name
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
s = self.registryValue('replyNoBugtracker', msg.args[0] if ircutils.isChannel(msg.args[0]) else None)
|
s = self.registryValue('replyNoBugtracker', msg.channel, irc.network)
|
||||||
irc.error(s % name)
|
irc.error(s % name)
|
||||||
alias = wrap(alias, [('checkCapability', 'admin'), 'something', additional('text')])
|
alias = wrap(alias, [('checkCapability', 'admin'), 'something', additional('text')])
|
||||||
|
|
||||||
@ -230,7 +227,7 @@ class Bugtracker(callbacks.PluginRegexp):
|
|||||||
irc.error("Bugtracker '%s' has no alias '%s' set" % (name, alias))
|
irc.error("Bugtracker '%s' has no alias '%s' set" % (name, alias))
|
||||||
return
|
return
|
||||||
except KeyError:
|
except KeyError:
|
||||||
s = self.registryValue('replyNoBugtracker', msg.args[0] if ircutils.isChannel(msg.args[0]) else None)
|
s = self.registryValue('replyNoBugtracker', msg.channel, irc.network)
|
||||||
irc.error(s % name)
|
irc.error(s % name)
|
||||||
unalias = wrap(unalias, [('checkCapability', 'admin'), 'something', 'something'])
|
unalias = wrap(unalias, [('checkCapability', 'admin'), 'something', 'something'])
|
||||||
|
|
||||||
@ -247,7 +244,7 @@ class Bugtracker(callbacks.PluginRegexp):
|
|||||||
irc.reply('%s%s: %s, %s [%s]' % (name, ' (%s)' % ', '.join(sorted(tracker.aliases)) if tracker.aliases else '',
|
irc.reply('%s%s: %s, %s [%s]' % (name, ' (%s)' % ', '.join(sorted(tracker.aliases)) if tracker.aliases else '',
|
||||||
tracker.description, tracker.url, tracker.__class__.__name__))
|
tracker.description, tracker.url, tracker.__class__.__name__))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
s = self.registryValue('replyNoBugtracker', msg.args[0] if ircutils.isChannel(msg.args[0]) else None)
|
s = self.registryValue('replyNoBugtracker', msg.channel, irc.network)
|
||||||
irc.error(s % name)
|
irc.error(s % name)
|
||||||
else:
|
else:
|
||||||
if self.db:
|
if self.db:
|
||||||
@ -283,7 +280,7 @@ class Bugtracker(callbacks.PluginRegexp):
|
|||||||
supylog.warning("Bugtracker: Unknown trackertype '%s' (%s)" % (trackers[name].trackertype(), name))
|
supylog.warning("Bugtracker: Unknown trackertype '%s' (%s)" % (trackers[name].trackertype(), name))
|
||||||
self.shorthand = utils.abbrev(list(self.db.keys()))
|
self.shorthand = utils.abbrev(list(self.db.keys()))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
s = self.registryValue('replyNoBugtracker', msg.args[0] if ircutils.isChannel(msg.args[0]) else None)
|
s = self.registryValue('replyNoBugtracker', msg.channel, irc.network)
|
||||||
irc.error(s % name)
|
irc.error(s % name)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
@ -300,9 +297,9 @@ class Bugtracker(callbacks.PluginRegexp):
|
|||||||
return msg
|
return msg
|
||||||
if not ircutils.isUserHostmask(msg.prefix):
|
if not ircutils.isUserHostmask(msg.prefix):
|
||||||
return msg
|
return msg
|
||||||
if not defaultIgnored(msg.prefix, msg.args[0]):
|
if not defaultIgnored(msg.prefix):
|
||||||
return msg
|
return msg
|
||||||
if checkIgnored(msg.prefix, msg.args[0]):
|
if checkIgnored(msg.prefix, msg.channel):
|
||||||
return msg
|
return msg
|
||||||
if msg.command == 'PRIVMSG':
|
if msg.command == 'PRIVMSG':
|
||||||
self.doPrivmsg(irc, msg)
|
self.doPrivmsg(irc, msg)
|
||||||
@ -317,7 +314,7 @@ class Bugtracker(callbacks.PluginRegexp):
|
|||||||
self.termSnarfer(irc, msg, match, 'commit')
|
self.termSnarfer(irc, msg, match, 'commit')
|
||||||
|
|
||||||
def termSnarfer(self, irc, msg, match, termtype):
|
def termSnarfer(self, irc, msg, match, termtype):
|
||||||
channel = msg.args[0] if ircutils.isChannel(msg.args[0]) else None
|
channel = msg.channel
|
||||||
if checkAddressed(msg.args[1].strip(), channel):
|
if checkAddressed(msg.args[1].strip(), channel):
|
||||||
return
|
return
|
||||||
if not self.registryValue('{}Snarfer'.format(termtype), channel):
|
if not self.registryValue('{}Snarfer'.format(termtype), channel):
|
||||||
@ -378,7 +375,7 @@ class Bugtracker(callbacks.PluginRegexp):
|
|||||||
|
|
||||||
if not name:
|
if not name:
|
||||||
showTracker = False
|
showTracker = False
|
||||||
snarfTarget = self.registryValue('snarfTarget', channel)
|
snarfTarget = self.registryValue('snarfTarget', channel, irc.network)
|
||||||
if not snarfTarget:
|
if not snarfTarget:
|
||||||
supylog.warning("Bugtracker: No snarfTarget set")
|
supylog.warning("Bugtracker: No snarfTarget set")
|
||||||
return
|
return
|
||||||
@ -386,14 +383,16 @@ class Bugtracker(callbacks.PluginRegexp):
|
|||||||
name = self.shorthand[snarfTarget.lower()]
|
name = self.shorthand[snarfTarget.lower()]
|
||||||
tracker = self.db[name]
|
tracker = self.db[name]
|
||||||
except:
|
except:
|
||||||
s = self.registryValue('replyNoBugtracker', channel)
|
s = self.registryValue('replyNoBugtracker', channel, irc.network)
|
||||||
irc.error(s % (name or snarfTarget))
|
irc.error(s % (name or snarfTarget))
|
||||||
return
|
return
|
||||||
|
|
||||||
for bugid in bugids:
|
for bugid in bugids:
|
||||||
try:
|
try:
|
||||||
report = self.get_bug(channel or msg.nick, tracker, bugtype, bugid, self.registryValue('showassignee', channel),
|
report = self.get_bug(channel or msg.nick, irc.network, tracker, bugtype, bugid,
|
||||||
self.registryValue('extended', channel), do_tracker=showTracker)
|
self.registryValue('showassignee', channel, irc.network),
|
||||||
|
self.registryValue('extended', channel, irc.network),
|
||||||
|
do_tracker=showTracker)
|
||||||
except trackers.BugNotFoundError:
|
except trackers.BugNotFoundError:
|
||||||
if self.registryValue('replyWhenNotFound'):
|
if self.registryValue('replyWhenNotFound'):
|
||||||
irc.error("Could not find %s %s %s" % (tracker.description, termtype, bugid))
|
irc.error("Could not find %s %s %s" % (tracker.description, termtype, bugid))
|
||||||
@ -413,7 +412,7 @@ class Bugtracker(callbacks.PluginRegexp):
|
|||||||
self.urlSnarfer(irc, msg, match, 'commit')
|
self.urlSnarfer(irc, msg, match, 'commit')
|
||||||
|
|
||||||
def urlSnarfer(self, irc, msg, match, urltype):
|
def urlSnarfer(self, irc, msg, match, urltype):
|
||||||
channel = msg.args[0] if ircutils.isChannel(msg.args[0]) else None
|
channel = msg.channel
|
||||||
if checkAddressed(msg.args[1].strip(), channel):
|
if checkAddressed(msg.args[1].strip(), channel):
|
||||||
return
|
return
|
||||||
if not self.registryValue('{}Snarfer'.format(urltype), channel):
|
if not self.registryValue('{}Snarfer'.format(urltype), channel):
|
||||||
@ -430,8 +429,10 @@ class Bugtracker(callbacks.PluginRegexp):
|
|||||||
tracker = self.get_tracker(url, bugid)
|
tracker = self.get_tracker(url, bugid)
|
||||||
if not tracker:
|
if not tracker:
|
||||||
return
|
return
|
||||||
report = self.get_bug(channel or msg.nick, tracker, 'url', bugid, self.registryValue('showassignee', channel),
|
report = self.get_bug(channel or msg.nick, irc.network, tracker, 'url', bugid,
|
||||||
self.registryValue('extended', channel), do_url=False)
|
self.registryValue('showassignee', channel, irc.network),
|
||||||
|
self.registryValue('extended', channel, irc.network),
|
||||||
|
do_url=False)
|
||||||
except trackers.BugNotFoundError:
|
except trackers.BugNotFoundError:
|
||||||
if self.registryValue('replyWhenNotFound'):
|
if self.registryValue('replyWhenNotFound'):
|
||||||
irc.error("Could not find %s %s %s" % (tracker.description, urltype, match.group('bug')))
|
irc.error("Could not find %s %s %s" % (tracker.description, urltype, match.group('bug')))
|
||||||
@ -445,26 +446,28 @@ class Bugtracker(callbacks.PluginRegexp):
|
|||||||
# Only useful to Launchpad developers
|
# Only useful to Launchpad developers
|
||||||
def oopsSnarfer(self, irc, msg, match):
|
def oopsSnarfer(self, irc, msg, match):
|
||||||
r"(https?://\S+[=/])?OOPS-(?P<oopsid>[a-f0-9]{6,})"
|
r"(https?://\S+[=/])?OOPS-(?P<oopsid>[a-f0-9]{6,})"
|
||||||
channel = msg.args[0] if ircutils.isChannel(msg.args[0]) else None
|
channel = msg.channel
|
||||||
if checkAddressed(msg.args[1].strip(), channel):
|
if checkAddressed(msg.args[1].strip(), channel):
|
||||||
return
|
return
|
||||||
if not (self.registryValue('bugSnarfer', channel) and self.registryValue('oopsSnarfer', channel)):
|
if not (self.registryValue('bugSnarfer', channel, irc.network) \
|
||||||
|
and self.registryValue('oopsSnarfer', channel, irc.network)):
|
||||||
return
|
return
|
||||||
oopsid = match.group('oopsid')
|
oopsid = match.group('oopsid')
|
||||||
if not self.is_ok(channel or msg.nick, 'lpoops', oopsid):
|
if not self.is_ok(channel or msg.nick, irc.network, 'lpoops', oopsid):
|
||||||
return
|
return
|
||||||
if not match.group(1):
|
if not match.group(1):
|
||||||
irc.reply('https://oops.canonical.com/?oopsid=OOPS-%s' % oopsid)
|
irc.reply('https://oops.canonical.com/?oopsid=OOPS-%s' % oopsid)
|
||||||
|
|
||||||
def cveSnarfer(self, irc, msg, match):
|
def cveSnarfer(self, irc, msg, match):
|
||||||
r"(https?://\S+=)?CVE[- ](?P<cveid>\d{4}[- ]\d{4,})"
|
r"(https?://\S+=)?CVE[- ](?P<cveid>\d{4}[- ]\d{4,})"
|
||||||
channel = msg.args[0] if ircutils.isChannel(msg.args[0]) else None
|
channel = msg.channel
|
||||||
if checkAddressed(msg.args[1].strip(), channel):
|
if checkAddressed(msg.args[1].strip(), channel):
|
||||||
return
|
return
|
||||||
if not (self.registryValue('bugSnarfer', channel) and self.registryValue('cveSnarfer', channel)):
|
if not (self.registryValue('bugSnarfer', channel, irc.network) \
|
||||||
|
and self.registryValue('cveSnarfer', channel, irc.network)):
|
||||||
return
|
return
|
||||||
cveid = match.group('cveid').replace(' ','-')
|
cveid = match.group('cveid').replace(' ','-')
|
||||||
if not self.is_ok(channel or msg.nick, 'cve', cveid):
|
if not self.is_ok(channel or msg.nick, irc.network, 'cve', cveid):
|
||||||
return
|
return
|
||||||
if not match.group(1):
|
if not match.group(1):
|
||||||
do_url = True
|
do_url = True
|
||||||
@ -530,8 +533,8 @@ class Bugtracker(callbacks.PluginRegexp):
|
|||||||
self.shorthand = utils.abbrev(list(self.db.keys()))
|
self.shorthand = utils.abbrev(list(self.db.keys()))
|
||||||
return tracker
|
return tracker
|
||||||
|
|
||||||
def get_bug(self, channel, tracker, bugtype, bugid, do_assignee, do_extinfo, do_url=True, do_tracker=True):
|
def get_bug(self, channel, network, tracker, bugtype, bugid, do_assignee, do_extinfo, do_url=True, do_tracker=True):
|
||||||
if not self.is_ok(channel, tracker, bugid):
|
if not self.is_ok(channel, network, tracker, bugid):
|
||||||
return
|
return
|
||||||
|
|
||||||
bugdata = tracker.get_bug(bugtype, bugid)
|
bugdata = tracker.get_bug(bugtype, bugid)
|
||||||
@ -540,7 +543,7 @@ class Bugtracker(callbacks.PluginRegexp):
|
|||||||
|
|
||||||
(bugid, product, title, severity, status, assignee, url, extinfo, duplicate) = bugdata
|
(bugid, product, title, severity, status, assignee, url, extinfo, duplicate) = bugdata
|
||||||
|
|
||||||
if duplicate and not self.is_ok(channel, tracker, bugid):
|
if duplicate and not self.is_ok(channel, network, tracker, bugid):
|
||||||
return
|
return
|
||||||
|
|
||||||
bugtype = re.match(r'\S+/(feature-)?(?P<type>request|patch|todo|issue|pull|merge|ticket|commit)(_requests)?(e?s)?/([^\s?]*\?([^\s?&]+&)?id=)?[a-f0-9]+$', url)
|
bugtype = re.match(r'\S+/(feature-)?(?P<type>request|patch|todo|issue|pull|merge|ticket|commit)(_requests)?(e?s)?/([^\s?]*\?([^\s?&]+&)?id=)?[a-f0-9]+$', url)
|
||||||
|
@ -24,7 +24,7 @@ import supybot
|
|||||||
import supybot.world as world
|
import supybot.world as world
|
||||||
from imp import reload
|
from imp import reload
|
||||||
|
|
||||||
__version__ = "2.8"
|
__version__ = "2.9"
|
||||||
__author__ = supybot.Author("Krytarik Raido", "krytarik", "krytarik@tuxgarage.com")
|
__author__ = supybot.Author("Krytarik Raido", "krytarik", "krytarik@tuxgarage.com")
|
||||||
__contributors__ = {
|
__contributors__ = {
|
||||||
supybot.Author("Dennis Kaarsemaker", "Seveas", "dennis@kaarsemaker.net"): ['Original Author'],
|
supybot.Author("Dennis Kaarsemaker", "Seveas", "dennis@kaarsemaker.net"): ['Original Author'],
|
||||||
|
@ -33,19 +33,16 @@ def stripNick(nick):
|
|||||||
nick = nick[:-1]
|
nick = nick[:-1]
|
||||||
return nick
|
return nick
|
||||||
|
|
||||||
def defaultIgnored(hostmask, recipient):
|
def defaultIgnored(hostmask):
|
||||||
if not conf.supybot.defaultIgnore():
|
if not conf.supybot.defaultIgnore():
|
||||||
return False
|
return False
|
||||||
if conf.version <= '0.83.4.1' \
|
|
||||||
and ircutils.isChannel(recipient):
|
|
||||||
return False
|
|
||||||
try:
|
try:
|
||||||
user = ircdb.users.getUser(hostmask)
|
user = ircdb.users.getUser(hostmask)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def checkIgnored(hostmask, recipient):
|
def checkIgnored(hostmask, channel):
|
||||||
try:
|
try:
|
||||||
user = ircdb.users.getUser(hostmask)
|
user = ircdb.users.getUser(hostmask)
|
||||||
if user._checkCapability('owner'):
|
if user._checkCapability('owner'):
|
||||||
@ -56,8 +53,8 @@ def checkIgnored(hostmask, recipient):
|
|||||||
pass
|
pass
|
||||||
if ircdb.ignores.checkIgnored(hostmask):
|
if ircdb.ignores.checkIgnored(hostmask):
|
||||||
return True
|
return True
|
||||||
if ircutils.isChannel(recipient):
|
if channel:
|
||||||
c = ircdb.channels.getChannel(recipient)
|
c = ircdb.channels.getChannel(channel)
|
||||||
if c.checkIgnored(hostmask):
|
if c.checkIgnored(hostmask):
|
||||||
return True
|
return True
|
||||||
return False
|
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)
|
irc.reply(', '.join([u.name for u in list(ircdb.users.users.values()) if capab(u.name, 'addeditors')]), private=True)
|
||||||
moderators = wrap(moderators)
|
moderators = wrap(moderators)
|
||||||
|
|
||||||
def get_target(self, nick, text, target):
|
def get_target(self, irc, nick, text, target):
|
||||||
ret, retmsg = text, ''
|
ret, retmsg = text, ''
|
||||||
orig_target = target
|
orig_target = target
|
||||||
|
|
||||||
@ -254,7 +251,7 @@ class Encyclopedia(callbacks.Plugin):
|
|||||||
target = nick
|
target = nick
|
||||||
retmsg = "<%s> wants you to know: " % 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
|
target = orig_target
|
||||||
retmsg = "(Forwarding to channels is not permitted) "
|
retmsg = "(Forwarding to channels is not permitted) "
|
||||||
elif nick.lower() in (target.lower(), retmsg[:-2].lower()) \
|
elif nick.lower() in (target.lower(), retmsg[:-2].lower()) \
|
||||||
@ -388,9 +385,9 @@ class Encyclopedia(callbacks.Plugin):
|
|||||||
return msg
|
return msg
|
||||||
if not ircutils.isUserHostmask(msg.prefix):
|
if not ircutils.isUserHostmask(msg.prefix):
|
||||||
return msg
|
return msg
|
||||||
if not defaultIgnored(msg.prefix, msg.args[0]):
|
if not defaultIgnored(msg.prefix):
|
||||||
return msg
|
return msg
|
||||||
if checkIgnored(msg.prefix, msg.args[0]):
|
if checkIgnored(msg.prefix, msg.channel):
|
||||||
return msg
|
return msg
|
||||||
if msg.command == "PRIVMSG":
|
if msg.command == "PRIVMSG":
|
||||||
self.doPrivmsg(irc, msg)
|
self.doPrivmsg(irc, msg)
|
||||||
@ -414,7 +411,7 @@ class Encyclopedia(callbacks.Plugin):
|
|||||||
if not text:
|
if not text:
|
||||||
return
|
return
|
||||||
target = msg.args[0]
|
target = msg.args[0]
|
||||||
channel = target if ircutils.isChannel(target) else None
|
channel = msg.channel
|
||||||
|
|
||||||
if checkAddressed(text, channel):
|
if checkAddressed(text, channel):
|
||||||
return
|
return
|
||||||
@ -457,7 +454,7 @@ class Encyclopedia(callbacks.Plugin):
|
|||||||
|
|
||||||
# Now switch between actions
|
# Now switch between actions
|
||||||
ret, retmsg = '', ''
|
ret, retmsg = '', ''
|
||||||
term = self.get_target(msg.nick, text, target)
|
term = self.get_target(irc, msg.nick, text, target)
|
||||||
lower_term = term[0].lower()
|
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):
|
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):
|
if retmsg and checkUrl(retmsg):
|
||||||
# !ops factoid called with a URL, most likely spam
|
# !ops factoid called with a URL, most likely spam
|
||||||
return
|
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:
|
and target in irc.state.channels[channel].users:
|
||||||
myqueue(irc, channel, "%s: Please see my private message" % target)
|
myqueue(irc, channel, "%s: Please see my private message" % target)
|
||||||
myqueue(irc, target, retmsg + ret[0])
|
myqueue(irc, target, retmsg + ret[0])
|
||||||
|
@ -22,7 +22,7 @@ import supybot
|
|||||||
import supybot.world as world
|
import supybot.world as world
|
||||||
from imp import reload
|
from imp import reload
|
||||||
|
|
||||||
__version__ = "1.6.0"
|
__version__ = "1.7.0"
|
||||||
__author__ = supybot.Author("Krytarik Raido", "krytarik", "krytarik@tuxgarage.com")
|
__author__ = supybot.Author("Krytarik Raido", "krytarik", "krytarik@tuxgarage.com")
|
||||||
__contributors__ = {
|
__contributors__ = {
|
||||||
supybot.Author("Dennis Kaarsemaker", "Seveas", "dennis@kaarsemaker.net"): ['Original Concept'],
|
supybot.Author("Dennis Kaarsemaker", "Seveas", "dennis@kaarsemaker.net"): ['Original Concept'],
|
||||||
|
@ -30,19 +30,16 @@ def stripNick(nick):
|
|||||||
nick = nick[:-1]
|
nick = nick[:-1]
|
||||||
return nick
|
return nick
|
||||||
|
|
||||||
def defaultIgnored(hostmask, recipient):
|
def defaultIgnored(hostmask):
|
||||||
if not conf.supybot.defaultIgnore():
|
if not conf.supybot.defaultIgnore():
|
||||||
return False
|
return False
|
||||||
if conf.version <= '0.83.4.1' \
|
|
||||||
and ircutils.isChannel(recipient):
|
|
||||||
return False
|
|
||||||
try:
|
try:
|
||||||
user = ircdb.users.getUser(hostmask)
|
user = ircdb.users.getUser(hostmask)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def checkIgnored(hostmask, recipient):
|
def checkIgnored(hostmask, channel):
|
||||||
try:
|
try:
|
||||||
user = ircdb.users.getUser(hostmask)
|
user = ircdb.users.getUser(hostmask)
|
||||||
if user._checkCapability('owner'):
|
if user._checkCapability('owner'):
|
||||||
@ -53,8 +50,8 @@ def checkIgnored(hostmask, recipient):
|
|||||||
pass
|
pass
|
||||||
if ircdb.ignores.checkIgnored(hostmask):
|
if ircdb.ignores.checkIgnored(hostmask):
|
||||||
return True
|
return True
|
||||||
if ircutils.isChannel(recipient):
|
if channel:
|
||||||
c = ircdb.channels.getChannel(recipient)
|
c = ircdb.channels.getChannel(channel)
|
||||||
if c.checkIgnored(hostmask):
|
if c.checkIgnored(hostmask):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@ -90,7 +87,7 @@ class PackageInfo(callbacks.Plugin):
|
|||||||
def __getRelease(self, irc, release, channel, doError=True):
|
def __getRelease(self, irc, release, channel, doError=True):
|
||||||
if release:
|
if release:
|
||||||
release = release.strip()
|
release = release.strip()
|
||||||
defaultRelease = self.registryValue("defaultRelease", channel)
|
defaultRelease = self.registryValue("defaultRelease", channel, irc.network)
|
||||||
if not defaultRelease:
|
if not defaultRelease:
|
||||||
if doError:
|
if doError:
|
||||||
irc.error("'supybot.plugins.PackageInfo.defaultRelease' is not set")
|
irc.error("'supybot.plugins.PackageInfo.defaultRelease' is not set")
|
||||||
@ -108,7 +105,7 @@ class PackageInfo(callbacks.Plugin):
|
|||||||
return (package, True)
|
return (package, True)
|
||||||
return (package, False)
|
return (package, False)
|
||||||
|
|
||||||
def __handleRest(self, msg, target, reply, rest):
|
def __handleRest(self, irc, msg, target, reply, rest):
|
||||||
targeto = target
|
targeto = target
|
||||||
prefix = ''
|
prefix = ''
|
||||||
if rest[0] == '|':
|
if rest[0] == '|':
|
||||||
@ -126,7 +123,7 @@ class PackageInfo(callbacks.Plugin):
|
|||||||
target = msg.nick
|
target = msg.nick
|
||||||
prefix = "<%s> wants you to know: " % 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
|
target = targeto
|
||||||
prefix = "(Forwarding to channels is not permitted) "
|
prefix = "(Forwarding to channels is not permitted) "
|
||||||
elif msg.nick.lower() in (target.lower(), prefix[:-2].lower()) \
|
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>
|
Look up information for <package>, optionally in <release>
|
||||||
"""
|
"""
|
||||||
channel = msg.args[0] if ircutils.isChannel(msg.args[0]) else None
|
channel = msg.channel
|
||||||
if not self.registryValue("enabled", channel):
|
if not self.registryValue("enabled", channel, irc.network):
|
||||||
return
|
return
|
||||||
(release, rest) = self.__getRelease(irc, release, channel)
|
(release, rest) = self.__getRelease(irc, release, channel)
|
||||||
if not release:
|
if not release:
|
||||||
@ -151,7 +148,7 @@ class PackageInfo(callbacks.Plugin):
|
|||||||
target = ircutils.replyTo(msg)
|
target = ircutils.replyTo(msg)
|
||||||
reply = self.Apt.info(package, release, isSource)
|
reply = self.Apt.info(package, release, isSource)
|
||||||
if rest:
|
if rest:
|
||||||
(target, reply) = self.__handleRest(msg, target, reply, rest)
|
(target, reply) = self.__handleRest(irc, msg, target, reply, rest)
|
||||||
queue(irc, target, reply)
|
queue(irc, target, reply)
|
||||||
info = wrap(real_info, ['anything', optional('text')])
|
info = wrap(real_info, ['anything', optional('text')])
|
||||||
|
|
||||||
@ -160,8 +157,8 @@ class PackageInfo(callbacks.Plugin):
|
|||||||
|
|
||||||
Look up dependencies for <package>, optionally in <release>
|
Look up dependencies for <package>, optionally in <release>
|
||||||
"""
|
"""
|
||||||
channel = msg.args[0] if ircutils.isChannel(msg.args[0]) else None
|
channel = msg.channel
|
||||||
if not self.registryValue("enabled", channel):
|
if not self.registryValue("enabled", channel, irc.network):
|
||||||
return
|
return
|
||||||
(release, rest) = self.__getRelease(irc, release, channel)
|
(release, rest) = self.__getRelease(irc, release, channel)
|
||||||
if not release:
|
if not release:
|
||||||
@ -170,7 +167,7 @@ class PackageInfo(callbacks.Plugin):
|
|||||||
target = ircutils.replyTo(msg)
|
target = ircutils.replyTo(msg)
|
||||||
reply = self.Apt.depends(package, release, isSource)
|
reply = self.Apt.depends(package, release, isSource)
|
||||||
if rest:
|
if rest:
|
||||||
(target, reply) = self.__handleRest(msg, target, reply, rest)
|
(target, reply) = self.__handleRest(irc, msg, target, reply, rest)
|
||||||
queue(irc, target, reply)
|
queue(irc, target, reply)
|
||||||
depends = wrap(real_depends, ['anything', optional('text')])
|
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,
|
Search for <package> or, if that fails, <filename> in packages,
|
||||||
optionally in <release>
|
optionally in <release>
|
||||||
"""
|
"""
|
||||||
channel = msg.args[0] if ircutils.isChannel(msg.args[0]) else None
|
channel = msg.channel
|
||||||
if not self.registryValue("enabled", channel):
|
if not self.registryValue("enabled", channel, irc.network):
|
||||||
return
|
return
|
||||||
(release, rest) = self.__getRelease(irc, release, channel)
|
(release, rest) = self.__getRelease(irc, release, channel)
|
||||||
if not release:
|
if not release:
|
||||||
@ -189,7 +186,7 @@ class PackageInfo(callbacks.Plugin):
|
|||||||
target = ircutils.replyTo(msg)
|
target = ircutils.replyTo(msg)
|
||||||
reply = self.Apt.find(package, release)
|
reply = self.Apt.find(package, release)
|
||||||
if rest:
|
if rest:
|
||||||
(target, reply) = self.__handleRest(msg, target, reply, rest)
|
(target, reply) = self.__handleRest(irc, msg, target, reply, rest)
|
||||||
queue(irc, target, reply)
|
queue(irc, target, reply)
|
||||||
find = wrap(real_find, ['anything', optional('text')])
|
find = wrap(real_find, ['anything', optional('text')])
|
||||||
|
|
||||||
@ -199,8 +196,8 @@ class PackageInfo(callbacks.Plugin):
|
|||||||
text = msg.args[1].strip()
|
text = msg.args[1].strip()
|
||||||
if not text:
|
if not text:
|
||||||
return
|
return
|
||||||
channel = msg.args[0] if ircutils.isChannel(msg.args[0]) else None
|
channel = msg.channel
|
||||||
if text[0] == self.registryValue("prefixchar", channel):
|
if text[0] == self.registryValue("prefixchar", channel, irc.network):
|
||||||
text = text[1:].strip()
|
text = text[1:].strip()
|
||||||
elif channel or text[0] in conf.supybot.reply.whenAddressedBy.chars():
|
elif channel or text[0] in conf.supybot.reply.whenAddressedBy.chars():
|
||||||
return
|
return
|
||||||
@ -221,9 +218,9 @@ class PackageInfo(callbacks.Plugin):
|
|||||||
return msg
|
return msg
|
||||||
if not ircutils.isUserHostmask(msg.prefix):
|
if not ircutils.isUserHostmask(msg.prefix):
|
||||||
return msg
|
return msg
|
||||||
if not defaultIgnored(msg.prefix, msg.args[0]):
|
if not defaultIgnored(msg.prefix):
|
||||||
return msg
|
return msg
|
||||||
if checkIgnored(msg.prefix, msg.args[0]):
|
if checkIgnored(msg.prefix, msg.channel):
|
||||||
return msg
|
return msg
|
||||||
if msg.command == "PRIVMSG":
|
if msg.command == "PRIVMSG":
|
||||||
self.doPrivmsg(irc, msg)
|
self.doPrivmsg(irc, msg)
|
||||||
|
Reference in New Issue
Block a user