minetestbot-modules/admin.py

84 lines
2.4 KiB
Python
Raw Normal View History

2013-01-07 10:00:44 -08:00
#!/usr/bin/env python
"""
admin.py - Phenny Admin Module
Copyright 2008-9, Sean B. Palmer, inamidst.com
2014-07-19 11:13:28 -07:00
Modified by sfan5 2013
2013-01-07 10:00:44 -08:00
Licensed under the Eiffel Forum License 2.
http://inamidst.com/phenny/
"""
2014-07-19 11:13:28 -07:00
def join(phenny, input):
2013-01-07 10:00:44 -08: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
2014-07-19 11:13:28 -07:00
if input.admin:
2013-01-07 10:00:44 -08:00
channel, key = input.group(1), input.group(2)
2014-07-19 11:13:28 -07:00
if not key:
2013-01-07 10:00:44 -08:00
phenny.write(['JOIN'], channel)
else: phenny.write(['JOIN', channel, key])
2013-01-19 02:42:47 -08:00
join.rule = r'\!join (#\S+)(?: *(\S+))?'
2013-01-07 10:00:44 -08:00
#join.commands = ['join']
join.priority = 'low'
join.example = '.join #example or .join #example key'
2014-07-19 11:13:28 -07:00
def part(phenny, input):
2013-01-07 10:00:44 -08: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
2014-07-19 11:13:28 -07:00
if input.admin:
2014-02-01 11:33:10 -08:00
if ' ' in input.group(2):
arg = input.group(2).split(" ")
arg2 = ' '.join(arg[1:])
arg = arg[0]
phenny.write(['PART', arg], arg2)
else:
phenny.write(['PART'], input.group(2))
2013-01-07 10:00:44 -08:00
part.commands = ['part']
part.priority = 'low'
part.example = '.part #example'
2014-07-19 11:13:28 -07:00
def quit(phenny, input):
2013-01-07 10:00:44 -08: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
2014-07-19 11:13:28 -07:00
if input.owner:
2013-01-07 10:00:44 -08:00
phenny.write(['QUIT'])
__import__('os')._exit(0)
quit.commands = ['quit']
quit.priority = 'low'
def quit2(phenny, input):
if input.sender.startswith('#'): input.sender = "this_is_not_a_channel" # Allows you to use it in a Channel
quit(phenny, input)
quit2.rule = ('$nick', 'quit')
quit2.priority = 'low'
2014-07-19 11:13:28 -07:00
def msg(phenny, input):
2013-01-07 10:00:44 -08: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
2014-07-19 11:13:28 -07:00
if input.admin:
2013-01-07 10:00:44 -08:00
phenny.msg(a, b)
msg.rule = (['msg'], r'(#?\S+) (.+)')
msg.priority = 'low'
2014-07-19 11:13:28 -07:00
def me(phenny, input):
2013-01-07 10:00:44 -08:00
# Can only be done in privmsg by an admin
if input.sender.startswith('#'): return
2014-07-19 11:13:28 -07:00
if input.admin:
2013-01-07 10:00:44 -08:00
msg = '\x01ACTION %s\x01' % input.group(3)
phenny.msg(input.group(2) or input.sender, msg)
me.rule = (['me'], r'(#?\S+) (.+)')
me.priority = 'low'
2014-02-04 06:16:22 -08:00
def py(phenny, input):
if input.owner:
phenny.say(repr(eval(input.group(2))))
py.commands = ['py']
py.priority = 'high'
2014-07-19 11:13:28 -07:00
if __name__ == '__main__':
2014-07-20 07:13:59 -07:00
print(__doc__.strip())