mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 12:12:54 +01:00
Updateed to the new wrap; added a few XXXs.
This commit is contained in:
parent
1bd09d016f
commit
4566c1bfca
133
src/Channel.py
133
src/Channel.py
@ -70,18 +70,18 @@ class Channel(callbacks.Privmsg):
|
|||||||
if self.registryValue('alwaysRejoin', channel):
|
if self.registryValue('alwaysRejoin', channel):
|
||||||
irc.sendMsg(ircmsgs.join(channel)) # Fix for keys.
|
irc.sendMsg(ircmsgs.join(channel)) # Fix for keys.
|
||||||
|
|
||||||
def mode(self, irc, msg, args, channel):
|
def mode(self, irc, msg, args, channel, modes):
|
||||||
"""[<channel>] <mode> [<arg> ...]
|
"""[<channel>] <mode> [<arg> ...]
|
||||||
|
|
||||||
Sets the mode in <channel> to <mode>, sending the arguments given.
|
Sets the mode in <channel> to <mode>, sending the arguments given.
|
||||||
<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, args))
|
irc.queueMsg(ircmsgs.mode(channel, modes))
|
||||||
mode = wrap(mode,
|
mode = wrap(mode,
|
||||||
[('checkChannelCapability', 'op'),
|
[('checkChannelCapability', 'op'),
|
||||||
('haveOp', 'change the mode')],
|
('haveOp', 'change the mode'),
|
||||||
requireExtra=True)
|
many('text')])
|
||||||
|
|
||||||
def limit(self, irc, msg, args, channel, limit):
|
def limit(self, irc, msg, args, channel, limit):
|
||||||
"""[<channel>] [<limit>]
|
"""[<channel>] [<limit>]
|
||||||
@ -96,7 +96,7 @@ class Channel(callbacks.Privmsg):
|
|||||||
irc.queueMsg(ircmsgs.mode(channel, ['-l']))
|
irc.queueMsg(ircmsgs.mode(channel, ['-l']))
|
||||||
limit = wrap(mode, [('checkChannelCapability', 'op'),
|
limit = wrap(mode, [('checkChannelCapability', 'op'),
|
||||||
('haveOp', 'change the limit'),
|
('haveOp', 'change the limit'),
|
||||||
('?nonNegativeInt', 0)])
|
additional('nonNegativeInt', 0)])
|
||||||
|
|
||||||
def moderate(self, irc, msg, args, channel):
|
def moderate(self, irc, msg, args, channel):
|
||||||
"""[<channel>]
|
"""[<channel>]
|
||||||
@ -132,9 +132,10 @@ class Channel(callbacks.Privmsg):
|
|||||||
else:
|
else:
|
||||||
irc.queueMsg(ircmsgs.mode(channel, ['-k']))
|
irc.queueMsg(ircmsgs.mode(channel, ['-k']))
|
||||||
key = wrap(key, [('checkChannelCapability', 'op'),
|
key = wrap(key, [('checkChannelCapability', 'op'),
|
||||||
('haveOp', 'change the keyword'), '?capability'])
|
('haveOp', 'change the keyword'),
|
||||||
|
additional('capability')])
|
||||||
|
|
||||||
def op(self, irc, msg, args, channel):
|
def op(self, irc, msg, args, channel, nicks):
|
||||||
"""[<channel>] [<nick> ...]
|
"""[<channel>] [<nick> ...]
|
||||||
|
|
||||||
If you have the #channel,op capability, this will give all the <nick>s
|
If you have the #channel,op capability, this will give all the <nick>s
|
||||||
@ -142,93 +143,103 @@ 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.
|
||||||
"""
|
"""
|
||||||
if not args:
|
if not nicks:
|
||||||
args = [msg.nick]
|
nicks = [msg.nick]
|
||||||
irc.queueMsg(ircmsgs.ops(channel, args))
|
irc.queueMsg(ircmsgs.ops(channel, nicks))
|
||||||
op = wrap(op, [('checkChannelCapability', 'op'),
|
op = wrap(op, [('checkChannelCapability', 'op'),
|
||||||
('haveOp', 'op someone')], allowExtra=True)
|
('haveOp', 'op someone'),
|
||||||
|
any('nickInChannel')])
|
||||||
|
|
||||||
def halfop(self, irc, msg, args, channel):
|
def halfop(self, irc, msg, args, channel, nicks):
|
||||||
"""[<channel>]
|
"""[<channel>] [<nick> ...]
|
||||||
|
|
||||||
If you have the #channel,halfop capability, this will give all the
|
If you have the #channel,halfop capability, this will give all the
|
||||||
<nick>s you provide halfops. If you don't provide any <nick>s, this
|
<nick>s you provide halfops. If you don't provide any <nick>s, this
|
||||||
will give you halfops. <channel> is only necessary if the message isn't
|
will give you halfops. <channel> is only necessary if the message isn't
|
||||||
sent in the channel itself.
|
sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
if not args:
|
if not nicks:
|
||||||
args = [msg.nick]
|
nicks = [msg.nick]
|
||||||
irc.queueMsg(ircmsgs.halfops(channel, args))
|
irc.queueMsg(ircmsgs.halfops(channel, nicks))
|
||||||
halfop = wrap(halfop, [('checkChannelCapability', 'halfop'),
|
halfop = wrap(halfop, [('checkChannelCapability', 'halfop'),
|
||||||
('haveOp', 'halfop someone')], allowExtra=True)
|
('haveOp', 'halfop someone'),
|
||||||
|
many('nickInChannel')])
|
||||||
|
|
||||||
def voice(self, irc, msg, args, channel):
|
def voice(self, irc, msg, args, channel, nicks):
|
||||||
"""[<channel>]
|
"""[<channel>] [<nick> ...]
|
||||||
|
|
||||||
If you have the #channel,voice capability, this will voice all the
|
If you have the #channel,voice capability, this will voice all the
|
||||||
<nick>s you provide. If you don't provide any <nick>s, this will
|
<nick>s you provide. If you don't provide any <nick>s, this will
|
||||||
voice you. <channel> is only necessary if the message isn't sent in the
|
voice you. <channel> is only necessary if the message isn't sent in the
|
||||||
channel itself.
|
channel itself.
|
||||||
"""
|
"""
|
||||||
if not args:
|
if not nicks:
|
||||||
args = [msg.nick]
|
nicks = [msg.nick]
|
||||||
irc.queueMsg(ircmsgs.voices(channel, args))
|
irc.queueMsg(ircmsgs.voices(channel, nicks))
|
||||||
voice = wrap(voice, [('checkChannelCapability', 'voice'),
|
voice = wrap(voice, [('checkChannelCapability', 'voice'),
|
||||||
('haveOp', 'voice someone')], allowExtra=True)
|
('haveOp', 'voice someone'),
|
||||||
|
many('nickInChannel')])
|
||||||
|
|
||||||
def deop(self, irc, msg, args, channel):
|
def deop(self, irc, msg, args, channel, nicks):
|
||||||
"""[<channel>] [<nick> ...]
|
"""[<channel>] [<nick> ...]
|
||||||
|
|
||||||
If you have the #channel,op capability, this will remove operator
|
If you have the #channel,op capability, this will remove operator
|
||||||
privileges from all the nicks given. If no nicks are given, removes
|
privileges from all the nicks given. If no nicks are given, removes
|
||||||
operator privileges from the person sending the message.
|
operator privileges from the person sending the message.
|
||||||
"""
|
"""
|
||||||
if not args:
|
if irc.nick in nicks:
|
||||||
args.append(msg.nick)
|
|
||||||
if irc.nick in args:
|
|
||||||
irc.error('I cowardly refuse to deop myself. If you really want '
|
irc.error('I cowardly refuse to deop myself. If you really want '
|
||||||
'me deopped, tell me to op you and then deop me '
|
'me deopped, tell me to op you and then deop me '
|
||||||
'yourself.')
|
'yourself.', Raise=True)
|
||||||
|
if not nicks:
|
||||||
|
nicks = [msg.nick]
|
||||||
else:
|
else:
|
||||||
irc.queueMsg(ircmsgs.deops(channel, args))
|
irc.queueMsg(ircmsgs.deops(channel, nicks))
|
||||||
deop = wrap(deop, [('checkChannelCapability', 'op'),
|
deop = wrap(deop, [('checkChannelCapability', 'op'),
|
||||||
('haveOp', 'deop someone')], allowExtra=True)
|
('haveOp', 'deop someone'),
|
||||||
|
many('nickInChannel')])
|
||||||
|
|
||||||
def dehalfop(self, irc, msg, args, channel):
|
def dehalfop(self, irc, msg, args, channel, nicks):
|
||||||
"""[<channel>] [<nick> ...]
|
"""[<channel>] [<nick> ...]
|
||||||
|
|
||||||
If you have the #channel,op capability, this will remove half-operator
|
If you have the #channel,op capability, this will remove half-operator
|
||||||
privileges from all the nicks given. If no nicks are given, removes
|
privileges from all the nicks given. If no nicks are given, removes
|
||||||
half-operator privileges from the person sending the message.
|
half-operator privileges from the person sending the message.
|
||||||
"""
|
"""
|
||||||
if not args:
|
if irc.nick in nicks:
|
||||||
args.append(msg.nick)
|
|
||||||
if irc.nick in args:
|
|
||||||
irc.error('I cowardly refuse to dehalfop myself. If you really '
|
irc.error('I cowardly refuse to dehalfop myself. If you really '
|
||||||
'want me dehalfopped, tell me to op you and then '
|
'want me dehalfopped, tell me to op you and then '
|
||||||
'dehalfop me yourself.')
|
'dehalfop me yourself.', Raise=True)
|
||||||
|
if not nicks:
|
||||||
|
nicks = [msg.nick]
|
||||||
else:
|
else:
|
||||||
irc.queueMsg(ircmsgs.dehalfops(channel, args))
|
irc.queueMsg(ircmsgs.dehalfops(channel, nicks))
|
||||||
dehalfop = wrap(dehalfop, [('checkChannelCapability', 'halfop'),
|
dehalfop = wrap(dehalfop, [('checkChannelCapability', 'halfop'),
|
||||||
('haveOp', 'dehalfop someone')],allowExtra=True)
|
('haveOp', 'dehalfop someone'),
|
||||||
|
many('nickInChannel')])
|
||||||
|
|
||||||
def devoice(self, irc, msg, args, channel):
|
# XXX These nicks should really be sets, rather than lists, especially
|
||||||
|
# we check whether the bot's nick is in them.
|
||||||
|
# XXX We should respect the MODES part of an 005 here. Helper function
|
||||||
|
# material.
|
||||||
|
def devoice(self, irc, msg, args, channel, nicks):
|
||||||
"""[<channel>] [<nick> ...]
|
"""[<channel>] [<nick> ...]
|
||||||
|
|
||||||
If you have the #channel,op capability, this will remove voice from all
|
If you have the #channel,op capability, this will remove voice from all
|
||||||
the nicks given. If no nicks are given, removes voice from the person
|
the nicks given. If no nicks are given, removes voice from the person
|
||||||
sending the message.
|
sending the message.
|
||||||
"""
|
"""
|
||||||
if not args:
|
if irc.nick in nicks:
|
||||||
args.append(msg.nick)
|
|
||||||
if irc.nick in args:
|
|
||||||
irc.error('I cowardly refuse to devoice myself. If you really '
|
irc.error('I cowardly refuse to devoice myself. If you really '
|
||||||
'want me devoiced, tell me to op you and then devoice '
|
'want me devoiced, tell me to op you and then devoice '
|
||||||
'me yourself.')
|
'me yourself.', Raise=True)
|
||||||
|
if not nicks:
|
||||||
|
nicks = [msg.nick]
|
||||||
else:
|
else:
|
||||||
irc.queueMsg(ircmsgs.devoices(channel, args))
|
irc.queueMsg(ircmsgs.devoices(channel, nicks))
|
||||||
devoice = wrap(devoice, [('checkChannelCapability', 'voice'),
|
devoice = wrap(devoice, [('checkChannelCapability', 'voice'),
|
||||||
('haveOp', 'devoice someone')], allowExtra=True)
|
('haveOp', 'devoice someone'),
|
||||||
|
many('nickInChannel')])
|
||||||
|
|
||||||
def cycle(self, irc, msg, args, channel, key):
|
def cycle(self, irc, msg, args, channel, key):
|
||||||
"""[<channel>] [<key>]
|
"""[<channel>] [<key>]
|
||||||
@ -243,7 +254,8 @@ class Channel(callbacks.Privmsg):
|
|||||||
irc.queueMsg(ircmsgs.part(channel))
|
irc.queueMsg(ircmsgs.part(channel))
|
||||||
irc.queueMsg(ircmsgs.join(channel, key))
|
irc.queueMsg(ircmsgs.join(channel, key))
|
||||||
irc.noReply()
|
irc.noReply()
|
||||||
cycle = wrap(cycle, [('checkChannelCapability','op'),'?anything'])
|
cycle = wrap(cycle, [('checkChannelCapability','op'),
|
||||||
|
additional('anything')])
|
||||||
|
|
||||||
def kick(self, irc, msg, args, channel, nick, reason):
|
def kick(self, irc, msg, args, channel, nick, reason):
|
||||||
"""[<channel>] <nick> [<reason>]
|
"""[<channel>] <nick> [<reason>]
|
||||||
@ -266,7 +278,9 @@ class Channel(callbacks.Privmsg):
|
|||||||
irc.queueMsg(ircmsgs.kick(channel, nick, reason))
|
irc.queueMsg(ircmsgs.kick(channel, nick, reason))
|
||||||
irc.noReply()
|
irc.noReply()
|
||||||
kick = wrap(kick, [('checkChannelCapability', 'op'),
|
kick = wrap(kick, [('checkChannelCapability', 'op'),
|
||||||
('haveOp', 'kick someone'), 'nick', '?anything'])
|
('haveOp', 'kick someone'),
|
||||||
|
'nickInChannel',
|
||||||
|
additional('anything')])
|
||||||
|
|
||||||
def kban(self, irc, msg, args,
|
def kban(self, irc, msg, args,
|
||||||
optlist, channel, bannedNick, length, reason):
|
optlist, channel, bannedNick, length, reason):
|
||||||
@ -359,12 +373,11 @@ class Channel(callbacks.Privmsg):
|
|||||||
exact,nick,user,host
|
exact,nick,user,host
|
||||||
kban = wrap(kban,
|
kban = wrap(kban,
|
||||||
[('checkChannelCapability', 'op'),
|
[('checkChannelCapability', 'op'),
|
||||||
|
getopts({'exact':None,'nick':None,'user':None,'host':None}),
|
||||||
('haveOp', 'kick or ban someone'),
|
('haveOp', 'kick or ban someone'),
|
||||||
'nick', ('expiry?', 0), '?anything'],
|
'nickInChannel',
|
||||||
getopts={'exact': None,
|
optional('expiry', 0),
|
||||||
'nick': None,
|
additional('anything')])
|
||||||
'user': None,
|
|
||||||
'host': None})
|
|
||||||
|
|
||||||
def unban(self, irc, msg, args, channel, hostmask):
|
def unban(self, irc, msg, args, channel, hostmask):
|
||||||
"""[<channel>] <hostmask>
|
"""[<channel>] <hostmask>
|
||||||
@ -376,7 +389,8 @@ class Channel(callbacks.Privmsg):
|
|||||||
"""
|
"""
|
||||||
irc.queueMsg(ircmsgs.unban(channel, hostmask))
|
irc.queueMsg(ircmsgs.unban(channel, hostmask))
|
||||||
unban = wrap(unban, [('checkChannelCapability', 'op'),
|
unban = wrap(unban, [('checkChannelCapability', 'op'),
|
||||||
('haveOp', 'unban someone'), 'hostmask'])
|
('haveOp', 'unban someone'),
|
||||||
|
'hostmask'])
|
||||||
|
|
||||||
def invite(self, irc, msg, args, channel, nick):
|
def invite(self, irc, msg, args, channel, nick):
|
||||||
"""[<channel>] <nick>
|
"""[<channel>] <nick>
|
||||||
@ -387,7 +401,8 @@ class Channel(callbacks.Privmsg):
|
|||||||
"""
|
"""
|
||||||
irc.queueMsg(ircmsgs.invite(nick, channel))
|
irc.queueMsg(ircmsgs.invite(nick, channel))
|
||||||
invite = wrap(invite, [('checkChannelCapability', 'op'),
|
invite = wrap(invite, [('checkChannelCapability', 'op'),
|
||||||
('haveOp', 'invite someone'), 'nick'])
|
('haveOp', 'invite someone'),
|
||||||
|
'nick'])
|
||||||
|
|
||||||
def lobotomize(self, irc, msg, args, channel):
|
def lobotomize(self, irc, msg, args, channel):
|
||||||
"""[<channel>]
|
"""[<channel>]
|
||||||
@ -434,7 +449,8 @@ class Channel(callbacks.Privmsg):
|
|||||||
ircdb.channels.setChannel(channel, c)
|
ircdb.channels.setChannel(channel, c)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
permban = wrap(permban, [('checkChannelCapability', 'op'),
|
permban = wrap(permban, [('checkChannelCapability', 'op'),
|
||||||
'hostmask', ('?expiry', 0)])
|
'hostmask',
|
||||||
|
additional('expiry', 0)])
|
||||||
|
|
||||||
def unpermban(self, irc, msg, args, channel, banmask):
|
def unpermban(self, irc, msg, args, channel, banmask):
|
||||||
"""[<channel>] <hostmask>
|
"""[<channel>] <hostmask>
|
||||||
@ -478,7 +494,7 @@ class Channel(callbacks.Privmsg):
|
|||||||
ircdb.channels.setChannel(channel, c)
|
ircdb.channels.setChannel(channel, c)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
ignore = wrap(ignore, [('checkChannelCapability', 'op'),
|
ignore = wrap(ignore, [('checkChannelCapability', 'op'),
|
||||||
'hostmask', ('?expiry', 0)])
|
'hostmask', additional('expiry', 0)])
|
||||||
|
|
||||||
def unignore(self, irc, msg, args, channel, banmask):
|
def unignore(self, irc, msg, args, channel, banmask):
|
||||||
"""[<channel>] <hostmask>
|
"""[<channel>] <hostmask>
|
||||||
@ -594,7 +610,7 @@ class Channel(callbacks.Privmsg):
|
|||||||
ircdb.channels.setChannel(channel, chan)
|
ircdb.channels.setChannel(channel, chan)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
setcapability = wrap(setcapability,
|
setcapability = wrap(setcapability,
|
||||||
[('checkChannelCapability', 'op'), 'capability+'])
|
[('checkChannelCapability', 'op'), many('capability')])
|
||||||
|
|
||||||
def unsetcapability(self, irc, msg, args, channel, capabilities):
|
def unsetcapability(self, irc, msg, args, channel, capabilities):
|
||||||
"""[<channel>] <capability> [<capability> ...]
|
"""[<channel>] <capability> [<capability> ...]
|
||||||
@ -618,7 +634,8 @@ class Channel(callbacks.Privmsg):
|
|||||||
utils.pluralize('capability', len(fail))), Raise=True)
|
utils.pluralize('capability', len(fail))), Raise=True)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
unsetcapability = wrap(unsetcapability,
|
unsetcapability = wrap(unsetcapability,
|
||||||
[('checkChannelCapability', 'op'), 'capability+'])
|
[('checkChannelCapability', 'op'),
|
||||||
|
many('capability')])
|
||||||
|
|
||||||
def capabilities(self, irc, msg, args, channel):
|
def capabilities(self, irc, msg, args, channel):
|
||||||
"""[<channel>]
|
"""[<channel>]
|
||||||
@ -656,7 +673,7 @@ class Channel(callbacks.Privmsg):
|
|||||||
L = list(irc.state.channels[channel].users)
|
L = list(irc.state.channels[channel].users)
|
||||||
utils.sortBy(str.lower, L)
|
utils.sortBy(str.lower, L)
|
||||||
irc.reply(utils.commaAndify(L))
|
irc.reply(utils.commaAndify(L))
|
||||||
nicks = wrap(nicks, ['channel'])
|
nicks = wrap(nicks, ['inChannel']) # XXX Check that the caller is in chan.
|
||||||
|
|
||||||
def alertOps(self, irc, channel, s, frm=None):
|
def alertOps(self, irc, channel, s, frm=None):
|
||||||
"""Internal message for notifying all the #channel,ops in a channel of
|
"""Internal message for notifying all the #channel,ops in a channel of
|
||||||
|
Loading…
Reference in New Issue
Block a user