From b8251c334c4801ec58cb41b6a2027b09ac0cd1ab Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Sun, 9 Jul 2023 09:45:17 +0100 Subject: [PATCH] Use the same pride facts for each year The command args have been changed to accept a number between 1 & 20, rather than a date, to make it easier to select which day of the week you want. This also updates the output of the command so that the selected day, or random is included in the title. --- bot/exts/holidays/pride/pride_facts.py | 67 +++++++++---------------- bot/resources/holidays/pride/facts.json | 66 ++++++++++++------------ 2 files changed, 55 insertions(+), 78 deletions(-) diff --git a/bot/exts/holidays/pride/pride_facts.py b/bot/exts/holidays/pride/pride_facts.py index f3ce50a9bd..3d52a3c7d6 100644 --- a/bot/exts/holidays/pride/pride_facts.py +++ b/bot/exts/holidays/pride/pride_facts.py @@ -4,7 +4,6 @@ from datetime import UTC, datetime from pathlib import Path -import dateutil.parser import discord from discord.ext import commands @@ -28,65 +27,45 @@ def __init__(self, bot: Bot): async def send_pride_fact_daily(self) -> None: """Background task to post the daily pride fact every day.""" channel = self.bot.get_channel(Channels.sir_lancebot_playground) - await self.send_select_fact(channel, datetime.now(tz=UTC)) + await self.send_select_fact(channel, datetime.now(tz=UTC).day) - async def send_random_fact(self, ctx: commands.Context) -> None: - """Provides a fact from any previous day, or today.""" - now = datetime.now(tz=UTC) - previous_years_facts = (y for x, y in FACTS.items() if int(x) < now.year) - current_year_facts = FACTS.get(str(now.year), [])[:now.day] - previous_facts = current_year_facts + [x for y in previous_years_facts for x in y] + async def send_select_fact(self, target: discord.abc.Messageable, day_num: int) -> None: + """Provides the fact for the specified day.""" try: - await ctx.send(embed=self.make_embed(random.choice(previous_facts))) + await target.send(embed=self.get_fact_embed(day_num)) except IndexError: - await ctx.send("No facts available") - - async def send_select_fact(self, target: discord.abc.Messageable, _date: str | datetime) -> None: - """Provides the fact for the specified day, if the day is today, or is in the past.""" - now = datetime.now(tz=UTC) - if isinstance(_date, str): - try: - date = dateutil.parser.parse(_date, dayfirst=False, yearfirst=False, fuzzy=True) - except (ValueError, OverflowError) as err: - await target.send(f"Error parsing date: {err}") - return - else: - date = _date - if date.year < now.year or (date.year == now.year and date.day <= now.day): - try: - await target.send(embed=self.make_embed(FACTS[str(date.year)][date.day - 1])) - except KeyError: - await target.send(f"The year {date.year} is not yet supported") - return - except IndexError: - await target.send(f"Day {date.day} of {date.year} is not yet support") - return - else: - await target.send("The fact for the selected day is not yet available.") + await target.send(f"Day {day_num} is not supported") + return @commands.command(name="pridefact", aliases=("pridefacts",)) - async def pridefact(self, ctx: commands.Context, option: str = None) -> None: + async def pridefact(self, ctx: commands.Context, option: int | str = None) -> None: """ Sends a message with a pride fact of the day. - If "random" is given as an argument, a random previous fact will be provided. - - If a date is given as an argument, and the date is in the past, the fact from that day - will be provided. + "option" is an optional setting, which has two has two accepted values: + - "random": a random previous fact will be provided. + - If a option is a number (1-30), the fact for that given day of June is returned. """ if not option: - await self.send_select_fact(ctx, datetime.now(tz=UTC)) + await self.send_select_fact(ctx, datetime.now(tz=UTC).day) + elif isinstance(option, int): + await self.send_select_fact(ctx, option) elif option.lower().startswith("rand"): - await self.send_random_fact(ctx) + await ctx.send(embed=self.get_fact_embed()) else: - await self.send_select_fact(ctx, option) + await ctx.send(f"Could not parse option {option}") @staticmethod - def make_embed(fact: str) -> discord.Embed: - """Makes a nice embed for the fact to be sent.""" + def get_fact_embed(day_num: int | None=None) -> discord.Embed: + """ + Makes a embed for the fact on the given day_num to be sent. + + if day_num is not set, a random fact is selected. + """ + fact = FACTS[day_num-1] if day_num else random.choice(FACTS) return discord.Embed( colour=Colours.pink, - title="Pride Fact!", + title=f"Day {day_num}'s pride fact!" if day_num else "Random pride fact!", description=fact ) diff --git a/bot/resources/holidays/pride/facts.json b/bot/resources/holidays/pride/facts.json index 2151f5ca63..cb10e409c1 100644 --- a/bot/resources/holidays/pride/facts.json +++ b/bot/resources/holidays/pride/facts.json @@ -1,34 +1,32 @@ -{ - "2020": [ - "No research has conclusively proven what causes homosexuality, heterosexuality, or bisexuality.", - "Records of same-sex relationships have been found in nearly every culture throughout history with varying degrees of acceptance.", - "Various slurs targeting queer people have been reappropriated by them, notably \"dyke\", and \"queer\".", - "Historians note that in some cultures, some homosexual behavior was not viewed as effeminate, but as evidence of a man's masculinity. Examples include the Celtic and Greek cultures.", - "Over time, the proportion of people who identify as homosexual or bisexual appears to be increasing. It is not know if this is because they feel it is safer to come out, or if the actual numbers of homosexual/bisexual people are increasing.", - "A large proportion of people, both in and out of the LGBTQ+ communities, do not believe bisexuality exists. This is known as bisexual erasure.", - "Queer people commit suicide are much more common in politically conservative regions, and also more common than non-queer people in general.", - "October 8th is lesbian pride day!", - "Stormé DeLarverie, a lesbian drag king, had a \"scuffle\" with the police which many claim is what kicked off the Stonewall Riots.", - "Gilbert Baker, also known as the “Gay Betsy Ross,” designed the rainbow flag, or Pride Flag, in San Francisco in 1978.", - "The rainbow pride flag is well-known, but there are flags for most labeled gender/sexual minorities.", - "In 1968, Dr. John Money performed the first complete male-to-female sex-change operation in the United States at Johns Hopkins University.", - "At the age of 24, Leonardo Da Vinci was arrested for having sex with a man. He was eventually acquitted.", - "Alfred Kinsey, the creator of the Kinsey scale, is known as \"the father of the sexual revolution\". The Kinsey scale was created in order to demonstrate that sexuality does not fit into two strict categories: homosexual and heterosexual. Instead, Kinsey believed that sexuality is fluid and subject to change over time.", - "The Kinsey scale ranges from 0, which is exclusively heterosexual, to 6, which is exclusively homosexual.", - "November 20th is the Transgender Day of Remembrance, which is a day to memorialize those who have been murdered as a result of transphobia.", - "The pink triangle was the symbol that queer people were required to wear in Nazi concentration camps during WWII. The symbol has since been reclaimed as a positive symbol of self-identity.", - "The term \"AC/DC\" has been used to refer to bisexuals.", - "September 23rd is bisexual pride day!", - "Pride Day refers to celebrations that typically take place in June that commemorate the Stonewall Inn riots of June 28, 1969. These riots are considered the birth of the modern gay civil rights movement.", - "A \"beard\" is someone of the opposite sex who knowingly dates a closeted lesbian or gay man to provide that person with a heterosexual \"disguise\", usually for family or career purposes.", - "In Nigeria, where homosexuality is punishable by death by stoning, a post-grad student claimed he had proved being gay was wrong by using magnets. He hoped to win a Nobel Prize for his research. He has not received one.", - "In 1982, the Gay Related Immune Disorder (GRID) was renamed Acquired Immune Deficiency Syndrome (AIDS).", - "The word \"lesbian\" is derived from the Greek island Lesbos, home of Greek poet Sappho. Her poetry proclaimed her love for women, and their beauty.", - "Nearly all bonobos (a kind of chimpanzee) appear to be bisexual.", - "Homosexual behavior has been observed in 1,500 animal species and is most widespread among animals with a complex herd life.", - "Many queer people identify their sexual orientation independently from their romantic orientation. For instance, it is possible to be sexually attracted to both women and men, but only be romantically attracted to one of them.", - "In 2005, Swedish researchers found that when straight men smelled a female urine compound, their hypothalamus lit up in brain images. In gay men, it did not. Instead, homosexual men's hypothalamus lit up when they smelled the male-sweat compound, which was the same way straight women responded.", - "As of 2019-10-02, there are 17 states in the United States of America where queer people can be fired for being queer. In most other states, there is minimal protection offered, often only for public employees.", - "In 1985, an official Star Trek novel was published with scenes depicting Kirk and Spock as lovers. These parts were largely removed, which made the original into a collector's item." - ] -} +[ + "No research has conclusively proven what causes homosexuality, heterosexuality, or bisexuality.", + "Records of same-sex relationships have been found in nearly every culture throughout history with varying degrees of acceptance.", + "Various slurs targeting queer people have been reappropriated by them, notably \"dyke\", and \"queer\".", + "Historians note that in some cultures, some homosexual behavior was not viewed as effeminate, but as evidence of a man's masculinity. Examples include the Celtic and Greek cultures.", + "Over time, the proportion of people who identify as homosexual or bisexual appears to be increasing. It is not know if this is because they feel it is safer to come out, or if the actual numbers of homosexual/bisexual people are increasing.", + "A large proportion of people, both in and out of the LGBTQ+ communities, do not believe bisexuality exists. This is known as bisexual erasure.", + "Queer people commit suicide are much more common in politically conservative regions, and also more common than non-queer people in general.", + "October 8th is lesbian pride day!", + "Stormé DeLarverie, a lesbian drag king, had a \"scuffle\" with the police which many claim is what kicked off the Stonewall Riots.", + "Gilbert Baker, also known as the “Gay Betsy Ross,” designed the rainbow flag, or Pride Flag, in San Francisco in 1978.", + "The rainbow pride flag is well-known, but there are flags for most labeled gender/sexual minorities.", + "In 1968, Dr. John Money performed the first complete male-to-female sex-change operation in the United States at Johns Hopkins University.", + "At the age of 24, Leonardo Da Vinci was arrested for having sex with a man. He was eventually acquitted.", + "Alfred Kinsey, the creator of the Kinsey scale, is known as \"the father of the sexual revolution\". The Kinsey scale was created in order to demonstrate that sexuality does not fit into two strict categories: homosexual and heterosexual. Instead, Kinsey believed that sexuality is fluid and subject to change over time.", + "The Kinsey scale ranges from 0, which is exclusively heterosexual, to 6, which is exclusively homosexual.", + "November 20th is the Transgender Day of Remembrance, which is a day to memorialize those who have been murdered as a result of transphobia.", + "The pink triangle was the symbol that queer people were required to wear in Nazi concentration camps during WWII. The symbol has since been reclaimed as a positive symbol of self-identity.", + "The term \"AC/DC\" has been used to refer to bisexuals.", + "September 23rd is bisexual pride day!", + "Pride Day refers to celebrations that typically take place in June that commemorate the Stonewall Inn riots of June 28, 1969. These riots are considered the birth of the modern gay civil rights movement.", + "A \"beard\" is someone of the opposite sex who knowingly dates a closeted lesbian or gay man to provide that person with a heterosexual \"disguise\", usually for family or career purposes.", + "In Nigeria, where homosexuality is punishable by death by stoning, a post-grad student claimed he had proved being gay was wrong by using magnets. He hoped to win a Nobel Prize for his research. He has not received one.", + "In 1982, the Gay Related Immune Disorder (GRID) was renamed Acquired Immune Deficiency Syndrome (AIDS).", + "The word \"lesbian\" is derived from the Greek island Lesbos, home of Greek poet Sappho. Her poetry proclaimed her love for women, and their beauty.", + "Nearly all bonobos (a kind of chimpanzee) appear to be bisexual.", + "Homosexual behavior has been observed in 1,500 animal species and is most widespread among animals with a complex herd life.", + "Many queer people identify their sexual orientation independently from their romantic orientation. For instance, it is possible to be sexually attracted to both women and men, but only be romantically attracted to one of them.", + "In 2005, Swedish researchers found that when straight men smelled a female urine compound, their hypothalamus lit up in brain images. In gay men, it did not. Instead, homosexual men's hypothalamus lit up when they smelled the male-sweat compound, which was the same way straight women responded.", + "As of 2019-10-02, there are 17 states in the United States of America where queer people can be fired for being queer. In most other states, there is minimal protection offered, often only for public employees.", + "In 1985, an official Star Trek novel was published with scenes depicting Kirk and Spock as lovers. These parts were largely removed, which made the original into a collector's item." +]