Use irc.isChannel instead of ircutils.isChannel when possible.

It's aware of the network's 'chantypes'.
This commit is contained in:
Valentin Lorentz 2019-08-04 18:11:28 +02:00
parent bf7db13f01
commit 696254ff1b
18 changed files with 58 additions and 51 deletions

View File

@ -555,7 +555,7 @@ class Aka(callbacks.Plugin):
channel = 'global' channel = 'global'
for (option, arg) in optlist: for (option, arg) in optlist:
if option == 'channel': if option == 'channel':
if not ircutils.isChannel(arg): if not irc.isChannel(arg):
irc.error(_('%r is not a valid channel.') % arg, irc.error(_('%r is not a valid channel.') % arg,
Raise=True) Raise=True)
channel = arg channel = arg
@ -587,7 +587,7 @@ class Aka(callbacks.Plugin):
channel = 'global' channel = 'global'
for (option, arg) in optlist: for (option, arg) in optlist:
if option == 'channel': if option == 'channel':
if not ircutils.isChannel(arg): if not irc.isChannel(arg):
irc.error(_('%r is not a valid channel.') % arg, irc.error(_('%r is not a valid channel.') % arg,
Raise=True) Raise=True)
channel = arg channel = arg
@ -618,7 +618,7 @@ class Aka(callbacks.Plugin):
channel = 'global' channel = 'global'
for (option, arg) in optlist: for (option, arg) in optlist:
if option == 'channel': if option == 'channel':
if not ircutils.isChannel(arg): if not irc.isChannel(arg):
irc.error(_('%r is not a valid channel.') % arg, irc.error(_('%r is not a valid channel.') % arg,
Raise=True) Raise=True)
channel = arg channel = arg
@ -650,7 +650,7 @@ class Aka(callbacks.Plugin):
channel = 'global' channel = 'global'
for (option, arg) in optlist: for (option, arg) in optlist:
if option == 'channel': if option == 'channel':
if not ircutils.isChannel(arg): if not irc.isChannel(arg):
irc.error(_('%r is not a valid channel.') % arg, irc.error(_('%r is not a valid channel.') % arg,
Raise=True) Raise=True)
channel = arg channel = arg
@ -673,7 +673,7 @@ class Aka(callbacks.Plugin):
channel = 'global' channel = 'global'
for (option, arg) in optlist: for (option, arg) in optlist:
if option == 'channel': if option == 'channel':
if not ircutils.isChannel(arg): if not irc.isChannel(arg):
irc.error(_('%r is not a valid channel.') % arg, irc.error(_('%r is not a valid channel.') % arg,
Raise=True) Raise=True)
channel = arg channel = arg
@ -696,7 +696,7 @@ class Aka(callbacks.Plugin):
channel = 'global' channel = 'global'
for (option, arg) in optlist: for (option, arg) in optlist:
if option == 'channel': if option == 'channel':
if not ircutils.isChannel(arg): if not irc.isChannel(arg):
irc.error(_('%r is not a valid channel.') % arg, irc.error(_('%r is not a valid channel.') % arg,
Raise=True) Raise=True)
channel = arg channel = arg
@ -742,7 +742,7 @@ class Aka(callbacks.Plugin):
filterlocked = filterunlocked = False filterlocked = filterunlocked = False
for (option, arg) in optlist: for (option, arg) in optlist:
if option == 'channel': if option == 'channel':
if not ircutils.isChannel(arg): if not irc.isChannel(arg):
irc.error(_('%r is not a valid channel.') % arg, irc.error(_('%r is not a valid channel.') % arg,
Raise=True) Raise=True)
channel = arg channel = arg
@ -785,7 +785,7 @@ class Aka(callbacks.Plugin):
channel = 'global' channel = 'global'
for (option, arg) in optlist: for (option, arg) in optlist:
if option == 'channel': if option == 'channel':
if not ircutils.isChannel(arg): if not irc.isChannel(arg):
irc.error(_('%r is not a valid channel.') % arg, irc.error(_('%r is not a valid channel.') % arg,
Raise=True) Raise=True)
channel = arg channel = arg

View File

@ -43,13 +43,13 @@ from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Alias') _ = PluginInternationalization('Alias')
# Copied from the old privmsgs.py. # Copied from the old privmsgs.py.
def getChannel(msg, args=()): def getChannel(irc, msg, args):
"""Returns the channel the msg came over or the channel given in args. """Returns the channel the msg came over or the channel given in args.
If the channel was given in args, args is modified (the channel is If the channel was given in args, args is modified (the channel is
removed). removed).
""" """
if args and ircutils.isChannel(args[0]): if args and irc.isChannel(msg.args[0]):
if conf.supybot.reply.requireChannelCommandsToBeSentInChannel(): if conf.supybot.reply.requireChannelCommandsToBeSentInChannel():
if args[0] != msg.args[0]: if args[0] != msg.args[0]:
s = 'Channel commands must be sent in the channel to which ' \ s = 'Channel commands must be sent in the channel to which ' \
@ -60,7 +60,7 @@ def getChannel(msg, args=()):
'to False.' 'to False.'
raise callbacks.Error(s) raise callbacks.Error(s)
return args.pop(0) return args.pop(0)
elif ircutils.isChannel(msg.args[0]): elif irc.isChannel(msg.args[0]):
return msg.args[0] return msg.args[0]
else: else:
raise callbacks.Error('Command must be sent in a channel or ' \ raise callbacks.Error('Command must be sent in a channel or ' \
@ -173,7 +173,7 @@ def makeNewAlias(name, alias):
def f(self, irc, msg, args): def f(self, irc, msg, args):
alias = original.replace('$nick', msg.nick) alias = original.replace('$nick', msg.nick)
if '$channel' in original: if '$channel' in original:
channel = getChannel(msg, args) channel = getChannel(irc, msg, args)
alias = alias.replace('$channel', channel) alias = alias.replace('$channel', channel)
tokens = callbacks.tokenize(alias) tokens = callbacks.tokenize(alias)
if biggestDollar or biggestAt: if biggestDollar or biggestAt:

View File

@ -75,7 +75,7 @@ class BadWords(callbacks.Privmsg):
channel = msg.args[0] channel = msg.args[0]
self.updateRegexp(channel) self.updateRegexp(channel)
s = ircutils.stripFormatting(msg.args[1]) s = ircutils.stripFormatting(msg.args[1])
if ircutils.isChannel(channel) and self.registryValue('kick', channel): if irc.isChannel(channel) and self.registryValue('kick', channel):
if self.regexp.search(s): if self.regexp.search(s):
c = irc.state.channels[channel] c = irc.state.channels[channel]
cap = ircdb.makeChannelCapability(channel, 'op') cap = ircdb.makeChannelCapability(channel, 'op')

View File

@ -912,7 +912,7 @@ class Channel(callbacks.Plugin):
if 's' in irc.state.channels[channel].modes and \ if 's' in irc.state.channels[channel].modes and \
msg.args[0] != channel and \ msg.args[0] != channel and \
not ircdb.checkCapability(msg.prefix, capability) and \ not ircdb.checkCapability(msg.prefix, capability) and \
(ircutils.isChannel(msg.args[0]) or \ (irc.isChannel(msg.args[0]) or \
msg.nick not in irc.state.channels[channel].users): msg.nick not in irc.state.channels[channel].users):
irc.error(_('You don\'t have access to that information.'), irc.error(_('You don\'t have access to that information.'),
Raise=True) Raise=True)

View File

@ -141,8 +141,8 @@ class StatsDB(plugins.ChannelUserDB):
else: else:
return UserStat(*L) return UserStat(*L)
def addMsg(self, msg, id=None): def addMsg(self, irc, msg, id=None):
if msg.args and ircutils.isChannel(msg.args[0]): if msg.args and irc.isChannel(msg.args[0]):
channel = plugins.getChannel(msg.args[0]) channel = plugins.getChannel(msg.args[0])
if (channel, 'channelStats') not in self: if (channel, 'channelStats') not in self:
self[channel, 'channelStats'] = ChannelStat() self[channel, 'channelStats'] = ChannelStat()
@ -181,16 +181,16 @@ class ChannelStats(callbacks.Plugin):
self.__parent.die() self.__parent.die()
def __call__(self, irc, msg): def __call__(self, irc, msg):
self.db.addMsg(msg) self.db.addMsg(irc, msg)
super(ChannelStats, self).__call__(irc, msg) super(ChannelStats, self).__call__(irc, msg)
def outFilter(self, irc, msg): def outFilter(self, irc, msg):
if msg.command == 'PRIVMSG': if msg.command == 'PRIVMSG':
if ircutils.isChannel(msg.args[0]): if irc.isChannel(msg.args[0]):
if self.registryValue('selfStats', msg.args[0]): if self.registryValue('selfStats', msg.args[0]):
try: try:
self.outFiltering = True self.outFiltering = True
self.db.addMsg(msg, 0) self.db.addMsg(irc, msg, 0)
finally: finally:
self.outFiltering = False self.outFiltering = False
return msg return msg

View File

@ -63,7 +63,7 @@ def getWrapper(name):
raise registry.InvalidRegistryName(name) raise registry.InvalidRegistryName(name)
return group return group
def getCapability(name): def getCapability(irc, name):
capability = 'owner' # Default to requiring the owner capability. capability = 'owner' # Default to requiring the owner capability.
if not name.startswith('supybot') and not name.startswith('users'): if not name.startswith('supybot') and not name.startswith('users'):
name = 'supybot.' + name name = 'supybot.' + name
@ -74,7 +74,7 @@ def getCapability(name):
group = group.get(part) group = group.get(part)
if not getattr(group, '_opSettable', True): if not getattr(group, '_opSettable', True):
return 'owner' return 'owner'
if ircutils.isChannel(part): if irc.isChannel(part):
# If a registry value has a channel in it, it requires a # If a registry value has a channel in it, it requires a
# 'channel,op' capability, or so we assume. We'll see if we're # 'channel,op' capability, or so we assume. We'll see if we're
# proven wrong. # proven wrong.
@ -148,15 +148,15 @@ class Config(callbacks.Plugin):
except registry.InvalidRegistryValue as e: except registry.InvalidRegistryValue as e:
irc.error(str(e)) irc.error(str(e))
def _list(self, group): def _list(self, irc, group):
L = [] L = []
for (vname, v) in group._children.items(): for (vname, v) in group._children.items():
if hasattr(group, 'channelValue') and group.channelValue and \ if hasattr(group, 'channelValue') and group.channelValue and \
ircutils.isChannel(vname) and not v._children: irc.isChannel(vname) and not v._children:
continue continue
if hasattr(v, 'channelValue') and v.channelValue: if hasattr(v, 'channelValue') and v.channelValue:
vname = '#' + vname vname = '#' + vname
if v._added and not all(ircutils.isChannel, v._added): if v._added and not all(irc.isChannel, v._added):
vname = '@' + vname vname = '@' + vname
L.append(vname) L.append(vname)
utils.sortBy(str.lower, L) utils.sortBy(str.lower, L)
@ -172,7 +172,7 @@ class Config(callbacks.Plugin):
it can be separately configured for each channel using the 'channel' it can be separately configured for each channel using the 'channel'
command in this plugin, it is preceded by an '#' sign. command in this plugin, it is preceded by an '#' sign.
""" """
L = self._list(group) L = self._list(irc, group)
if L: if L:
irc.reply(format('%L', L)) irc.reply(format('%L', L))
else: else:
@ -190,7 +190,7 @@ class Config(callbacks.Plugin):
for (name, x) in conf.supybot.getValues(getChildren=True): for (name, x) in conf.supybot.getValues(getChildren=True):
if word in name.lower(): if word in name.lower():
possibleChannel = registry.split(name)[-1] possibleChannel = registry.split(name)[-1]
if not ircutils.isChannel(possibleChannel): if not irc.isChannel(possibleChannel):
L.append(name) L.append(name)
if L: if L:
irc.reply(format('%L', L)) irc.reply(format('%L', L))
@ -207,7 +207,7 @@ class Config(callbacks.Plugin):
if not group._private: if not group._private:
return (value, None) return (value, None)
else: else:
capability = getCapability(group._name) capability = getCapability(irc, group._name)
if ircdb.checkCapability(msg.prefix, capability): if ircdb.checkCapability(msg.prefix, capability):
return (value, True) return (value, True)
else: else:
@ -222,7 +222,7 @@ class Config(callbacks.Plugin):
irc.error(_("This configuration variable is not writeable " irc.error(_("This configuration variable is not writeable "
"via IRC. To change it you have to: 1) use the 'flush' command 2) edit " "via IRC. To change it you have to: 1) use the 'flush' command 2) edit "
"the config file 3) use the 'config reload' command."), Raise=True) "the config file 3) use the 'config reload' command."), Raise=True)
capability = getCapability(group._name) capability = getCapability(irc, group._name)
if ircdb.checkCapability(msg.prefix, capability): if ircdb.checkCapability(msg.prefix, capability):
# I think callCommand catches exceptions here. Should it? # I think callCommand catches exceptions here. Should it?
group.set(value) group.set(value)

View File

@ -128,7 +128,7 @@ class FactoidsCallback(httpserver.SupyHTTPServerCallback):
self.write(httpserver.get_template('factoids/index.html')) self.write(httpserver.get_template('factoids/index.html'))
elif len(parts) == 2: elif len(parts) == 2:
channel = utils.web.urlunquote(parts[0]) channel = utils.web.urlunquote(parts[0])
if not ircutils.isChannel(channel): if not irc.isChannel(channel):
self.send_response(404) self.send_response(404)
self.send_header('Content-type', 'text/html; charset=utf-8') self.send_header('Content-type', 'text/html; charset=utf-8')
self.end_headers() self.end_headers()

View File

@ -326,7 +326,7 @@ class Google(callbacks.PluginRegexp):
Uses Google's calculator to calculate the value of <expression>. Uses Google's calculator to calculate the value of <expression>.
""" """
channel = msg.args[0] channel = msg.args[0]
if not ircutils.isChannel(channel): if not irc.isChannel(channel):
channel = None channel = None
url = self._googleUrl(expr, channel) url = self._googleUrl(expr, channel)
h = {"User-Agent":"Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36"} h = {"User-Agent":"Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36"}
@ -360,7 +360,7 @@ class Google(callbacks.PluginRegexp):
Looks <phone number> up on Google. Looks <phone number> up on Google.
""" """
channel = msg.args[0] channel = msg.args[0]
if not ircutils.isChannel(channel): if not irc.isChannel(channel):
channel = None channel = None
url = self._googleUrl(phonenumber, channel) url = self._googleUrl(phonenumber, channel)
html = utils.web.getUrl(url).decode('utf8') html = utils.web.getUrl(url).decode('utf8')

View File

@ -34,6 +34,7 @@ import imp
import sys import sys
import json import json
import time import time
import functools
import supybot import supybot
@ -402,10 +403,10 @@ class Misc(callbacks.Plugin):
irc.error(_('That\'s all, there is no more.')) irc.error(_('That\'s all, there is no more.'))
more = wrap(more, [additional('seenNick')]) more = wrap(more, [additional('seenNick')])
def _validLastMsg(self, msg): def _validLastMsg(self, irc, msg):
return msg.prefix and \ return msg.prefix and \
msg.command == 'PRIVMSG' and \ msg.command == 'PRIVMSG' and \
ircutils.isChannel(msg.args[0]) irc.isChannel(msg.args[0])
@internationalizeDocstring @internationalizeDocstring
def last(self, irc, msg, args, optlist): def last(self, irc, msg, args, optlist):
@ -422,7 +423,7 @@ class Misc(callbacks.Plugin):
predicates = {} predicates = {}
nolimit = False nolimit = False
skipfirst = True skipfirst = True
if ircutils.isChannel(msg.args[0]): if irc.isChannel(msg.args[0]):
predicates['in'] = lambda m: ircutils.strEqual(m.args[0], predicates['in'] = lambda m: ircutils.strEqual(m.args[0],
msg.args[0]) msg.args[0])
else: else:
@ -469,7 +470,8 @@ class Misc(callbacks.Plugin):
predicates.setdefault('regexp', []).append(f) predicates.setdefault('regexp', []).append(f)
elif option == 'nolimit': elif option == 'nolimit':
nolimit = True nolimit = True
iterable = filter(self._validLastMsg, reversed(irc.state.history)) iterable = filter(functools.partial(self._validLastMsg, irc),
reversed(irc.state.history))
if skipfirst: if skipfirst:
# Drop the first message only if our current channel is the same as # Drop the first message only if our current channel is the same as
# the channel we've been instructed to look at. # the channel we've been instructed to look at.
@ -535,7 +537,7 @@ class Misc(callbacks.Plugin):
irc.error('This command cannot be nested.', Raise=True) irc.error('This command cannot be nested.', Raise=True)
if target.lower() == 'me': if target.lower() == 'me':
target = msg.nick target = msg.nick
if ircutils.isChannel(target): if irc.isChannel(target):
irc.error(_('Hey, just give the command. No need for the tell.')) irc.error(_('Hey, just give the command. No need for the tell.'))
return return
if not ircutils.isNick(target): if not ircutils.isNick(target):

View File

@ -120,7 +120,7 @@ class NickCapture(callbacks.Plugin):
def do437(self, irc, msg): def do437(self, irc, msg):
"""Nick/channel is temporarily unavailable""" """Nick/channel is temporarily unavailable"""
if ircutils.isChannel(msg.args[1]): if irc.isChannel(msg.args[1]):
return return
self.log.info('Nick %s is unavailable; attempting NickServ release ' self.log.info('Nick %s is unavailable; attempting NickServ release '
'on %s.' % (msg.args[1], irc.network)) 'on %s.' % (msg.args[1], irc.network))

View File

@ -270,8 +270,8 @@ class Note(callbacks.Plugin):
self.db.setRead(id) self.db.setRead(id)
note = wrap(note, ['user', ('id', 'note')]) note = wrap(note, ['user', ('id', 'note')])
def _formatNoteId(self, msg, note, sent=False): def _formatNoteId(self, irc, msg, note, sent=False):
if note.public or not ircutils.isChannel(msg.args[0]): if note.public or not irc.isChannel(msg.args[0]):
if sent: if sent:
sender = plugins.getUserName(note.to) sender = plugins.getUserName(note.to)
return format('#%i to %s', note.id, sender) return format('#%i to %s', note.id, sender)
@ -315,7 +315,7 @@ class Note(callbacks.Plugin):
irc.reply('No matching notes were found.') irc.reply('No matching notes were found.')
else: else:
utils.sortBy(operator.attrgetter('id'), notes) utils.sortBy(operator.attrgetter('id'), notes)
ids = [self._formatNoteId(msg, note) for note in notes] ids = [self._formatNoteId(irc, msg, note) for note in notes]
ids = self._condense(ids) ids = self._condense(ids)
irc.reply(format('%L', ids)) irc.reply(format('%L', ids))
search = wrap(search, search = wrap(search,
@ -357,7 +357,7 @@ class Note(callbacks.Plugin):
irc.reply('You have no unread notes.') irc.reply('You have no unread notes.')
else: else:
utils.sortBy(operator.attrgetter('id'), notes) utils.sortBy(operator.attrgetter('id'), notes)
ids = [self._formatNoteId(msg, note) for note in notes] ids = [self._formatNoteId(irc, msg, note) for note in notes]
ids = self._condense(ids) ids = self._condense(ids)
irc.reply(format('%L.', ids)) irc.reply(format('%L.', ids))
list = wrap(list, ['user', getopts({'old': '', 'sent': '', list = wrap(list, ['user', getopts({'old': '', 'sent': '',
@ -421,7 +421,7 @@ class Note(callbacks.Plugin):
else: else:
utils.sortBy(operator.attrgetter('id'), notes) utils.sortBy(operator.attrgetter('id'), notes)
notes.reverse() # Most recently sent first. notes.reverse() # Most recently sent first.
ids = [self._formatNoteId(msg, note, sent=True) for note in notes] ids = [self._formatNoteId(irc, msg, note, sent=True) for note in notes]
ids = self._condense(ids) ids = self._condense(ids)
irc.reply(format('%L.', ids)) irc.reply(format('%L.', ids))
@ -444,7 +444,7 @@ class Note(callbacks.Plugin):
else: else:
utils.sortBy(operator.attrgetter('id'), notes) utils.sortBy(operator.attrgetter('id'), notes)
notes.reverse() notes.reverse()
ids = [self._formatNoteId(msg, note) for note in notes] ids = [self._formatNoteId(irc, msg, note) for note in notes]
ids = self._condense(ids) ids = self._condense(ids)
irc.reply(format('%L.', ids)) irc.reply(format('%L.', ids))

View File

@ -63,7 +63,7 @@ else:
from urllib.request import ProxyHandler from urllib.request import ProxyHandler
def get_feedName(irc, msg, args, state): def get_feedName(irc, msg, args, state):
if ircutils.isChannel(args[0]): if irc.isChannel(args[0]):
state.errorInvalid('feed name', args[0], 'must not be channel names.') state.errorInvalid('feed name', args[0], 'must not be channel names.')
if not registry.isValidRegistryName(args[0]): if not registry.isValidRegistryName(args[0]):
state.errorInvalid('feed name', args[0], state.errorInvalid('feed name', args[0],

View File

@ -34,7 +34,7 @@ class ReplyTestCase(ChannelPluginTestCase):
plugins = ('Reply',) plugins = ('Reply',)
def testPrivate(self): def testPrivate(self):
m = self.getMsg('private [list]') m = self.getMsg('private [list]')
self.failIf(ircutils.isChannel(m.args[0])) self.failIf(self.irc.isChannel(m.args[0]))
def testNotice(self): def testNotice(self):
m = self.getMsg('notice [list]') m = self.getMsg('notice [list]')

View File

@ -276,7 +276,7 @@ class Services(callbacks.Plugin):
chanTypes = irc.state.supported['CHANTYPES'] chanTypes = irc.state.supported['CHANTYPES']
if re.match(r'^\[[%s]' % re.escape(chanTypes), s): if re.match(r'^\[[%s]' % re.escape(chanTypes), s):
self.log.debug('Got entrymsg from ChanServ %s.', on) self.log.debug('Got entrymsg from ChanServ %s.', on)
elif ircutils.isChannel(msg.args[0]): elif irc.isChannel(msg.args[0]):
# Atheme uses channel-wide notices for alerting channel access # Atheme uses channel-wide notices for alerting channel access
# changes if the FANTASY or VERBOSE setting is on; we can suppress # changes if the FANTASY or VERBOSE setting is on; we can suppress
# these 'unexpected notice' warnings since they're not really # these 'unexpected notice' warnings since they're not really

View File

@ -62,7 +62,7 @@ class Success(plugins.ChannelIdDatabasePlugin):
return ret return ret
def get(self, attr): def get(self, attr):
if ircutils.isChannel(attr): if irc.isChannel(attr):
pluginSelf.target = attr pluginSelf.target = attr
return self return self
conf.supybot.replies.success.__class__ = MySuccessClass conf.supybot.replies.success.__class__ = MySuccessClass

View File

@ -470,7 +470,7 @@ class RichReplyMethods(object):
joiner = joiner.join joiner = joiner.join
to = self._getTarget(kwargs.get('to')) to = self._getTarget(kwargs.get('to'))
if oneToOne is None: # Can be True, False, or None if oneToOne is None: # Can be True, False, or None
if ircutils.isChannel(to): if self.irc.isChannel(to):
oneToOne = conf.get(conf.supybot.reply.oneToOne, to) oneToOne = conf.get(conf.supybot.reply.oneToOne, to)
else: else:
oneToOne = conf.supybot.reply.oneToOne() oneToOne = conf.supybot.reply.oneToOne()
@ -665,7 +665,7 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
self.notice = None self.notice = None
self.private = None self.private = None
self.noLengthCheck = None self.noLengthCheck = None
if ircutils.isChannel(self.msg.args[0]): if self.irc.isChannel(self.msg.args[0]):
self.prefixNick = conf.get(conf.supybot.reply.withNickPrefix, self.prefixNick = conf.get(conf.supybot.reply.withNickPrefix,
self.msg.args[0]) self.msg.args[0])
else: else:
@ -976,7 +976,7 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
pass # We'll leave it as it is. pass # We'll leave it as it is.
mask = prefix.split('!', 1)[1] mask = prefix.split('!', 1)[1]
self._mores[mask] = msgs self._mores[mask] = msgs
public = ircutils.isChannel(msg.args[0]) public = self.irc.isChannel(msg.args[0])
private = self.private or not public private = self.private or not public
self._mores[msg.nick] = (private, msgs) self._mores[msg.nick] = (private, msgs)
m = reply(msg, response, to=self.to, m = reply(msg, response, to=self.to,

View File

@ -569,7 +569,7 @@ class IrcState(IrcCommandDispatcher, log.Firewalled):
def doMode(self, irc, msg): def doMode(self, irc, msg):
channel = msg.args[0] channel = msg.args[0]
if ircutils.isChannel(channel): # There can be user modes, as well. if irc.isChannel(channel): # There can be user modes, as well.
try: try:
chan = self.channels[channel] chan = self.channels[channel]
except KeyError: except KeyError:

View File

@ -35,6 +35,7 @@ import pickle
import supybot.conf as conf import supybot.conf as conf
import supybot.irclib as irclib import supybot.irclib as irclib
import supybot.ircmsgs as ircmsgs import supybot.ircmsgs as ircmsgs
import supybot.ircutils as ircutils
# The test framework used to provide these, but not it doesn't. We'll add # The test framework used to provide these, but not it doesn't. We'll add
# messages to as we find bugs (if indeed we find bugs). # messages to as we find bugs (if indeed we find bugs).
@ -229,6 +230,10 @@ class IrcStateTestCase(SupyTestCase):
class FakeIrc: class FakeIrc:
nick = 'nick' nick = 'nick'
prefix = 'nick!user@host' prefix = 'nick!user@host'
def isChannel(self, s):
return ircutils.isChannel(s)
irc = FakeIrc() irc = FakeIrc()
def testKickRemovesChannel(self): def testKickRemovesChannel(self):
st = irclib.IrcState() st = irclib.IrcState()