Created
September 29, 2011 05:55
-
-
Save myano/1250083 to your computer and use it in GitHub Desktop.
Old QuakeNet Signups module for jenni
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
signups.py - Signups Module | |
Copyright 2011 - Michael Yanovich, yanovich.net | |
Licensed under the Eiffel Forum License 2. | |
This module collects a list of names by people who type ".signup" | |
and then displays them. | |
""" | |
from copy import copy | |
import time | |
import re | |
ops = [ ] | |
signed = [ ] | |
curious_nick = "" | |
permission = False | |
def open(jenni, input): | |
global permission | |
getnames(jenni, input) | |
time.sleep(1.5) | |
if input.nick not in ops: | |
jenni.reply("I'm sorry but only ops can enable the commands!") | |
return | |
permission = True | |
jenni.reply("-- Signups are OPEN -- All commands have been activated!") | |
open.commands = ['open'] | |
open.thread = True | |
def close(jenni, input): | |
global permission | |
if input.nick not in ops: | |
jenni.reply("I'm sorry but only ops can disable the commands!") | |
return | |
permission = False | |
jenni.reply("-- Signups are CLOSED -- All commands have been disabled!") | |
close.commands = ['close'] | |
close.thread = False | |
def joins(jenni, input): | |
time.sleep(1) | |
getnames(jenni, input) | |
time.sleep(1.5) | |
joins.event = 'JOIN' | |
joins.rule = r'(.*)' | |
def clear(jenni, input): | |
""".clear -- Clears the list of people signed up.""" | |
if not permission: | |
jenni.reply("All commands are currently disabled.") | |
return | |
if input.nick not in ops: | |
jenni.reply("I can only clear the list if an ops tells me to.") | |
return | |
global signed | |
signed = [ ] | |
jenni.reply("The signup list has been cleared.") | |
clear.commands = ['clear'] | |
clear.thread = False | |
def getnames(jenni, input): | |
channel = str(input.sender).lstrip().rstrip() | |
jenni.write(['NAMES'], channel) | |
print "I'M GETTING NAMES" | |
def getnames2(jenni, input): | |
global ops | |
ops = [ ] | |
a = unicode(input.group()).split() | |
for x in a: | |
if x.startswith("@"): | |
k = re.escape(x[1:]) | |
global ops | |
ops.append(k) | |
getnames2.event = '353' | |
getnames2.rule = r'(.*)' | |
getnames2.thread = True | |
def list(jenni, input): | |
""".list -- Print the list of people currently signed up to the channel.""" | |
if not permission: | |
jenni.reply("All commands are currently disabled.") | |
return | |
msg = " >> " | |
for nick in signed: | |
msg += nick + ", " | |
if msg.endswith(", "): | |
msg = msg[:-2] | |
if len(signed) == 0: | |
msg = "No one is currently signed up." | |
jenni.reply(msg) | |
list.commands = ['list'] | |
def signup(jenni, input): | |
""".signup -- Signs up the nick who issued the command.""" | |
if not permission: | |
jenni.reply("All commands are currently disabled.") | |
return | |
getnames(jenni, input) | |
global signed | |
if input.nick not in signed: | |
signed.append(unicode(re.escape(input.nick))) | |
jenni.reply("You have been signed up, at position: " + unicode(len(signed))) | |
else: | |
jenni.reply("You are already signed up!") | |
signup.commands = ['signup'] | |
signup.thread = False | |
def add(jenni, input): | |
""".add <nick> <pos> -- adds given nick to a specific position in the list of people signed up.""" | |
if not permission: | |
jenni.reply("All commands are currently disabled.") | |
return | |
global signed | |
if input.nick not in ops: | |
jenni.reply("I'm sorry but this command is only available to ops.") | |
return | |
text = unicode(input.group()).split() | |
if len(text) != 3: | |
jenni.reply("Invalid usage try, " + jenni.config.nick + ": help add") | |
return | |
nick = re.escape(text[1]) | |
try: | |
idx = int(text[2]) | |
idx -= 1 | |
except: | |
jenni.reply("Invalid usage try, " + jenni.config.nick + ": help add") | |
return | |
signed.insert(idx, nick) | |
jenni.reply("I have added " + nick + " at position: " + text[2]) | |
add.commands = ['add'] | |
add.thread = False | |
def signout(jenni, input): | |
""".remove <nick> or .remove -- removes player if no parameter specified. Removes a specific player if specified.""" | |
if not permission: | |
jenni.reply("All commands are currently disabled.") | |
return | |
global signed | |
text = unicode(input.group()).split() | |
#jenni.say(unicode(text)) | |
if len(signed) == 0: | |
jenni.reply("Invalid usage see, " + jenni.config.nick + ": help remove") | |
return | |
if len(text) >= 2: | |
if input.nick in ops: | |
bnick = text[1] | |
nick = re.escape(text[1]) | |
else: | |
jenni.say("I'm sorry but I can only remove specific people if an ops tells me to.") | |
return | |
elif len(text) == 1: | |
bnick = input.nick | |
nick = re.escape(input.nick) | |
idx = signed.index(nick) | |
del signed[idx] | |
if bnick == input.nick: | |
nick = "you" | |
jenni.reply("I have removed " + nick + " from the list.") | |
signout.commands = ['signout', 'remove'] | |
signout.thread = False | |
def move(jenni, input): | |
""".move <nick> <pos> -- moves a given nick to a specific position.""" | |
if not permission: | |
jenni.reply("All commands are currently disabled.") | |
return | |
if input.nick not in ops: | |
jenni.reply("I'm sorry but this command is only available to ops.") | |
return | |
global signed | |
text = unicode(input.group()).split() | |
if len(signed) == 0: return | |
if len(text) == 3: | |
if input.nick in ops: | |
nick = unicode(re.escape(text[1])) | |
try: | |
pos = int(text[2]) | |
except: | |
jenni.reply("Please specify a number after the nick.") | |
return | |
pos -= 1 | |
else: return | |
idx = signed.index(nick) | |
del signed[idx] | |
signed.insert(pos, nick) | |
jenni.reply("I have moved " + nick + " to position: " + str(pos+1)) | |
move.commands = ['move'] | |
move.thread = False | |
if __name__ == '__main__': | |
print __doc__.strip() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment