Skip to content

Commit

Permalink
Move things around
Browse files Browse the repository at this point in the history
  • Loading branch information
Elad Alfassa committed Nov 9, 2012
0 parents commit 682f957
Show file tree
Hide file tree
Showing 46 changed files with 6,254 additions and 0 deletions.
Empty file added __init__.py
Empty file.
109 changes: 109 additions & 0 deletions admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#!/usr/bin/env python
# coding=utf-8
"""
admin.py - Willie Admin Module
Copyright 2010-2011, Sean B. Palmer (inamidst.com) and Michael Yanovich (yanovich.net)
Copyright © 2012, Elad Alfassa, <[email protected]>
Licensed under the Eiffel Forum License 2.
http://willie.dfbta.net
"""

import os

def join(willie, trigger):
"""Join the specified channel. This is an admin-only command."""
# Can only be done in privmsg by an admin
if trigger.sender.startswith('#'):
return
if trigger.admin:
channel, key = trigger.group(1), trigger.group(2)
if not key:
willie.join(channel)
else:
willie.join(channel, key)
join.rule = r'\.join (#\S+)(?: *(\S+))?'
join.priority = 'low'
join.example = '.join #example or .join #example key'

def part(willie, trigger):
"""Part the specified channel. This is an admin-only command."""
# Can only be done in privmsg by an admin
if trigger.sender.startswith('#'):
return
if trigger.admin:
willie.part(trigger.group(2).strip())
part.commands = ['part']
part.priority = 'low'
part.example = '.part #example'

def quit(willie, trigger):
"""Quit from the server. This is an owner-only command."""
# Can only be done in privmsg by the owner
if trigger.sender.startswith('#'):
return
if trigger.owner:
quit_message = 'Quitting on command from %s' % trigger.nick
if trigger.group(2) is not None:
quit_message = trigger.group(2)
willie.quit(quit_message)
quit.commands = ['quit']
quit.priority = 'low'

def msg(willie, trigger):
"""
Send a message to a given channel or nick. Can only be done in privmsg by an
admin.
"""
if trigger.sender.startswith('#'):
return
a, b = trigger.group(2), trigger.group(3)
if (not a) or (not b):
return
if trigger.admin:
willie.msg(a, b)
msg.rule = (['msg'], r'(#?\S+) (.+)')
msg.priority = 'low'
msg.example = '.msg #YourPants Does anyone else smell neurotoxin?'

def me(willie, trigger):
"""
Send an ACTION (/me) to a given channel or nick. Can only be done in privmsg
by an admin.
"""
if trigger.sender.startswith('#'):
return
if trigger.admin:
msg = '\x01ACTION %s\x01' % trigger.group(3)
willie.msg(trigger.group(2), msg)
me.rule = (['me'], r'(#?\S+) (.*)')
me.priority = 'low'

def defend_ground(willie, trigger):
"""
This function monitors all kicks across all channels willie is in. If he
detects that she is the one kicked she'll automatically join that channel.
WARNING: This may not be needed and could cause problems if willie becomes
annoying. Please use this with caution.
"""
channel = trigger.sender
willie.write(['JOIN'], channel)
defend_ground.event = 'KICK'
defend_ground.rule = '.*'
defend_ground.priority = 'low'

def mode(willie, trigger):
"""Set a user mode on Willie. Can only be done in privmsg by an admin."""
if trigger.sender.startswith('#'):
return
if trigger.admin:
mode = trigger.group(1)
willie.write(('MODE ', willie.nick + ' ' + mode))
mode.rule = r'\.mode ([\+-]\S+)'
mode.priority = 'low'

if __name__ == '__main__':
print __doc__.strip()

Loading

0 comments on commit 682f957

Please sign in to comment.