Updated to do proper noReply calls.

This commit is contained in:
Jeremy Fincher 2004-12-07 00:41:17 +00:00
parent 5af655391a
commit 9480ff3e88
1 changed files with 26 additions and 25 deletions

View File

@ -60,9 +60,6 @@ conf.registerChannelValue(conf.supybot.plugins.Channel, 'alwaysRejoin',
registry.Boolean(True, """Determines whether the bot will always try to registry.Boolean(True, """Determines whether the bot will always try to
rejoin a channel whenever it's kicked from the channel.""")) rejoin a channel whenever it's kicked from the channel."""))
# XXX We need a lot of noReply calls in here; otherwise, we should add a
# wrapper of some sort to handle that for us. Perhaps we can abstract out
# the very repetitive commands.wrap calls in here while we're at it.
class Channel(callbacks.Privmsg): class Channel(callbacks.Privmsg):
def doKick(self, irc, msg): def doKick(self, irc, msg):
channel = msg.args[0] channel = msg.args[0]
@ -71,6 +68,10 @@ class Channel(callbacks.Privmsg):
networkGroup = conf.supybot.networks.get(irc.network) networkGroup = conf.supybot.networks.get(irc.network)
irc.sendMsg(networkGroup.channels.join(channel)) irc.sendMsg(networkGroup.channels.join(channel))
def _sendMsg(self, irc, msg):
irc.queueMsg(msg)
irc.noReply()
def mode(self, irc, msg, args, channel, modes): def mode(self, irc, msg, args, channel, modes):
"""[<channel>] <mode> [<arg> ...] """[<channel>] <mode> [<arg> ...]
@ -78,7 +79,7 @@ class Channel(callbacks.Privmsg):
<channel> is only necessary if the message isn't sent in the channel <channel> is only necessary if the message isn't sent in the channel
itself. itself.
""" """
irc.queueMsg(ircmsgs.mode(channel, modes)) self._sendMsg(ircmsgs.mode(channel, modes))
mode = wrap(mode, mode = wrap(mode,
[('checkChannelCapability', 'op'), [('checkChannelCapability', 'op'),
('haveOp', 'change the mode'), ('haveOp', 'change the mode'),
@ -92,10 +93,10 @@ class Channel(callbacks.Privmsg):
isn't sent in the channel itself. isn't sent in the channel itself.
""" """
if limit: if limit:
irc.queueMsg(ircmsgs.mode(channel, ['+l', limit])) self._sendMsg(ircmsgs.mode(channel, ['+l', limit]))
else: else:
irc.queueMsg(ircmsgs.mode(channel, ['-l'])) self._sendMsg(ircmsgs.mode(channel, ['-l']))
limit = wrap(mode, [('checkChannelCapability', 'op'), limit = wrap(limit, [('checkChannelCapability', 'op'),
('haveOp', 'change the limit'), ('haveOp', 'change the limit'),
additional('nonNegativeInt', 0)]) additional('nonNegativeInt', 0)])
@ -106,7 +107,7 @@ class Channel(callbacks.Privmsg):
send messages to the channel. <channel> is only necessary if the send messages to the channel. <channel> is only necessary if the
message isn't sent in the channel itself. message isn't sent in the channel itself.
""" """
irc.queueMsg(ircmsgs.mode(channel, ['+m'])) self._sendMsg(ircmsgs.mode(channel, ['+m']))
moderate = wrap(moderate, [('checkChannelCapability', 'op'), moderate = wrap(moderate, [('checkChannelCapability', 'op'),
('haveOp', 'moderate the channel')]) ('haveOp', 'moderate the channel')])
@ -117,7 +118,7 @@ class Channel(callbacks.Privmsg):
send messages to the channel. <channel> is only necessary if the send messages to the channel. <channel> is only necessary if the
message isn't sent in the channel itself. message isn't sent in the channel itself.
""" """
irc.queueMsg(ircmsgs.mode(channel, ['-m'])) self._sendMsg(ircmsgs.mode(channel, ['-m']))
unmoderate = wrap(unmoderate, [('checkChannelCapability', 'op'), unmoderate = wrap(unmoderate, [('checkChannelCapability', 'op'),
('haveOp', 'unmoderate the channel')]) ('haveOp', 'unmoderate the channel')])
@ -128,13 +129,15 @@ class Channel(callbacks.Privmsg):
the keyword requirement to join <channel>. <channel> is only necessary the keyword requirement to join <channel>. <channel> is only necessary
if the message isn't sent in the channel itself. if the message isn't sent in the channel itself.
""" """
networkGroup = conf.supybot.networks.get(irc.network)
networkGroup.channels.key.get(channel).setValue(key)
if key: if key:
irc.queueMsg(ircmsgs.mode(channel, ['+k', key])) self._sendMsg(ircmsgs.mode(channel, ['+k', key]))
else: else:
irc.queueMsg(ircmsgs.mode(channel, ['-k'])) self._sendMsg(ircmsgs.mode(channel, ['-k']))
key = wrap(key, [('checkChannelCapability', 'op'), key = wrap(key, [('checkChannelCapability', 'op'),
('haveOp', 'change the keyword'), ('haveOp', 'change the keyword'),
additional('capability')]) additional('somethingWithoutSpaces', '')])
def op(self, irc, msg, args, channel, nicks): def op(self, irc, msg, args, channel, nicks):
"""[<channel>] [<nick> ...] """[<channel>] [<nick> ...]
@ -146,7 +149,7 @@ class Channel(callbacks.Privmsg):
""" """
if not nicks: if not nicks:
nicks = [msg.nick] nicks = [msg.nick]
irc.queueMsg(ircmsgs.ops(channel, nicks)) self._sendMsg(ircmsgs.ops(channel, nicks))
op = wrap(op, [('checkChannelCapability', 'op'), op = wrap(op, [('checkChannelCapability', 'op'),
('haveOp', 'op someone'), ('haveOp', 'op someone'),
any('nickInChannel')]) any('nickInChannel')])
@ -161,7 +164,7 @@ class Channel(callbacks.Privmsg):
""" """
if not nicks: if not nicks:
nicks = [msg.nick] nicks = [msg.nick]
irc.queueMsg(ircmsgs.halfops(channel, nicks)) self._sendMsg(ircmsgs.halfops(channel, nicks))
halfop = wrap(halfop, [('checkChannelCapability', 'halfop'), halfop = wrap(halfop, [('checkChannelCapability', 'halfop'),
('haveOp', 'halfop someone'), ('haveOp', 'halfop someone'),
any('nickInChannel')]) any('nickInChannel')])
@ -184,7 +187,7 @@ class Channel(callbacks.Privmsg):
capability = 'voice' capability = 'voice'
capability = ircdb.makeChannelCapability(channel, capability) capability = ircdb.makeChannelCapability(channel, capability)
if ircdb.checkCapability(msg.prefix, capability): if ircdb.checkCapability(msg.prefix, capability):
irc.queueMsg(ircmsgs.voices(channel, nicks)) self._sendMsg(ircmsgs.voices(channel, nicks))
else: else:
irc.errorNoCapability(capability) irc.errorNoCapability(capability)
voice = wrap(voice, ['channel', ('haveOp', 'voice someone'), voice = wrap(voice, ['channel', ('haveOp', 'voice someone'),
@ -203,7 +206,7 @@ class Channel(callbacks.Privmsg):
'yourself.', Raise=True) 'yourself.', Raise=True)
if not nicks: if not nicks:
nicks = [msg.nick] nicks = [msg.nick]
irc.queueMsg(ircmsgs.deops(channel, nicks)) self._sendMsg(ircmsgs.deops(channel, nicks))
deop = wrap(deop, [('checkChannelCapability', 'op'), deop = wrap(deop, [('checkChannelCapability', 'op'),
('haveOp', 'deop someone'), ('haveOp', 'deop someone'),
any('nickInChannel')]) any('nickInChannel')])
@ -221,7 +224,7 @@ class Channel(callbacks.Privmsg):
'dehalfop me yourself.', Raise=True) 'dehalfop me yourself.', Raise=True)
if not nicks: if not nicks:
nicks = [msg.nick] nicks = [msg.nick]
irc.queueMsg(ircmsgs.dehalfops(channel, nicks)) self._sendMsg(ircmsgs.dehalfops(channel, nicks))
dehalfop = wrap(dehalfop, [('checkChannelCapability', 'halfop'), dehalfop = wrap(dehalfop, [('checkChannelCapability', 'halfop'),
('haveOp', 'dehalfop someone'), ('haveOp', 'dehalfop someone'),
any('nickInChannel')]) any('nickInChannel')])
@ -243,7 +246,7 @@ class Channel(callbacks.Privmsg):
'me yourself.', Raise=True) 'me yourself.', Raise=True)
if not nicks: if not nicks:
nicks = [msg.nick] nicks = [msg.nick]
irc.queueMsg(ircmsgs.devoices(channel, nicks)) self._sendMsg(ircmsgs.devoices(channel, nicks))
devoice = wrap(devoice, [('checkChannelCapability', 'voice'), devoice = wrap(devoice, [('checkChannelCapability', 'voice'),
('haveOp', 'devoice someone'), ('haveOp', 'devoice someone'),
any('nickInChannel')]) any('nickInChannel')])
@ -255,10 +258,9 @@ class Channel(callbacks.Privmsg):
"cycle", or PART and then JOIN the channel. <channel> is only necessary "cycle", or PART and then JOIN the channel. <channel> is only necessary
if the message isn't sent in the channel itself. if the message isn't sent in the channel itself.
""" """
irc.queueMsg(ircmsgs.part(channel, msg.nick)) self._sendMsg(ircmsgs.part(channel, msg.nick))
networkGroup = conf.supybot.networks.get(irc.network) networkGroup = conf.supybot.networks.get(irc.network)
irc.queueMsg(networkGroup.channels.join(channel)) self._sendMsg(networkGroup.channels.join(channel))
irc.noReply()
cycle = wrap(cycle, [('checkChannelCapability','op')]) cycle = wrap(cycle, [('checkChannelCapability','op')])
def kick(self, irc, msg, args, channel, nick, reason): def kick(self, irc, msg, args, channel, nick, reason):
@ -279,8 +281,7 @@ class Channel(callbacks.Privmsg):
irc.error('The reason you gave is longer than the allowed ' irc.error('The reason you gave is longer than the allowed '
'length for a KICK reason on this server.') 'length for a KICK reason on this server.')
return return
irc.queueMsg(ircmsgs.kick(channel, nick, reason)) self._sendMsg(ircmsgs.kick(channel, nick, reason))
irc.noReply()
kick = wrap(kick, [('checkChannelCapability', 'op'), kick = wrap(kick, [('checkChannelCapability', 'op'),
('haveOp', 'kick someone'), ('haveOp', 'kick someone'),
'nickInChannel', 'nickInChannel',
@ -397,7 +398,7 @@ class Channel(callbacks.Privmsg):
only necessary if the message isn't sent in the channel itself. only necessary if the message isn't sent in the channel itself.
""" """
if hostmask: if hostmask:
irc.queueMsg(ircmsgs.unban(channel, hostmask)) self._sendMsg(ircmsgs.unban(channel, hostmask))
else: else:
bans = [] bans = []
for banmask in irc.state.channels[channel].bans: for banmask in irc.state.channels[channel].bans:
@ -421,7 +422,7 @@ class Channel(callbacks.Privmsg):
to join <channel>. <channel> is only necessary if the message isn't to join <channel>. <channel> is only necessary if the message isn't
sent in the channel itself. sent in the channel itself.
""" """
irc.queueMsg(ircmsgs.invite(nick, channel)) self._sendMsg(ircmsgs.invite(nick, channel))
invite = wrap(invite, [('checkChannelCapability', 'op'), invite = wrap(invite, [('checkChannelCapability', 'op'),
('haveOp', 'invite someone'), ('haveOp', 'invite someone'),
'nick']) 'nick'])