async def previous_status(self, ctx: commands.context.Context): # botの発言 / 自分へのメンション以外は無視 if Utils.is_message_author_bot(ctx.message): return # クラメンデータ検索 context: Context = await Context.get_instance(self.bot) clan_member: ClanMember = context.get_clan_member( ctx.message.author.id) # 1個前のステータスを出力する previous_attack_status: AttackStatus = clan_member.attack_status clan_member.previous_status() now_attack_status: AttackStatus = clan_member.attack_status # メッセージ生成 previous_status_message: str = "【前回】{}凸 {} {}".format( previous_attack_status.attack_count, "【持越し】" if previous_attack_status.is_carry_over else "", "【タスキル済み】" if previous_attack_status.use_task_kill else "") now_status_message: str = "【今回】{}凸 {} {} ".format( now_attack_status.attack_count, "【持越し】" if now_attack_status.is_carry_over else "", "【タスキル済み】" if now_attack_status.use_task_kill else "") return_message: str = "{}さんの状態を変更しました。\n{}\n{}".format( clan_member.get_member_nickname(), previous_status_message, now_status_message) await ctx.message.channel.send(return_message) # 凸状態が変わるのでニックネーム修正 await clan_member.update_member_name()
async def on_finish(self, ctx: commands.context.Context): # botの発言 / 自分へのメンション以外は無視 if Utils.is_message_author_bot(ctx.message): return # 終了処理 await self._finish(ctx.message)
async def on_cancel(self, ctx: commands.context.Context): # botの発言 / 自分へのメンション以外は無視 if Utils.is_message_author_bot(ctx.message): return # キャンセル処理 await self._cancel(ctx.message, is_force_reset=True)
async def check_edit(self, before_message: discord.Message, after_message: discord.Message): # botの発言 / 自分へのメンション以外は無視 if Utils.is_message_author_bot(after_message): return # 対象チャンネル以外でスルー if not Utils.check_channel(after_message): return await after_message.reply("このチャンネルでメッセージを削除・変更はしないでください。\n" + "もし間違って凸宣言をした場合は、リアクションかコマンドで取り消してください。")
async def check_delete(self, message: discord.Message): # botの発言 / 自分へのメンション以外は無視 if Utils.is_message_author_bot(message): return # 対象チャンネル以外でスルー if not Utils.check_channel(message): return await message.channel.send("{} \nこのチャンネルでメッセージを削除・変更はしないでください。\n". format(message.author.mention) + "もし間違って凸宣言をした場合は、リアクションかコマンドで取り消してください。")
async def now_status(self, ctx: commands.context.Context): # botの発言 / 自分へのメンション以外は無視 if Utils.is_message_author_bot(ctx.message): return # 対象チャンネル以外でスルー if not Utils.check_channel(ctx.message): return context: Context = await Context.get_instance(self.bot) return_message: str = context.get_now_attack_member() await ctx.message.channel.send("現在のボスに凸しているメンバーの一覧です。\n```\n {} \n```".format(return_message))
async def use_task_kill(self, ctx: commands.context.Context): # botの発言 / 自分へのメンション以外は無視 if Utils.is_message_author_bot(ctx.message): return # 対象チャンネル以外でスルー if not Utils.check_channel(ctx.message): return # クラメンデータ検索 context: Context = await Context.get_instance(self.bot) clan_member: ClanMember = context.get_clan_member( ctx.message.author.id) # タスキル処理 await clan_member.exec_task_kill(ctx.message)
async def previous_status(self, ctx: commands.context.Context): # botの発言 / 自分へのメンション以外は無視 if Utils.is_message_author_bot(ctx.message): return # 対象チャンネル以外でスルー if not Utils.check_channel(ctx.message): return # クラメンデータ検索 context: Context = await Context.get_instance(self.bot) clan_member: ClanMember = context.get_clan_member( ctx.message.author.id) # ひとつ前に戻す処理 await clan_member.previous_status(ctx.message)
async def command_alias(self, message: discord.Message): # botの発言 / 自分へのメンション以外は無視 if Utils.is_message_author_bot(message): return # 対象チャンネル以外でスルー if not Utils.check_channel(message): return command_msg: str = message.content # 「a(スペース無し)数値」→「a」に変換 「凸(スペース無し)数値」→「凸」に変換 ※数値は半角or全角 if re.match(r"^a[0-90123456789]+$", command_msg) or re.match( r"^凸[0-90123456789]+$", command_msg): ctx: commands.Context = await self.bot.get_context(message) cog: AttackCog = self.bot.get_cog("AttackCog") await cog.on_attack(ctx) # 変な文字列を送ってきたので燃やします await message.add_reaction(ClanBattleEmoji.FIRE)
async def on_attack(self, ctx: commands.context.Context): # botの発言 / 自分へのメンション以外は無視 if Utils.is_message_author_bot(ctx.message): return # 対象チャンネル以外でスルー if not Utils.check_channel(ctx.message): return # クラメンデータ検索 context: Context = await Context.get_instance(self.bot) clan_member: ClanMember = context.get_clan_member(ctx.author.id) # 凸のデータ保存 clan_member.attack(ctx.message) # メッセージに対してリアクションを送出する await ctx.message.add_reaction(ClanBattleEmoji.END) await ctx.message.add_reaction(ClanBattleEmoji.KILL) await ctx.message.add_reaction(ClanBattleEmoji.CANCEL)
async def use_task_kill(self, ctx: commands.context.Context): # botの発言 / 自分へのメンション以外は無視 if Utils.is_message_author_bot(ctx.message): return # クラメンデータ検索 context: Context = await Context.get_instance(self.bot) clan_member: ClanMember = context.get_clan_member( ctx.message.author.id) clan_member.exec_task_kill() # キャンセル処理 return_message: str = "【タスキル使用】{} さんの{}凸目{}をキャンセルしました".format( clan_member.get_member_nickname(), clan_member.attack_status.attack_count + 1, "(持越し)" if clan_member.attack_status.is_carry_over else "") await ctx.message.channel.send(return_message) # 凸状態が変わるのでニックネーム修正 await clan_member.update_member_name()
async def over_kill(self, ctx: commands.context.Context): # botの発言 / 自分へのメンション以外は無視 if Utils.is_message_author_bot(ctx.message): return await self._kill(ctx.message)