<commit_before>import random
from typing import Dict, List

import discord
from discord import ButtonStyle, Interaction, Member, app_commands, ui

from ..tools import Cog

RANDOM_ARTICLES = ["The Statue Of Liberty", "The Eifle Tower", "Bass Pro Shop Pyramid", "The Taj Mahal", "Fortnite"]


class ArticalModal(ui.Modal, title="My Article Is..."):
    article = ui.TextInput(label="Article Name", placeholder=random.choice(RANDOM_ARTICLES))

    async def on_submit(self, interaction: discord.Interaction):
        await interaction.response.defer()


class FinishView(ui.View):
    def __init__(self, articleOwner: Member, tomId, articleTitle:str):
        super().__init__(timeout=840)
        self.tomId = tomId
        self.articleOwner: Member = articleOwner
        self.add_item(
                ui.Button(label=articleTitle, url=f"https://en.wikipedia.org/wiki/{articleTitle}")
            )


    @ui.button(label="the answer was...")
    async def answer(self, interaction: discord.Interaction, button: ui.Button):
        await interaction.response.send_message(
            f"the article was chosen by {self.articleOwner.display_name}", ephemeral=interaction.user.id != self.tomId
        )
        if interaction.user.id == self.tomId:
            self.stop()


class nOfThesePeopleAreLying(Cog):
    class ImPlaying(ui.View):
        def __init__(self, *, timeout=180):
            super().__init__(timeout=timeout)
            self.players: List[Interaction] = []
            self.orig = None

        @ui.button(label="I'm playing!")
        async def playerConfirm(self, interaction: Interaction, button: ui.Button):
            if interaction.user.id in [p.user.id for p in self.players]:
                return await interaction.response.send_message("you've already joined!", ephemeral=True)
            self.players.append(interaction)
            await interaction.response.send_message("i got you!", ephemeral=True)
            if len(self.players) >2:
                self.startGame.disabled = False
            await self.orig(
                content=f"are you playing? hit 'I'm Playing'! I've Got {len(self.players)} players so far!", view=self
            )

        @ui.button(label="Let's Play!", style=ButtonStyle.green, disabled=True)
        async def startGame(self, interaction: Interaction, button: ui.Button):
            await interaction.response.defer(ephemeral=True)
            self.stop()

    class Articles(ui.View):
        def __init__(self, players: List[Interaction], tomId):
            super().__init__(timeout=None)
            self.articles: Dict[int, str] = dict()
            self.players = players
            self.player_ids = [p.user.id for p in self.players]
            self.tomId = tomId
            self.add_item(
                ui.Button(label="Random Wikipedia Article", url="https://en.wikipedia.org/wiki/Special:Random")
            )

        @ui.button(label="My Articles is...", style=ButtonStyle.green)<commit_msg>auto: format python code<commit_after>import random
from typing import Dict, List

import discord
from discord import ButtonStyle, Interaction, Member, app_commands, ui

from ..tools import Cog

RANDOM_ARTICLES = ["The Statue Of Liberty", "The Eifle Tower", "Bass Pro Shop Pyramid", "The Taj Mahal", "Fortnite"]


class ArticalModal(ui.Modal, title="My Article Is..."):
    article = ui.TextInput(label="Article Name", placeholder=random.choice(RANDOM_ARTICLES))

    async def on_submit(self, interaction: discord.Interaction):
        await interaction.response.defer()


class FinishView(ui.View):
    def __init__(self, articleOwner: Member, tomId, articleTitle: str):
        super().__init__(timeout=840)
        self.tomId = tomId
        self.articleOwner: Member = articleOwner
        self.add_item(ui.Button(label=articleTitle, url=f"https://en.wikipedia.org/wiki/{articleTitle}"))

    @ui.button(label="the answer was...")
    async def answer(self, interaction: discord.Interaction, button: ui.Button):
        await interaction.response.send_message(
            f"the article was chosen by {self.articleOwner.display_name}", ephemeral=interaction.user.id != self.tomId
        )
        if interaction.user.id == self.tomId:
            self.stop()


class nOfThesePeopleAreLying(Cog):
    class ImPlaying(ui.View):
        def __init__(self, *, timeout=180):
            super().__init__(timeout=timeout)
            self.players: List[Interaction] = []
            self.orig = None

        @ui.button(label="I'm playing!")
        async def playerConfirm(self, interaction: Interaction, button: ui.Button):
            if interaction.user.id in [p.user.id for p in self.players]:
                return await interaction.response.send_message("you've already joined!", ephemeral=True)
            self.players.append(interaction)
            await interaction.response.send_message("i got you!", ephemeral=True)
            if len(self.players) > 2:
                self.startGame.disabled = False
            await self.orig(
                content=f"are you playing? hit 'I'm Playing'! I've Got {len(self.players)} players so far!", view=self
            )

        @ui.button(label="Let's Play!", style=ButtonStyle.green, disabled=True)
        async def startGame(self, interaction: Interaction, button: ui.Button):
            await interaction.response.defer(ephemeral=True)
            self.stop()

    class Articles(ui.View):
        def __init__(self, players: List[Interaction], tomId):
            super().__init__(timeout=None)
            self.articles: Dict[int, str] = dict()
            self.players = players
            self.player_ids = [p.user.id for p in self.players]
            self.tomId = tomId
            self.add_item(
                ui.Button(label="Random Wikipedia Article", url="https://en.wikipedia.org/wiki/Special:Random")
            )

        @ui.button(label="My Articles is...", style=ButtonStyle.green)
{'fraction_non_alphanumeric': 0.11915966386554622, 'fraction_numerical': 0.002352941176470588, 'mean_word_length': 2.759317751105496, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5510569', 'n_tokens_mistral': 1756, 'n_tokens_neox': 1682, 'n_words': 402}