2008-02-21 07:06:33 -05:00
|
|
|
#!/usr/bin/env python
|
|
|
|
"""
|
|
|
|
admin.py - Phenny Admin Module
|
|
|
|
Copyright 2008, Sean B. Palmer, inamidst.com
|
|
|
|
Licensed under the Eiffel Forum License 2.
|
|
|
|
|
|
|
|
http://inamidst.com/phenny/
|
|
|
|
"""
|
|
|
|
|
|
|
|
def join(phenny, input):
|
2008-03-10 15:58:28 -04:00
|
|
|
"""Join the specified channel. This is an admin-only command."""
|
2008-02-21 07:06:33 -05:00
|
|
|
# Can only be done in privmsg by an admin
|
|
|
|
if input.sender.startswith('#'): return
|
|
|
|
if input.admin:
|
2008-06-19 13:58:24 -04:00
|
|
|
channel, key = input.group(1), input.group(2)
|
|
|
|
if not key:
|
|
|
|
phenny.write(['JOIN'], channel)
|
|
|
|
else: phenny.write(['JOIN', channel, key])
|
|
|
|
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
|
|
|
|
|
|
|
def part(phenny, input):
|
2008-03-10 15:58:28 -04:00
|
|
|
"""Part the specified channel. This is an admin-only command."""
|
2008-02-21 07:06:33 -05:00
|
|
|
# Can only be done in privmsg by an admin
|
|
|
|
if input.sender.startswith('#'): return
|
|
|
|
if input.admin:
|
|
|
|
phenny.write(['PART'], input.group(2))
|
|
|
|
part.commands = ['part']
|
|
|
|
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):
|
2008-03-10 15:58:28 -04:00
|
|
|
"""Quit from the server. This is an owner-only command."""
|
2008-02-21 07:06:33 -05:00
|
|
|
# Can only be done in privmsg by the owner
|
|
|
|
if input.sender.startswith('#'): return
|
|
|
|
if input.owner:
|
|
|
|
phenny.write(['QUIT'])
|
|
|
|
__import__('os')._exit(0)
|
|
|
|
quit.commands = ['quit']
|
|
|
|
quit.priority = 'low'
|
|
|
|
|
|
|
|
def msg(phenny, input):
|
|
|
|
# Can only be done in privmsg by an admin
|
|
|
|
if input.sender.startswith('#'): return
|
|
|
|
if input.admin:
|
|
|
|
phenny.msg(input.group(2), input.group(3))
|
2008-03-31 11:17:32 -04:00
|
|
|
msg.rule = (['msg'], r'(#?\S+) (.*)')
|
2008-02-21 07:06:33 -05:00
|
|
|
msg.priority = 'low'
|
|
|
|
|
|
|
|
def me(phenny, input):
|
|
|
|
# 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__':
|
|
|
|
print __doc__.strip()
|