Convert !quit to new command API
This commit is contained in:
parent
c9e1845fbb
commit
1989be5c8d
@ -3181,53 +3181,53 @@ def leave(var, what, user, why=None):
|
|||||||
temp = user.lower()
|
temp = user.lower()
|
||||||
var.DISCONNECTED[user] = (datetime.now(), what)
|
var.DISCONNECTED[user] = (datetime.now(), what)
|
||||||
|
|
||||||
@cmd("quit", "leave", pm=True, phases=("join", "day", "night"))
|
@command("quit", "leave", pm=True, phases=("join", "day", "night"))
|
||||||
def leave_game(cli, nick, chan, rest):
|
def leave_game(var, wrapper, message):
|
||||||
"""Quits the game."""
|
"""Quits the game."""
|
||||||
if chan == botconfig.CHANNEL:
|
if wrapper.target is channels.Main:
|
||||||
if nick not in list_players():
|
if wrapper.source not in get_players():
|
||||||
return
|
return
|
||||||
if var.PHASE == "join":
|
if var.PHASE == "join":
|
||||||
lpl = len(list_players()) - 1
|
lpl = len(get_players()) - 1
|
||||||
if lpl == 0:
|
if lpl == 0:
|
||||||
population = " " + messages["no_players_remaining"]
|
population = " " + messages["no_players_remaining"]
|
||||||
else:
|
else:
|
||||||
population = " " + messages["new_player_count"].format(lpl)
|
population = " " + messages["new_player_count"].format(lpl)
|
||||||
else:
|
else:
|
||||||
if not rest.startswith("-force"):
|
if not message.startswith("-force"):
|
||||||
reply(cli, nick, chan, messages["leave_game_ingame_safeguard"].format(botconfig.CMD_CHAR), private=True)
|
wrapper.pm(messages["leave_game_ingame_safeguard"].format(botconfig.CMD_CHAR))
|
||||||
return
|
return
|
||||||
population = ""
|
population = ""
|
||||||
elif chan == nick:
|
elif wrapper.private:
|
||||||
if var.PHASE in var.GAME_PHASES and nick not in list_players() and users._get(nick) in var.DEADCHAT_PLAYERS:
|
if var.PHASE in var.GAME_PHASES and wrapper.source not in get_players() and wrapper.source in var.DEADCHAT_PLAYERS:
|
||||||
leave_deadchat(var, users._get(nick))
|
leave_deadchat(var, wrapper.source)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
if get_role(nick) != "person" and var.ROLE_REVEAL in ("on", "team"):
|
if get_main_role(wrapper.source) != "person" and var.ROLE_REVEAL in ("on", "team"):
|
||||||
role = get_reveal_role(users._get(nick)) # FIXME
|
role = get_reveal_role(wrapper.source)
|
||||||
an = "n" if role.startswith(("a", "e", "i", "o", "u")) else ""
|
an = "n" if role.startswith(("a", "e", "i", "o", "u")) else ""
|
||||||
if var.DYNQUIT_DURING_GAME:
|
if var.DYNQUIT_DURING_GAME:
|
||||||
lmsg = random.choice(messages["quit"]).format(nick, an, role)
|
lmsg = random.choice(messages["quit"]).format(wrapper.source.nick, an, role)
|
||||||
cli.msg(botconfig.CHANNEL, lmsg)
|
channels.Main.send(lmsg)
|
||||||
else:
|
else:
|
||||||
cli.msg(botconfig.CHANNEL, (messages["static_quit"] + "{2}").format(nick, role, population))
|
channels.Main.send((messages["static_quit"] + "{2}").format(wrapper.source.nick, role, population))
|
||||||
else:
|
else:
|
||||||
# DYNQUIT_DURING_GAME should not have any effect during the join phase, so only check if we aren't in that
|
# DYNQUIT_DURING_GAME should not have any effect during the join phase, so only check if we aren't in that
|
||||||
if var.PHASE != "join" and not var.DYNQUIT_DURING_GAME:
|
if var.PHASE != "join" and not var.DYNQUIT_DURING_GAME:
|
||||||
cli.msg(botconfig.CHANNEL, (messages["static_quit_no_reveal"] + "{1}").format(nick, population))
|
channels.Main.send((messages["static_quit_no_reveal"] + "{1}").format(wrapper.source.nick, population))
|
||||||
else:
|
else:
|
||||||
lmsg = random.choice(messages["quit_no_reveal"]).format(nick) + population
|
lmsg = random.choice(messages["quit_no_reveal"]).format(wrapper.source.nick) + population
|
||||||
cli.msg(botconfig.CHANNEL, lmsg)
|
channels.Main.send(lmsg)
|
||||||
if var.PHASE != "join":
|
if var.PHASE != "join":
|
||||||
var.DCED_LOSERS.add(users._get(nick)) # FIXME
|
var.DCED_LOSERS.add(wrapper.source)
|
||||||
if var.LEAVE_PENALTY:
|
if var.LEAVE_PENALTY:
|
||||||
add_warning(cli, nick, var.LEAVE_PENALTY, users.Bot.nick, messages["leave_warning"], expires=var.LEAVE_EXPIRY)
|
add_warning(wrapper.client, wrapper.source.nick, var.LEAVE_PENALTY, users.Bot.nick, messages["leave_warning"], expires=var.LEAVE_EXPIRY) # FIXME
|
||||||
if nick in var.PLAYERS:
|
if wrapper.source.nick in var.PLAYERS:
|
||||||
var.DCED_PLAYERS[nick] = var.PLAYERS.pop(nick)
|
var.DCED_PLAYERS[wrapper.source.nick] = var.PLAYERS.pop(wrapper.source.nick)
|
||||||
|
|
||||||
del_player(users._get(nick), death_triggers=False) # FIXME
|
del_player(wrapper.source, death_triggers=False)
|
||||||
|
|
||||||
def begin_day(cli):
|
def begin_day(cli):
|
||||||
chan = botconfig.CHANNEL
|
chan = botconfig.CHANNEL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user