admin: join channel when invited

master
mutantmonkey 2012-01-03 13:55:28 -05:00
parent e2535ab621
commit 9cd3578ed1
1 changed files with 39 additions and 31 deletions

View File

@ -8,56 +8,64 @@ http://inamidst.com/phenny/
""" """
def join(phenny, input): def join(phenny, input):
"""Join the specified channel. This is an admin-only command.""" """Join the specified channel. This is an admin-only command."""
# Can only be done in privmsg by an admin # Can only be done in privmsg by an admin
if input.sender.startswith('#'): return if input.sender.startswith('#'): return
if input.admin: if input.admin:
channel, key = input.group(1), input.group(2) channel, key = input.group(1), input.group(2)
if not key: if not key:
phenny.write(['JOIN'], channel) phenny.write(['JOIN'], channel)
else: phenny.write(['JOIN', channel, key]) else: phenny.write(['JOIN', channel, key])
join.rule = r'\.join (#\S+)(?: *(\S+))?' join.rule = r'\.join (#\S+)(?: *(\S+))?'
join.priority = 'low' join.priority = 'low'
join.example = '.join #example or .join #example key' join.example = '.join #example or .join #example key'
def autojoin(phenny, input):
"""Join the specified channel when invited by an admin."""
if input.admin:
channel = input.group(1)
phenny.write(['JOIN'], channel)
autojoin.event = 'INVITE'
autojoin.rule = r'(.*)'
def part(phenny, input): def part(phenny, input):
"""Part the specified channel. This is an admin-only command.""" """Part the specified channel. This is an admin-only command."""
# Can only be done in privmsg by an admin # Can only be done in privmsg by an admin
if input.sender.startswith('#'): return if input.sender.startswith('#'): return
if input.admin: if input.admin:
phenny.write(['PART'], input.group(2)) phenny.write(['PART'], input.group(2))
part.commands = ['part'] part.commands = ['part']
part.priority = 'low' part.priority = 'low'
part.example = '.part #example' part.example = '.part #example'
def quit(phenny, input): def quit(phenny, input):
"""Quit from the server. This is an owner-only command.""" """Quit from the server. This is an owner-only command."""
# Can only be done in privmsg by the owner # Can only be done in privmsg by the owner
if input.sender.startswith('#'): return if input.sender.startswith('#'): return
if input.owner: if input.owner:
phenny.write(['QUIT']) phenny.write(['QUIT'])
__import__('os')._exit(0) __import__('os')._exit(0)
quit.commands = ['quit'] quit.commands = ['quit']
quit.priority = 'low' quit.priority = 'low'
def msg(phenny, input): def msg(phenny, input):
# Can only be done in privmsg by an admin # Can only be done in privmsg by an admin
if input.sender.startswith('#'): return if input.sender.startswith('#'): return
a, b = input.group(2), input.group(3) a, b = input.group(2), input.group(3)
if (not a) or (not b): return if (not a) or (not b): return
if input.admin: if input.admin:
phenny.msg(a, b) phenny.msg(a, b)
msg.rule = (['msg'], r'(#?\S+) (.+)') msg.rule = (['msg'], r'(#?\S+) (.+)')
msg.priority = 'low' msg.priority = 'low'
def me(phenny, input): def me(phenny, input):
# Can only be done in privmsg by an admin # Can only be done in privmsg by an admin
if input.sender.startswith('#'): return if input.sender.startswith('#'): return
if input.admin: if input.admin:
msg = '\x01ACTION %s\x01' % input.group(3) msg = '\x01ACTION %s\x01' % input.group(3)
phenny.msg(input.group(2), msg) phenny.msg(input.group(2), msg)
me.rule = (['me'], r'(#?\S+) (.*)') me.rule = (['me'], r'(#?\S+) (.*)')
me.priority = 'low' me.priority = 'low'
if __name__ == '__main__': if __name__ == '__main__':
print(__doc__.strip()) print(__doc__.strip())