Remove some trailing whitespace

This commit is contained in:
nyuszika7h 2015-03-27 20:09:45 +01:00
parent ad8f3a720a
commit 440f4beca5
7 changed files with 77 additions and 77 deletions

View File

@ -46,7 +46,7 @@ def on_privmsg(cli, rawnick, chan, msg, notice = False):
else: else:
if botconfig.IGNORE_HIDDEN_COMMANDS and chan[0] in prefixes: if botconfig.IGNORE_HIDDEN_COMMANDS and chan[0] in prefixes:
return return
if (notice and ((chan != botconfig.NICK and not botconfig.ALLOW_NOTICE_COMMANDS) or if (notice and ((chan != botconfig.NICK and not botconfig.ALLOW_NOTICE_COMMANDS) or
(chan == botconfig.NICK and not botconfig.ALLOW_PRIVATE_NOTICE_COMMANDS))): (chan == botconfig.NICK and not botconfig.ALLOW_PRIVATE_NOTICE_COMMANDS))):
return # not allowed in settings return # not allowed in settings
@ -84,7 +84,7 @@ def on_privmsg(cli, rawnick, chan, msg, notice = False):
else: else:
notify_error(cli, chan, log) notify_error(cli, chan, log)
def __unhandled__(cli, prefix, cmd, *args): def __unhandled__(cli, prefix, cmd, *args):
currmod = ld.MODULES[ld.CURRENT_MODULE] currmod = ld.MODULES[ld.CURRENT_MODULE]
@ -101,7 +101,7 @@ def __unhandled__(cli, prefix, cmd, *args):
else: else:
notify_error(cli, botconfig.CHANNEL, log) notify_error(cli, botconfig.CHANNEL, log)
COMMANDS = {} COMMANDS = {}
HOOKS = {} HOOKS = {}
@ -110,29 +110,29 @@ hook = decorators.generate(HOOKS, raw_nick=True, permissions=False)
def connect_callback(cli): def connect_callback(cli):
def prepare_stuff(*args): def prepare_stuff(*args):
cli.join(botconfig.CHANNEL) cli.join(botconfig.CHANNEL)
cli.join(botconfig.ALT_CHANNELS) cli.join(botconfig.ALT_CHANNELS)
cli.join(",".join(chan.lstrip("".join(var.STATUSMSG_PREFIXES)) for chan in botconfig.DEV_CHANNEL.split(","))) cli.join(",".join(chan.lstrip("".join(var.STATUSMSG_PREFIXES)) for chan in botconfig.DEV_CHANNEL.split(",")))
cli.msg("ChanServ", "op "+botconfig.CHANNEL) cli.msg("ChanServ", "op "+botconfig.CHANNEL)
cli.cap("REQ", "extended-join") cli.cap("REQ", "extended-join")
cli.cap("REQ", "account-notify") cli.cap("REQ", "account-notify")
try: try:
ld.MODULES[ld.CURRENT_MODULE].connect_callback(cli) ld.MODULES[ld.CURRENT_MODULE].connect_callback(cli)
except AttributeError: except AttributeError:
pass # no connect_callback for this one pass # no connect_callback for this one
cli.nick(botconfig.NICK) # very important (for regain/release) cli.nick(botconfig.NICK) # very important (for regain/release)
prepare_stuff = hook("endofmotd", hookid=294)(prepare_stuff) prepare_stuff = hook("endofmotd", hookid=294)(prepare_stuff)
def mustregain(cli, *blah): def mustregain(cli, *blah):
if not botconfig.PASS: if not botconfig.PASS:
return return
cli.ns_regain() cli.ns_regain()
def mustrelease(cli, *rest): def mustrelease(cli, *rest):
if not botconfig.PASS: if not botconfig.PASS:
return # prevents the bot from trying to release without a password return # prevents the bot from trying to release without a password
@ -144,13 +144,13 @@ def connect_callback(cli):
def must_use_temp_nick(cli, *etc): def must_use_temp_nick(cli, *etc):
cli.nick(botconfig.NICK+"_") cli.nick(botconfig.NICK+"_")
cli.user(botconfig.NICK, "") cli.user(botconfig.NICK, "")
decorators.unhook(HOOKS, 239) decorators.unhook(HOOKS, 239)
hook("unavailresource")(mustrelease) hook("unavailresource")(mustrelease)
hook("nicknameinuse")(mustregain) hook("nicknameinuse")(mustregain)
if botconfig.SASL_AUTHENTICATION: if botconfig.SASL_AUTHENTICATION:
@hook("authenticate") @hook("authenticate")
def auth_plus(cli, something, plus): def auth_plus(cli, something, plus):
if plus == "+": if plus == "+":
@ -158,16 +158,16 @@ def connect_callback(cli):
pass_b = bytes(botconfig.PASS, "utf-8") pass_b = bytes(botconfig.PASS, "utf-8")
secrt_msg = b'\0'.join((nick_b, nick_b, pass_b)) secrt_msg = b'\0'.join((nick_b, nick_b, pass_b))
cli.send("AUTHENTICATE " + b64encode(secrt_msg).decode("utf-8")) cli.send("AUTHENTICATE " + b64encode(secrt_msg).decode("utf-8"))
@hook("cap") @hook("cap")
def on_cap(cli, svr, mynick, ack, cap): def on_cap(cli, svr, mynick, ack, cap):
if ack.upper() == "ACK" and "sasl" in cap: if ack.upper() == "ACK" and "sasl" in cap:
cli.send("AUTHENTICATE PLAIN") cli.send("AUTHENTICATE PLAIN")
@hook("903") @hook("903")
def on_successful_auth(cli, blah, blahh, blahhh): def on_successful_auth(cli, blah, blahh, blahhh):
cli.cap("END") cli.cap("END")
@hook("904") @hook("904")
@hook("905") @hook("905")
@hook("906") @hook("906")
@ -176,9 +176,9 @@ def connect_callback(cli):
cli.quit() cli.quit()
alog("Authentication failed. Did you fill the account name "+ alog("Authentication failed. Did you fill the account name "+
"in botconfig.USERNAME if it's different from the bot nick?") "in botconfig.USERNAME if it's different from the bot nick?")
@hook("ping") @hook("ping")
def on_ping(cli, prefix, server): def on_ping(cli, prefix, server):
cli.send('PONG', server) cli.send('PONG', server)

View File

@ -1924,7 +1924,7 @@ def stop_game(cli, winner = "", abort = False):
if p.startswith("(dced)"): if p.startswith("(dced)"):
p = p[6:] p = p[6:]
if p in origroles and role not in var.TEMPLATE_RESTRICTIONS.keys(): if p in origroles and role not in var.TEMPLATE_RESTRICTIONS.keys():
playersformatted.append("\u0002{0}\u0002 ({1}{2})".format(p, playersformatted.append("\u0002{0}\u0002 ({1}{2})".format(p,
"" if prev else "was ", origroles[p])) "" if prev else "was ", origroles[p]))
prev = True prev = True
else: else:
@ -2143,7 +2143,7 @@ def chk_win(cli, end_game = True):
with var.GRAVEYARD_LOCK: with var.GRAVEYARD_LOCK:
if var.PHASE not in ("day", "night"): if var.PHASE not in ("day", "night"):
return False #some other thread already ended game probably return False #some other thread already ended game probably
lwolves = len(var.list_players(var.WOLFCHAT_ROLES)) lwolves = len(var.list_players(var.WOLFCHAT_ROLES))
cubs = len(var.ROLES["wolf cub"]) if "wolf cub" in var.ROLES else 0 cubs = len(var.ROLES["wolf cub"]) if "wolf cub" in var.ROLES else 0
lrealwolves = len(var.list_players(var.WOLF_ROLES)) - cubs lrealwolves = len(var.list_players(var.WOLF_ROLES)) - cubs
@ -3598,7 +3598,7 @@ def transition_day(cli, gameid=0):
"https://i.imgur.com/b8HAvjL.gifv", "https://i.imgur.com/b8HAvjL.gifv",
"https://i.imgur.com/PIIfL15.gifv"] "https://i.imgur.com/PIIfL15.gifv"]
)) ))
if victim in var.HVISITED.values() and victim in bywolves: # victim was visited by some harlot and victim was attacked by wolves if victim in var.HVISITED.values() and victim in bywolves: # victim was visited by some harlot and victim was attacked by wolves
for hlt in var.HVISITED.keys(): for hlt in var.HVISITED.keys():
if var.HVISITED[hlt] == victim: if var.HVISITED[hlt] == victim:
@ -3719,7 +3719,7 @@ def transition_day(cli, gameid=0):
if havetotem: if havetotem:
message.append("\u0002{0}\u0002 seem{1} to be in possession of a mysterious totem...".format(havetotem, "ed" if havetotem in dead else "s")) message.append("\u0002{0}\u0002 seem{1} to be in possession of a mysterious totem...".format(havetotem, "ed" if havetotem in dead else "s"))
cli.msg(chan, "\n".join(message)) cli.msg(chan, "\n".join(message))
if chk_win(cli): # if after the last person is killed, one side wins, then actually end the game here if chk_win(cli): # if after the last person is killed, one side wins, then actually end the game here
return return
@ -3812,7 +3812,7 @@ def no_lynch(cli, nick, chan, rest):
if nick not in var.NO_LYNCH: if nick not in var.NO_LYNCH:
var.NO_LYNCH.append(nick) var.NO_LYNCH.append(nick)
cli.msg(chan, "\u0002{0}\u0002 votes to not lynch anyone today.".format(nick)) cli.msg(chan, "\u0002{0}\u0002 votes to not lynch anyone today.".format(nick))
chk_decision(cli) chk_decision(cli)
return return
@ -4085,7 +4085,7 @@ def check_exchange(cli, actor, nick):
if nick_role == "shaman": if nick_role == "shaman":
pm(cli, actor, "You have a \u0002{0}\u0002 totem.".format(nick_totem)) pm(cli, actor, "You have a \u0002{0}\u0002 totem.".format(nick_totem))
var.TOTEMS[actor] = nick_totem var.TOTEMS[actor] = nick_totem
elif nick_role in var.WOLFCHAT_ROLES and actor_role not in var.WOLFCHAT_ROLES: elif nick_role in var.WOLFCHAT_ROLES and actor_role not in var.WOLFCHAT_ROLES:
pl = var.list_players() pl = var.list_players()
random.shuffle(pl) random.shuffle(pl)
pl.remove(actor) # remove self from list pl.remove(actor) # remove self from list
@ -4121,7 +4121,7 @@ def check_exchange(cli, actor, nick):
if actor_role == "shaman": if actor_role == "shaman":
pm(cli, nick, "You have a \u0002{0}\u0002 totem.".format(actor_totem)) pm(cli, nick, "You have a \u0002{0}\u0002 totem.".format(actor_totem))
var.TOTEMS[nick] = actor_totem var.TOTEMS[nick] = actor_totem
elif actor_role in var.WOLFCHAT_ROLES and nick_role not in var.WOLFCHAT_ROLES: elif actor_role in var.WOLFCHAT_ROLES and nick_role not in var.WOLFCHAT_ROLES:
pl = var.list_players() pl = var.list_players()
random.shuffle(pl) random.shuffle(pl)
pl.remove(nick) # remove self from list pl.remove(nick) # remove self from list
@ -4471,7 +4471,7 @@ def guard(cli, nick, chan, rest):
var.LASTGUARDED[nick] = nick var.LASTGUARDED[nick] = nick
pm(cli, nick, "You have decided to guard yourself tonight.") pm(cli, nick, "You have decided to guard yourself tonight.")
else: else:
victim = choose_target(nick, victim) victim = choose_target(nick, victim)
if check_exchange(cli, nick, victim): if check_exchange(cli, nick, victim):
return return
var.GUARDED[nick] = victim var.GUARDED[nick] = victim
@ -5234,7 +5234,7 @@ def transition_night(cli):
# this makes playing the day transition message easier since we can keep # this makes playing the day transition message easier since we can keep
# var.BITTEN around for a day after they turn # var.BITTEN around for a day after they turn
chumprole = var.get_role(chump) chumprole = var.get_role(chump)
if chumprole in var.WOLF_ROLES: if chumprole in var.WOLF_ROLES:
del var.BITTEN[chump] del var.BITTEN[chump]
continue continue
@ -6417,7 +6417,7 @@ def allow_deny(cli, nick, chan, rest, mode):
var.remove_allow(cloak, command) var.remove_allow(cloak, command)
else: else:
var.remove_deny(cloak, command) var.remove_deny(cloak, command)
if cloak in variable and variable[cloak]: if cloak in variable and variable[cloak]:
msg = "\u0002{0}\u0002 (Host: {1}) is now {2} the following {3}commands: {4}{5}.".format( msg = "\u0002{0}\u0002 (Host: {1}) is now {2} the following {3}commands: {4}{5}.".format(
data[0], cloak, "allowed" if mode == 'allow' else "denied", "special " if mode == 'allow' else "", botconfig.CMD_CHAR, ", {0}".format(botconfig.CMD_CHAR).join(variable[cloak])) data[0], cloak, "allowed" if mode == 'allow' else "denied", "special " if mode == 'allow' else "", botconfig.CMD_CHAR, ", {0}".format(botconfig.CMD_CHAR).join(variable[cloak]))
@ -7106,7 +7106,7 @@ def game(cli, nick, chan, rest):
if rest: if rest:
gamemode = rest.lower().split()[0] gamemode = rest.lower().split()[0]
else: else:
gamemodes = ", ".join(["\002{}\002".format(gamemode) if len(var.list_players()) in range(var.GAME_MODES[gamemode][1], gamemodes = ", ".join(["\002{}\002".format(gamemode) if len(var.list_players()) in range(var.GAME_MODES[gamemode][1],
var.GAME_MODES[gamemode][2]+1) else gamemode for gamemode in var.GAME_MODES.keys() if gamemode != "roles"]) var.GAME_MODES[gamemode][2]+1) else gamemode for gamemode in var.GAME_MODES.keys() if gamemode != "roles"])
cli.notice(nick, "No game mode specified. Available game modes: " + gamemodes) cli.notice(nick, "No game mode specified. Available game modes: " + gamemodes)
return return
@ -7121,7 +7121,7 @@ def game(cli, nick, chan, rest):
cli.notice(nick, "\002{0}\002 is not a valid game mode.".format(gamemode)) cli.notice(nick, "\002{0}\002 is not a valid game mode.".format(gamemode))
return return
gamemode = match gamemode = match
if gamemode != "roles": if gamemode != "roles":
var.GAMEMODE_VOTES[nick] = gamemode var.GAMEMODE_VOTES[nick] = gamemode
cli.msg(chan, "\002{0}\002 votes for the \002{1}\002 game mode.".format(nick, gamemode)) cli.msg(chan, "\002{0}\002 votes for the \002{1}\002 game mode.".format(nick, gamemode))

View File

@ -21,12 +21,12 @@ import traceback
import sys import sys
import ssl import ssl
from oyoyo.parse import parse_raw_irc_command from oyoyo.parse import parse_raw_irc_command
# Adapted from http://code.activestate.com/recipes/511490-implementation-of-the-token-bucket-algorithm/ # Adapted from http://code.activestate.com/recipes/511490-implementation-of-the-token-bucket-algorithm/
class TokenBucket(object): class TokenBucket(object):
"""An implementation of the token bucket algorithm. """An implementation of the token bucket algorithm.
>>> bucket = TokenBucket(80, 0.5) >>> bucket = TokenBucket(80, 0.5)
>>> bucket.consume(1) >>> bucket.consume(1)
""" """
@ -54,9 +54,9 @@ class TokenBucket(object):
self._tokens = min(self.capacity, self._tokens + delta) self._tokens = min(self.capacity, self._tokens + delta)
self.timestamp = now self.timestamp = now
return self._tokens return self._tokens
def add_commands(d): def add_commands(d):
def dec(cls): def dec(cls):
for c in d: for c in d:
@ -78,25 +78,25 @@ class IRCClient(object):
""" """
def __init__(self, cmd_handler, **kwargs): def __init__(self, cmd_handler, **kwargs):
""" the first argument should be an object with attributes/methods named """ the first argument should be an object with attributes/methods named
as the irc commands. You may subclass from one of the classes in as the irc commands. You may subclass from one of the classes in
oyoyo.cmdhandler for convenience but it is not required. The oyoyo.cmdhandler for convenience but it is not required. The
methods should have arguments (prefix, args). prefix is methods should have arguments (prefix, args). prefix is
normally the sender of the command. args is a list of arguments. normally the sender of the command. args is a list of arguments.
Its recommened you subclass oyoyo.cmdhandler.DefaultCommandHandler, Its recommened you subclass oyoyo.cmdhandler.DefaultCommandHandler,
this class provides defaults for callbacks that are required for this class provides defaults for callbacks that are required for
normal IRC operation. normal IRC operation.
all other arguments should be keyword arguments. The most commonly all other arguments should be keyword arguments. The most commonly
used will be nick, host and port. You can also specify an "on connect" used will be nick, host and port. You can also specify an "on connect"
callback. ( check the source for others ) callback. ( check the source for others )
Warning: By default this class will not block on socket operations, this Warning: By default this class will not block on socket operations, this
means if you use a plain while loop your app will consume 100% cpu. means if you use a plain while loop your app will consume 100% cpu.
To enable blocking pass blocking=True. To enable blocking pass blocking=True.
""" """
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.nickname = "" self.nickname = ""
self.hostmask = "" self.hostmask = ""
self.ident = "" self.ident = ""
@ -111,12 +111,12 @@ class IRCClient(object):
self.use_ssl = False self.use_ssl = False
self.lock = threading.RLock() self.lock = threading.RLock()
self.stream_handler = lambda output, level=None: print(output) self.stream_handler = lambda output, level=None: print(output)
self.tokenbucket = TokenBucket(23, 1.73) self.tokenbucket = TokenBucket(23, 1.73)
self.__dict__.update(kwargs) self.__dict__.update(kwargs)
self.command_handler = cmd_handler self.command_handler = cmd_handler
if self.use_ssl: if self.use_ssl:
self.socket = ssl.wrap_socket(self.socket) self.socket = ssl.wrap_socket(self.socket)
@ -124,8 +124,8 @@ class IRCClient(object):
def send(self, *args, **kwargs): def send(self, *args, **kwargs):
""" send a message to the connected server. all arguments are joined """ send a message to the connected server. all arguments are joined
with a space for convenience, for example the following are identical with a space for convenience, for example the following are identical
>>> cli.send("JOIN " + some_room) >>> cli.send("JOIN " + some_room)
>>> cli.send("JOIN", some_room) >>> cli.send("JOIN", some_room)
@ -134,7 +134,7 @@ class IRCClient(object):
the 'encoding' keyword argument (default 'utf8'). the 'encoding' keyword argument (default 'utf8').
In python 3, all args must be of type str or bytes, *BUT* if they are In python 3, all args must be of type str or bytes, *BUT* if they are
str they will be converted to bytes with the encoding specified by the str they will be converted to bytes with the encoding specified by the
'encoding' keyword argument (default 'utf8'). 'encoding' keyword argument (default 'utf8').
""" """
with self.lock: with self.lock:
# Convert all args to bytes if not already # Convert all args to bytes if not already
@ -154,14 +154,14 @@ class IRCClient(object):
msg = bytes(" ", "utf_8").join(bargs) msg = bytes(" ", "utf_8").join(bargs)
self.stream_handler('---> send {0}'.format(str(msg)[1:])) self.stream_handler('---> send {0}'.format(str(msg)[1:]))
while not self.tokenbucket.consume(1): while not self.tokenbucket.consume(1):
time.sleep(0.3) time.sleep(0.3)
self.socket.send(msg + bytes("\r\n", "utf_8")) self.socket.send(msg + bytes("\r\n", "utf_8"))
def connect(self): def connect(self):
""" initiates the connection to the server set in self.host:self.port """ initiates the connection to the server set in self.host:self.port
and returns a generator object. and returns a generator object.
>>> cli = IRCClient(my_handler, host="irc.freenode.net", port=6667) >>> cli = IRCClient(my_handler, host="irc.freenode.net", port=6667)
>>> g = cli.connect() >>> g = cli.connect()
@ -183,32 +183,32 @@ class IRCClient(object):
break break
if not self.blocking: if not self.blocking:
self.socket.setblocking(0) self.socket.setblocking(0)
if not self.sasl_auth: if not self.sasl_auth:
self.send("PASS {0}:{1}".format(self.authname if self.authname else self.nickname, self.send("PASS {0}:{1}".format(self.authname if self.authname else self.nickname,
self.password if self.password else "NOPASS")) self.password if self.password else "NOPASS"))
else: else:
self.cap("LS") self.cap("LS")
self.nick(self.nickname) self.nick(self.nickname)
self.user(self.ident, self.real_name) self.user(self.ident, self.real_name)
if self.sasl_auth: if self.sasl_auth:
self.cap("REQ", "multi-prefix") self.cap("REQ", "multi-prefix")
self.cap("REQ", "sasl") self.cap("REQ", "sasl")
if self.connect_cb: if self.connect_cb:
try: try:
self.connect_cb(self) self.connect_cb(self)
except Exception as e: except Exception as e:
traceback.print_exc() traceback.print_exc()
raise e raise e
buffer = bytes() buffer = bytes()
while not self._end: while not self._end:
try: try:
buffer += self.socket.recv(1024) buffer += self.socket.recv(1024)
except socket.error as e: except socket.error as e:
if False and not self.blocking and e.errno == 11: if False and not self.blocking and e.errno == 11:
pass pass
else: else:
@ -219,14 +219,14 @@ class IRCClient(object):
for el in data: for el in data:
prefix, command, args = parse_raw_irc_command(el) prefix, command, args = parse_raw_irc_command(el)
try: try:
enc = "utf8" enc = "utf8"
fargs = [arg.decode(enc) for arg in args if isinstance(arg,bytes)] fargs = [arg.decode(enc) for arg in args if isinstance(arg,bytes)]
except UnicodeDecodeError: except UnicodeDecodeError:
enc = "latin1" enc = "latin1"
fargs = [arg.decode(enc) for arg in args if isinstance(arg,bytes)] fargs = [arg.decode(enc) for arg in args if isinstance(arg,bytes)]
self.stream_handler("processCommand ({2}){0}({1})".format(command, self.stream_handler("processCommand ({2}){0}({1})".format(command,
fargs, prefix), level="debug") fargs, prefix), level="debug")
try: try:
@ -244,7 +244,7 @@ class IRCClient(object):
raise e # ? raise e # ?
yield True yield True
finally: finally:
if self.socket: if self.socket:
self.stream_handler('closing socket') self.stream_handler('closing socket')
self.socket.close() self.socket.close()
yield False yield False
@ -291,4 +291,4 @@ class IRCClient(object):
if not next(conn): if not next(conn):
self.stream_handler("Calling sys.exit()...", level="warning") self.stream_handler("Calling sys.exit()...", level="warning")
sys.exit() sys.exit()

View File

@ -59,7 +59,7 @@ def parse_raw_irc_command(element):
if args[0].startswith(bytes(':', 'utf_8')): if args[0].startswith(bytes(':', 'utf_8')):
args = [bytes(" ", "utf_8").join(args)[1:]] args = [bytes(" ", "utf_8").join(args)[1:]]
else: else:
for idx, arg in enumerate(args): for idx, arg in enumerate(args):
if arg.startswith(bytes(':', 'utf_8')): if arg.startswith(bytes(':', 'utf_8')):
args = args[:idx] + [bytes(" ", 'utf_8').join(args[idx:])[1:]] args = args[:idx] + [bytes(" ", 'utf_8').join(args[idx:])[1:]]
break break
@ -87,4 +87,4 @@ def parse_nick(name):
return (nick, mode, rest, None) return (nick, mode, rest, None)
return (nick, mode, user, host) return (nick, mode, user, host)

View File

@ -82,7 +82,7 @@ DISABLE_DEBUG_MODE_STASIS = True
# Minimum number of players needed for mad scientist to skip over dead people when determining who is next to them # Minimum number of players needed for mad scientist to skip over dead people when determining who is next to them
# Set to 0 to always skip over dead players. Note this is number of players that !joined, NOT number of players currently alive # Set to 0 to always skip over dead players. Note this is number of players that !joined, NOT number of players currently alive
MAD_SCIENTIST_SKIPS_DEAD_PLAYERS = 16 MAD_SCIENTIST_SKIPS_DEAD_PLAYERS = 16
CARE_BOLD = False CARE_BOLD = False
CARE_COLOR = False CARE_COLOR = False
@ -308,7 +308,7 @@ def is_owner(nick, cloak=None, acc=None):
def plural(role): def plural(role):
bits = role.split() bits = role.split()
bits[-1] = {"person": "people", "wolf": "wolves"}.get(bits[-1], bits[-1] + "s") bits[-1] = {"person": "people", "wolf": "wolves"}.get(bits[-1], bits[-1] + "s")
return " ".join(bits) return " ".join(bits)
def list_players(roles = None): def list_players(roles = None):
if roles == None: if roles == None:
@ -373,7 +373,7 @@ def role_order():
vils = [role for role in ROLE_GUIDE.keys() if role not in WOLFTEAM_ROLES+templates] vils = [role for role in ROLE_GUIDE.keys() if role not in WOLFTEAM_ROLES+templates]
vils.sort() vils.sort()
return WOLFTEAM_ROLES + vils + templates return WOLFTEAM_ROLES + vils + templates
def break_long_message(phrases, joinstr = " "): def break_long_message(phrases, joinstr = " "):
message = "" message = ""

View File

@ -152,12 +152,12 @@ def generate(fdict, permissions=True, **kwargs):
innerf.aftergame = False innerf.aftergame = False
innerf.__doc__ = f.__doc__ innerf.__doc__ = f.__doc__
return innerf return innerf
return dec return dec
return lambda *args, **kwarargs: cmd(*args, **kwarargs) if kwarargs else cmd(*args, **kwargs) return lambda *args, **kwarargs: cmd(*args, **kwarargs) if kwarargs else cmd(*args, **kwargs)
def unhook(hdict, hookid): def unhook(hdict, hookid):
for cmd in list(hdict.keys()): for cmd in list(hdict.keys()):
for x in hdict[cmd]: for x in hdict[cmd]:

View File

@ -13,13 +13,13 @@ for modfile in os.listdir("modules"):
continue # not a module continue # not a module
if not os.path.isfile("modules/"+modfile): if not os.path.isfile("modules/"+modfile):
continue # not a file continue # not a file
modfile = modfile[:-3] modfile = modfile[:-3]
logger(None)("Loading module "+modfile) logger(None)("Loading module "+modfile)
MODULES[modfile] = getattr(__import__("modules."+modfile), modfile) MODULES[modfile] = getattr(__import__("modules."+modfile), modfile)
if botconfig.DEFAULT_MODULE in MODULES.keys(): if botconfig.DEFAULT_MODULE in MODULES.keys():
CURRENT_MODULE = botconfig.DEFAULT_MODULE.lower() CURRENT_MODULE = botconfig.DEFAULT_MODULE.lower()
else: else: