Merge remote-tracking branch 'upstream/master'
Conflicts: modules/wolfgame.py settings/wolfgame.py
This commit is contained in:
commit
a670925779
@ -92,6 +92,8 @@ var.LOGGER = WolfgameLogger(var.LOG_FILENAME, var.BARE_LOG_FILENAME)
|
|||||||
|
|
||||||
var.JOINED_THIS_GAME = [] # keeps track of who already joined this game at least once (cloaks)
|
var.JOINED_THIS_GAME = [] # keeps track of who already joined this game at least once (cloaks)
|
||||||
|
|
||||||
|
var.OPPED = False # Keeps track of whether the bot is opped
|
||||||
|
|
||||||
if botconfig.DEBUG_MODE:
|
if botconfig.DEBUG_MODE:
|
||||||
var.NIGHT_TIME_LIMIT = 0 # 120
|
var.NIGHT_TIME_LIMIT = 0 # 120
|
||||||
var.NIGHT_TIME_WARN = 0 # 90
|
var.NIGHT_TIME_WARN = 0 # 90
|
||||||
@ -137,19 +139,20 @@ def connect_callback(cli):
|
|||||||
|
|
||||||
@hook("mode", hookid=294)
|
@hook("mode", hookid=294)
|
||||||
def on_give_me_ops(cli, blah, blahh, modeaction, target="", *other):
|
def on_give_me_ops(cli, blah, blahh, modeaction, target="", *other):
|
||||||
if modeaction == "+o" and target == botconfig.NICK and var.PHASE == "none":
|
if modeaction == "+o" and target == botconfig.NICK:
|
||||||
|
var.OPPED = True
|
||||||
|
|
||||||
@hook("quietlistend", 294)
|
if var.PHASE == "none":
|
||||||
def on_quietlist_end(cli, svr, nick, chan, *etc):
|
@hook("quietlistend", 294)
|
||||||
if chan == botconfig.CHANNEL:
|
def on_quietlist_end(cli, svr, nick, chan, *etc):
|
||||||
decorators.unhook(HOOKS, 294)
|
if chan == botconfig.CHANNEL:
|
||||||
mass_mode(cli, cmodes)
|
mass_mode(cli, cmodes)
|
||||||
|
|
||||||
cli.mode(botconfig.CHANNEL, "q") # unquiet all
|
cli.mode(botconfig.CHANNEL, "q") # unquiet all
|
||||||
|
cli.mode(botconfig.CHANNEL, "-m") # remove -m mode from channel
|
||||||
cli.mode(botconfig.CHANNEL, "-m") # remove -m mode from channel
|
elif modeaction == "-o" and target == botconfig.NICK:
|
||||||
elif modeaction == "+o" and target == botconfig.NICK and var.PHASE != "none":
|
var.OPPED = False
|
||||||
decorators.unhook(HOOKS, 294) # forget about it
|
cli.msg("ChanServ", "op " + botconfig.CHANNEL)
|
||||||
|
|
||||||
|
|
||||||
cli.who(botconfig.CHANNEL, "%nuhaf")
|
cli.who(botconfig.CHANNEL, "%nuhaf")
|
||||||
@ -416,6 +419,10 @@ def join(cli, nick, chann_, rest):
|
|||||||
|
|
||||||
nick, _, __, cloak = parse_nick(nick)
|
nick, _, __, cloak = parse_nick(nick)
|
||||||
|
|
||||||
|
if not var.OPPED:
|
||||||
|
cli.notice(nick, "Sorry, I'm not opped in {0}.".format(chan))
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cloak = var.USERS[nick]['cloak']
|
cloak = var.USERS[nick]['cloak']
|
||||||
if cloak is not None and cloak in var.STASISED:
|
if cloak is not None and cloak in var.STASISED:
|
||||||
@ -1498,6 +1505,10 @@ def on_join(cli, raw_nick, chan, acc="*", rname=""):
|
|||||||
break
|
break
|
||||||
if nick in var.DCED_PLAYERS.keys():
|
if nick in var.DCED_PLAYERS.keys():
|
||||||
var.PLAYERS[nick] = var.DCED_PLAYERS.pop(nick)
|
var.PLAYERS[nick] = var.DCED_PLAYERS.pop(nick)
|
||||||
|
if nick == botconfig.NICK:
|
||||||
|
var.OPPED = False
|
||||||
|
if nick == "ChanServ" and not var.OPPED:
|
||||||
|
cli.msg("ChanServ", "op " + chan)
|
||||||
|
|
||||||
@cmd("goat")
|
@cmd("goat")
|
||||||
def goat(cli, nick, chan, rest):
|
def goat(cli, nick, chan, rest):
|
||||||
@ -1750,7 +1761,7 @@ hook("quit")(lambda cli, nick, *rest: leave(cli, "quit", nick, rest[0]))
|
|||||||
hook("kick")(lambda cli, nick, *rest: leave(cli, "kick", rest[1]))
|
hook("kick")(lambda cli, nick, *rest: leave(cli, "kick", rest[1]))
|
||||||
|
|
||||||
|
|
||||||
@cmd("quit", "leave", "q")
|
@cmd("quit", "leave")
|
||||||
def leave_game(cli, nick, chan, rest):
|
def leave_game(cli, nick, chan, rest):
|
||||||
"""Quits the game."""
|
"""Quits the game."""
|
||||||
if var.PHASE == "none":
|
if var.PHASE == "none":
|
||||||
@ -3312,7 +3323,10 @@ def relay(cli, nick, rest):
|
|||||||
if (guy in var.PLAYERS and
|
if (guy in var.PLAYERS and
|
||||||
var.PLAYERS[guy]["cloak"] in var.SIMPLE_NOTIFY)], "\02{0}\02 says: {1}".format(nick, rest), True)
|
var.PLAYERS[guy]["cloak"] in var.SIMPLE_NOTIFY)], "\02{0}\02 says: {1}".format(nick, rest), True)
|
||||||
|
|
||||||
|
@pmcmd("")
|
||||||
|
def ctcp_ping(cli, nick, msg):
|
||||||
|
if msg.startswith("\x01PING"):
|
||||||
|
cli.notice(nick, msg)
|
||||||
|
|
||||||
def transition_night(cli):
|
def transition_night(cli):
|
||||||
if var.PHASE == "night":
|
if var.PHASE == "night":
|
||||||
@ -4013,7 +4027,6 @@ def on_error(cli, pfx, msg):
|
|||||||
elif msg.startswith("Closing Link:"):
|
elif msg.startswith("Closing Link:"):
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
|
||||||
@cmd("fstasis", admin_only=True)
|
@cmd("fstasis", admin_only=True)
|
||||||
def fstasis(cli, nick, chan, rest):
|
def fstasis(cli, nick, chan, rest):
|
||||||
"""Admin command for removing or setting stasis penalties."""
|
"""Admin command for removing or setting stasis penalties."""
|
||||||
@ -4022,12 +4035,14 @@ def fstasis(cli, nick, chan, rest):
|
|||||||
if data:
|
if data:
|
||||||
lusers = {k.lower(): v for k, v in var.USERS.items()}
|
lusers = {k.lower(): v for k, v in var.USERS.items()}
|
||||||
user = data[0].lower()
|
user = data[0].lower()
|
||||||
|
#if user not in lusers:
|
||||||
if user not in lusers:
|
# pm(cli, nick, "Sorry, {0} cannot be found.".format(data[0]))
|
||||||
pm(cli, nick, "Sorry, {0} cannot be found.".format(data[0]))
|
# return
|
||||||
return
|
|
||||||
|
if user in lusers:
|
||||||
cloak = lusers[user]['cloak']
|
cloak = lusers[user]['cloak']
|
||||||
|
else:
|
||||||
|
cloak = user
|
||||||
|
|
||||||
if len(data) == 1:
|
if len(data) == 1:
|
||||||
if cloak in var.STASISED:
|
if cloak in var.STASISED:
|
||||||
@ -4233,53 +4248,56 @@ def is_admin(cloak):
|
|||||||
return bool([ptn for ptn in botconfig.OWNERS+botconfig.ADMINS if fnmatch.fnmatch(cloak.lower(), ptn.lower())])
|
return bool([ptn for ptn in botconfig.OWNERS+botconfig.ADMINS if fnmatch.fnmatch(cloak.lower(), ptn.lower())])
|
||||||
|
|
||||||
|
|
||||||
@cmd("admins", "ops")
|
@cmd('admins', 'ops')
|
||||||
def show_admins(cli, nick, chan, rest):
|
def show_admins(cli, nick, chan, rest):
|
||||||
"""Pings the admins that are available."""
|
"""Pings the admins that are available."""
|
||||||
|
|
||||||
admins = []
|
admins = []
|
||||||
pl = var.list_players()
|
pl = var.list_players()
|
||||||
|
|
||||||
if (var.LAST_ADMINS and
|
if (chan != nick and var.LAST_ADMINS and var.LAST_ADMINS +
|
||||||
var.LAST_ADMINS + timedelta(seconds=var.ADMINS_RATE_LIMIT) > datetime.now()):
|
timedelta(seconds=var.ADMINS_RATE_LIMIT) > datetime.now()):
|
||||||
cli.notice(nick, ("This command is rate-limited. " +
|
cli.notice(nick, ('This command is rate-limited. Please wait a while '
|
||||||
"Please wait a while before using it again."))
|
'before using it again.'))
|
||||||
return
|
return
|
||||||
|
|
||||||
if not (var.PHASE in ("day", "night") and nick not in pl):
|
if chan != nick or (var.PHASE in ('day', 'night') or nick in pl):
|
||||||
var.LAST_ADMINS = datetime.now()
|
var.LAST_ADMINS = datetime.now()
|
||||||
|
|
||||||
if var.ADMIN_PINGING:
|
if var.ADMIN_PINGING:
|
||||||
return
|
return
|
||||||
|
|
||||||
var.ADMIN_PINGING = True
|
var.ADMIN_PINGING = True
|
||||||
|
|
||||||
@hook("whoreply", hookid = 4)
|
@hook('whoreply', hookid=4)
|
||||||
def on_whoreply(cli, server, dunno, chan, dunno1,
|
def on_whoreply(cli, server, _, chan, __, cloak, ___, user, status, ____):
|
||||||
cloak, dunno3, user, status, dunno4):
|
|
||||||
if not var.ADMIN_PINGING:
|
if not var.ADMIN_PINGING:
|
||||||
return
|
return
|
||||||
if (is_admin(cloak) and 'G' not in status and
|
|
||||||
user != botconfig.NICK):
|
if is_admin(cloak) and 'G' not in status and user != botconfig.NICK:
|
||||||
admins.append(user)
|
admins.append(user)
|
||||||
|
|
||||||
@hook("endofwho", hookid = 4)
|
@hook('endofwho', hookid=4)
|
||||||
def show(*args):
|
def show(*args):
|
||||||
if not var.ADMIN_PINGING:
|
if not var.ADMIN_PINGING:
|
||||||
return
|
return
|
||||||
|
|
||||||
admins.sort(key=lambda x: x.lower())
|
admins.sort(key=lambda x: x.lower())
|
||||||
|
|
||||||
if chan == nick:
|
if chan == nick:
|
||||||
pm(cli, nick, "Available admins: "+" ".join(admins))
|
pm(cli, nick, 'Available admins: {}'.format(', '.join(admins)))
|
||||||
elif var.PHASE in ("day", "night") and nick not in pl:
|
elif var.PHASE in ('day', 'night') and nick not in pl:
|
||||||
cli.notice(nick, "Available admins: "+" ".join(admins))
|
cli.notice(nick, 'Available admins: {}'.format(', '.join(admins)))
|
||||||
else:
|
else:
|
||||||
cli.msg(chan, "Available admins: "+" ".join(admins))
|
cli.msg(chan, 'Available admins: {}'.format(', '.join(admins)))
|
||||||
|
|
||||||
decorators.unhook(HOOKS, 4)
|
decorators.unhook(HOOKS, 4)
|
||||||
var.ADMIN_PINGING = False
|
var.ADMIN_PINGING = False
|
||||||
|
|
||||||
cli.who(chan)
|
cli.who(botconfig.CHANNEL)
|
||||||
|
|
||||||
@pmcmd("admins", "ops")
|
|
||||||
|
@pmcmd('admins', 'ops')
|
||||||
def show_admins_pm(cli, nick, rest):
|
def show_admins_pm(cli, nick, rest):
|
||||||
show_admins(cli, nick, nick, rest)
|
show_admins(cli, nick, nick, rest)
|
||||||
|
|
||||||
@ -4697,11 +4715,19 @@ if botconfig.DEBUG_MODE or botconfig.ALLOWED_NORMAL_MODE_COMMANDS:
|
|||||||
cli.msg(chan, str(type(e))+":"+str(e))
|
cli.msg(chan, str(type(e))+":"+str(e))
|
||||||
|
|
||||||
|
|
||||||
|
@cmd('revealroles', admin_only=True)
|
||||||
|
def revealroles(cli, nick, chan, rest):
|
||||||
|
if var.PHASE == 'none':
|
||||||
|
cli.notice(nick, 'No game is currently running.')
|
||||||
|
return
|
||||||
|
|
||||||
@cmd("revealroles", admin_only=True)
|
s = ' | '.join('\u0002{}\u0002: {}'.format(role,', '.join(players))
|
||||||
def revroles(cli, nick, chan, rest):
|
for (role, players) in sorted(var.ROLES.items()) if players)
|
||||||
if var.PHASE != "none":
|
|
||||||
cli.msg(chan, str(var.ROLES))
|
if chan == nick:
|
||||||
|
pm(cli, nick, s)
|
||||||
|
else:
|
||||||
|
cli.msg(chan, s)
|
||||||
|
|
||||||
|
|
||||||
@cmd("fgame", admin_only=True)
|
@cmd("fgame", admin_only=True)
|
||||||
|
@ -444,9 +444,11 @@ def get_player_totals(acc):
|
|||||||
row = c.fetchone()
|
row = c.fetchone()
|
||||||
if row:
|
if row:
|
||||||
role_totals.append("\u0002{0}\u0002: {1}".format(role, *row))
|
role_totals.append("\u0002{0}\u0002: {1}".format(role, *row))
|
||||||
return "\u0002{0}\u0002's totals | {1}".format(player[0], ", ".join(role_totals))
|
c.execute("SELECT SUM(totalgames) from rolestats WHERE player=? COLLATE NOCASE AND role!='cursed villager' AND role!='gunner'", (acc,))
|
||||||
|
row = c.fetchone()
|
||||||
|
return "\u0002{0}\u0002's totals | \u0002{1}\u0002 games | {2}".format(player[0], row[0], ", ".join(role_totals))
|
||||||
else:
|
else:
|
||||||
return "{0} has not played any games.".format(acc)
|
return "\u0002{0}\u0002 has not played any games.".format(acc)
|
||||||
|
|
||||||
def get_game_stats(size):
|
def get_game_stats(size):
|
||||||
with conn:
|
with conn:
|
||||||
|
Loading…
Reference in New Issue
Block a user