-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement a lot of v1.0.0 features (Xinverse#19)
* Add botc.pid to gitignore * Remove notify.csv.example and ignore.csv.example, and update README * Update !sync and prevent it from stopping game if run during game start * Make !help send a message in the invocation context * Implement !revealrole - https://github.com/Xinverse/Blood-on-the-Clocktower-Storyteller-Discord-Bot/projects/1#card-41971138 * Implement !fday and !fdawn - https://github.com/Xinverse/Blood-on-the-Clocktower-Storyteller-Discord-Bot/projects/1#card-42145067 & https://github.com/Xinverse/Blood-on-the-Clocktower-Storyteller-Discord-Bot/projects/1#card-42145071 * Implement !fleave all - https://github.com/Xinverse/Blood-on-the-Clocktower-Storyteller-Discord-Bot/projects/1#card-42091529 * Update bot status based on bot state - https://github.com/Xinverse/Blood-on-the-Clocktower-Storyteller-Discord-Bot/projects/1#card-42091417 * Remove spammy log line * Log actions when registered * Fdawn and Fday were skipping night actions * !fnight no longer ignores executions * Night deaths should occur at daybreak and not dawn - https://github.com/Xinverse/Blood-on-the-Clocktower-Storyteller-Discord-Bot/projects/1#card-42157266
- Loading branch information
1 parent
4c507fe
commit d592887
Showing
16 changed files
with
397 additions
and
60 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
from .fnight import Fnight | ||
from .fnomination import Fnomination | ||
from .fdawn import Fdawn | ||
from .fday import Fday | ||
from .frole import Frole | ||
from .fstop import Fstop | ||
from .modkill import Modkill | ||
|
||
from .revealrole import RevealRole | ||
|
||
def setup(client): | ||
client.add_cog(Fstop(client)) | ||
client.add_cog(Modkill(client)) | ||
client.add_cog(Frole(client)) | ||
client.add_cog(Fnight(client)) | ||
client.add_cog(Fnomination(client)) | ||
client.add_cog(Fdawn(client)) | ||
client.add_cog(Fday(client)) | ||
client.add_cog(RevealRole(client)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"""Contains the fdawn command cog""" | ||
|
||
import json | ||
import traceback | ||
|
||
from discord.ext import commands | ||
|
||
import botutils | ||
from botc import Phase | ||
|
||
with open('botc/game_text.json') as json_file: | ||
documentation = json.load(json_file) | ||
|
||
with open('botutils/bot_text.json') as json_file: | ||
bot_text = json.load(json_file) | ||
error_str = bot_text["system"]["error"] | ||
|
||
|
||
class Fdawn(commands.Cog, name = documentation["misc"]["debug_cog"]): | ||
"""Fdawn command""" | ||
|
||
def __init__(self, client): | ||
self.client = client | ||
|
||
def cog_check(self, ctx): | ||
return botutils.check_if_admin(ctx) | ||
|
||
# ---------- FDAWN command ---------------------------------------- | ||
@commands.command( | ||
pass_context = True, | ||
name = "fdawn", | ||
hidden = False, | ||
brief = documentation["doc"]["fdawn"]["brief"], | ||
help = documentation["doc"]["fdawn"]["help"], | ||
description = documentation["doc"]["fdawn"]["description"] | ||
) | ||
async def fdawn(self, ctx): | ||
"""Fnight command""" | ||
|
||
import globvars | ||
if globvars.master_state.game.current_phase == Phase.night: | ||
|
||
import botc.switches | ||
botc.switches.master_proceed_to_dawn = True | ||
msg = documentation["doc"]["fdawn"]["feedback"].format(botutils.BotEmoji.success) | ||
|
||
await ctx.send(msg) | ||
|
||
@fdawn.error | ||
async def fdawn_error(self, ctx, error): | ||
# Check did not pass -> commands.CheckFailure | ||
if isinstance(error, commands.CheckFailure): | ||
return | ||
else: | ||
try: | ||
raise error | ||
except Exception: | ||
await ctx.send(error_str) | ||
await botutils.log(botutils.Level.error, traceback.format_exc()) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"""Contains the fday command cog""" | ||
|
||
import json | ||
import traceback | ||
|
||
from discord.ext import commands | ||
|
||
import botutils | ||
from botc import Phase | ||
|
||
with open('botc/game_text.json') as json_file: | ||
documentation = json.load(json_file) | ||
|
||
with open('botutils/bot_text.json') as json_file: | ||
bot_text = json.load(json_file) | ||
error_str = bot_text["system"]["error"] | ||
|
||
|
||
class Fday(commands.Cog, name = documentation["misc"]["debug_cog"]): | ||
"""Fday command""" | ||
|
||
def __init__(self, client): | ||
self.client = client | ||
|
||
def cog_check(self, ctx): | ||
return botutils.check_if_admin(ctx) | ||
|
||
# ---------- FDAWN command ---------------------------------------- | ||
@commands.command( | ||
pass_context = True, | ||
name = "fday", | ||
hidden = False, | ||
brief = documentation["doc"]["fday"]["brief"], | ||
help = documentation["doc"]["fday"]["help"], | ||
description = documentation["doc"]["fday"]["description"] | ||
) | ||
async def fday(self, ctx): | ||
"""Fnight command""" | ||
|
||
import globvars | ||
if globvars.master_state.game.current_phase == Phase.night or globvars.master_state.game.current_phase == Phase.dawn: | ||
|
||
import botc.switches | ||
botc.switches.master_proceed_to_day = True | ||
msg = documentation["doc"]["fday"]["feedback"].format(botutils.BotEmoji.success) | ||
|
||
await ctx.send(msg) | ||
|
||
@fday.error | ||
async def fday_error(self, ctx, error): | ||
# Check did not pass -> commands.CheckFailure | ||
if isinstance(error, commands.CheckFailure): | ||
return | ||
else: | ||
try: | ||
raise error | ||
except Exception: | ||
await ctx.send(error_str) | ||
await botutils.log(botutils.Level.error, traceback.format_exc()) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
"""Revealroles command""" | ||
|
||
import json | ||
from typing import Union | ||
import discord | ||
import traceback | ||
|
||
import botutils | ||
import globvars | ||
from botc import BOTCUtils, PlayerNotFound | ||
from botutils import BotEmoji | ||
|
||
from discord.ext import commands | ||
|
||
with open('botc/game_text.json') as json_file: | ||
documentation = json.load(json_file) | ||
|
||
with open('botutils/bot_text.json') as json_file: | ||
language = json.load(json_file) | ||
error_str = language["system"]["error"] | ||
|
||
class RevealRole(commands.Cog, name = documentation["misc"]["debug_cog"]): | ||
|
||
def __init__(self, client): | ||
self.client = client | ||
|
||
def cog_check(self, ctx): | ||
return botutils.check_if_admin(ctx) | ||
|
||
@commands.command( | ||
pass_context = True, | ||
name = "revealrole", | ||
aliases = ["rr", "revealroles"], | ||
brief = documentation["doc"]["modkill"]["brief"], | ||
help = documentation["doc"]["modkill"]["help"], | ||
description = documentation["doc"]["modkill"]["description"] | ||
) | ||
async def reveal_roles(self, ctx, target: str): | ||
if target == 'all': | ||
msg = "" | ||
for player in globvars.master_state.game.sitting_order: | ||
msg += player.game_nametag + " is the **" + player.role.true_self.name + \ | ||
(" " + player.role.ego_self.name if player.role.true_self.name != player.role.ego_self.name else "") + "**\n" | ||
else: | ||
target = BOTCUtils.get_player_from_string(target) | ||
if target is None: | ||
raise PlayerNotFound(f"Player {target} not found") | ||
msg = target.game_nametag + " is the **" + target.role.true_self.name + \ | ||
(" " + target.role.ego_self.name if target.role.true_self.name != target.role.ego_self.name else "") + "**" | ||
await ctx.send(msg) | ||
|
||
@reveal_roles.error | ||
async def reveal_roles_error(self, ctx, error): | ||
# Incorrect argument -> commands.BadArgument | ||
if isinstance(error, commands.BadArgument): | ||
return | ||
# Missing argument -> commands.MissingRequiredArgument | ||
elif isinstance(error, commands.MissingRequiredArgument): | ||
return | ||
else: | ||
try: | ||
raise error | ||
except Exception: | ||
await ctx.send(error_str) | ||
await botutils.log(botutils.Level.error, traceback.format_exc()) |
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
Oops, something went wrong.