2008-02-21 07:06:33 -05:00
|
|
|
#!/usr/bin/env python
|
|
|
|
"""
|
|
|
|
admin.py - Phenny Admin Module
|
2009-06-07 05:08:49 -04:00
|
|
|
Copyright 2008-9, Sean B. Palmer, inamidst.com
|
2008-02-21 07:06:33 -05:00
|
|
|
Licensed under the Eiffel Forum License 2.
|
|
|
|
|
|
|
|
http://inamidst.com/phenny/
|
|
|
|
"""
|
|
|
|
|
|
|
|
def join(phenny, input):
|
2012-01-03 13:55:28 -05:00
|
|
|
"""Join the specified channel. This is an admin-only command."""
|
|
|
|
# Can only be done in privmsg by an admin
|
|
|
|
if input.sender.startswith('#'): return
|
|
|
|
if input.admin:
|
|
|
|
channel, key = input.group(1), input.group(2)
|
2018-03-14 13:31:10 -04:00
|
|
|
phenny.proto.join(channel, key)
|
2008-06-19 13:58:24 -04:00
|
|
|
join.rule = r'\.join (#\S+)(?: *(\S+))?'
|
2008-02-21 07:06:33 -05:00
|
|
|
join.priority = 'low'
|
2008-06-19 13:58:24 -04:00
|
|
|
join.example = '.join #example or .join #example key'
|
2008-02-21 07:06:33 -05:00
|
|
|
|
2012-01-03 13:55:28 -05:00
|
|
|
def autojoin(phenny, input):
|
|
|
|
"""Join the specified channel when invited by an admin."""
|
|
|
|
if input.admin:
|
|
|
|
channel = input.group(1)
|
2018-03-14 13:31:10 -04:00
|
|
|
phenny.proto.join(channel)
|
2012-01-03 13:55:28 -05:00
|
|
|
autojoin.event = 'INVITE'
|
|
|
|
autojoin.rule = r'(.*)'
|
|
|
|
|
2008-02-21 07:06:33 -05:00
|
|
|
def part(phenny, input):
|
2012-01-03 13:55:28 -05:00
|
|
|
"""Part the specified channel. This is an admin-only command."""
|
|
|
|
# Can only be done in privmsg by an admin
|
|
|
|
if input.sender.startswith('#'): return
|
|
|
|
if input.admin:
|
2018-03-14 13:31:10 -04:00
|
|
|
phenny.proto.part(input.group(2))
|
2016-01-12 13:02:54 -05:00
|
|
|
part.rule = (['part'], r'(#\S+)')
|
2008-02-21 07:06:33 -05:00
|
|
|
part.priority = 'low'
|
2008-03-10 15:58:28 -04:00
|
|
|
part.example = '.part #example'
|
2008-02-21 07:06:33 -05:00
|
|
|
|
|
|
|
def quit(phenny, input):
|
2012-01-03 13:55:28 -05:00
|
|
|
"""Quit from the server. This is an owner-only command."""
|
|
|
|
# Can only be done in privmsg by the owner
|
|
|
|
if input.sender.startswith('#'): return
|
|
|
|
if input.owner:
|
2018-03-14 13:31:10 -04:00
|
|
|
phenny.proto.quit()
|
2012-01-03 13:55:28 -05:00
|
|
|
__import__('os')._exit(0)
|
2008-02-21 07:06:33 -05:00
|
|
|
quit.commands = ['quit']
|
|
|
|
quit.priority = 'low'
|
|
|
|
|
|
|
|
def msg(phenny, input):
|
2012-01-03 13:55:28 -05:00
|
|
|
# Can only be done in privmsg by an admin
|
|
|
|
if input.sender.startswith('#'): return
|
|
|
|
a, b = input.group(2), input.group(3)
|
|
|
|
if (not a) or (not b): return
|
|
|
|
if input.admin:
|
|
|
|
phenny.msg(a, b)
|
2009-01-19 11:47:05 -05:00
|
|
|
msg.rule = (['msg'], r'(#?\S+) (.+)')
|
2008-02-21 07:06:33 -05:00
|
|
|
msg.priority = 'low'
|
|
|
|
|
|
|
|
def me(phenny, input):
|
2012-01-03 13:55:28 -05:00
|
|
|
# Can only be done in privmsg by an admin
|
|
|
|
if input.sender.startswith('#'): return
|
|
|
|
if input.admin:
|
|
|
|
msg = '\x01ACTION %s\x01' % input.group(3)
|
|
|
|
phenny.msg(input.group(2), msg)
|
2008-03-31 11:17:32 -04:00
|
|
|
me.rule = (['me'], r'(#?\S+) (.*)')
|
2008-02-21 07:06:33 -05:00
|
|
|
me.priority = 'low'
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2012-01-03 13:55:28 -05:00
|
|
|
print(__doc__.strip())
|