phenny-1/modules/admin.py

72 lines
2.2 KiB
Python
Raw Normal View History

#!/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
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)
if not key:
phenny.write(['JOIN'], channel)
else: phenny.write(['JOIN', channel, key])
join.rule = r'\.join (#\S+)(?: *(\S+))?'
join.priority = 'low'
join.example = '.join #example or .join #example key'
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)
phenny.write(['JOIN'], channel)
autojoin.event = 'INVITE'
autojoin.rule = r'(.*)'
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:
phenny.write(['PART'], input.group(2))
2016-01-12 13:02:54 -05:00
part.rule = (['part'], r'(#\S+)')
part.priority = 'low'
2008-03-10 15:58:28 -04:00
part.example = '.part #example'
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:
phenny.write(['QUIT'])
__import__('os')._exit(0)
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+) (.+)')
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)
me.rule = (['me'], r'(#?\S+) (.*)')
me.priority = 'low'
if __name__ == '__main__':
2012-01-03 13:55:28 -05:00
print(__doc__.strip())