From 8c82fd5c03b62f2d35cf6b0e2945e332a5b02bc3 Mon Sep 17 00:00:00 2001 From: vivax3794 <51753506+vivax3794@users.noreply.github.com> Date: Tue, 1 Oct 2019 01:16:01 +0200 Subject: added hacktober-issue-finder cog. --- bot/seasons/halloween/hacktober-issue-finder.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 bot/seasons/halloween/hacktober-issue-finder.py (limited to 'bot') diff --git a/bot/seasons/halloween/hacktober-issue-finder.py b/bot/seasons/halloween/hacktober-issue-finder.py new file mode 100644 index 00000000..ce0993d3 --- /dev/null +++ b/bot/seasons/halloween/hacktober-issue-finder.py @@ -0,0 +1,18 @@ +import logging + +from discord.ext import commands + +log = logging.getLogger(__name__) + + +class SpookyEightBall(commands.Cog): + """Find a random hacktober python issue on GitHub.""" + + def __init__(self, bot: commands.Bot): + self.bot = bot + + +def setup(bot: commands.Bot) -> None: + """Hacktober issue finder Cog Load.""" + bot.add_cog(SpookyEightBall(bot)) + log.info("hacktober-issue-finder cog loaded") -- cgit v1.2.3 From ae4eb13f93c9b7e5465fe9b3a91f093f1c6d1bac Mon Sep 17 00:00:00 2001 From: vivax3794 <51753506+vivax3794@users.noreply.github.com> Date: Tue, 1 Oct 2019 02:45:48 +0200 Subject: get issue data --- bot/seasons/halloween/hacktober-issue-finder.py | 39 +++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/seasons/halloween/hacktober-issue-finder.py b/bot/seasons/halloween/hacktober-issue-finder.py index ce0993d3..17eec95a 100644 --- a/bot/seasons/halloween/hacktober-issue-finder.py +++ b/bot/seasons/halloween/hacktober-issue-finder.py @@ -1,18 +1,53 @@ +import datetime import logging +from typing import Dict, List +import aiohttp from discord.ext import commands log = logging.getLogger(__name__) +URL = "https://api.github.com/search/issues" +HEADERS = {"Accept": "application / vnd.github.v3 + json"} +SEARCH = "label:hacktoberfest+language:python+state:open" -class SpookyEightBall(commands.Cog): + +class HacktoberIssues(commands.Cog): """Find a random hacktober python issue on GitHub.""" def __init__(self, bot: commands.Bot): self.bot = bot + self.cache = None + self.cache_timer = datetime.datetime(1, 1, 1) + + @commands.command() + async def hacktoberissues(self, ctx: commands.Context) -> None: + """Get a random python hacktober issue from Github.""" + with ctx.typing(): + data = await self.get_issues(ctx) + print("need to use data somehow to commit...", data) + + async def get_issues(self, ctx: commands.Context) -> List[Dict]: + """Get a list of the python issues with the label 'hacktoberfest' from the Github api.""" + if (ctx.message.created_at - self.cache_timer).seconds <= 60: + return self.cache + + async with aiohttp.ClientSession() as session: + # text = TEXT # + "+label:hacktober" + params = { + "q": SEARCH + } + async with session.get(URL, headers=HEADERS, params=params) as response: + if response.status != 200: + await ctx.send(f"ERROR: expected 200 status (got {response.status}) from the GitHub api.") + await ctx.send(await response.text()) + data = (await response.json())["items"] + self.cache = data + self.cache_timer = ctx.message.created_at + return data def setup(bot: commands.Bot) -> None: """Hacktober issue finder Cog Load.""" - bot.add_cog(SpookyEightBall(bot)) + bot.add_cog(HacktoberIssues(bot)) log.info("hacktober-issue-finder cog loaded") -- cgit v1.2.3 From dce5b70e15b089ea661c12db120223f50f83ad74 Mon Sep 17 00:00:00 2001 From: Will Da Silva Date: Tue, 1 Oct 2019 15:02:21 -0400 Subject: Add drag queen names The names are stored in a text file, since they're basically just a list, and json seems like overkill for this case. In any case switching over to json later would be easy. The names could be separated into first and last names in order to generate more combinations, but that would break the wordplay that many of the names have. The names were taken from https://www.fantasynamegenerators.com/drag-queen-names.php as permitted by the footnote on the page. --- bot/resources/pride/drag_queen_names.txt | 248 +++++++++++++++++++++++++++++++ 1 file changed, 248 insertions(+) create mode 100644 bot/resources/pride/drag_queen_names.txt (limited to 'bot') diff --git a/bot/resources/pride/drag_queen_names.txt b/bot/resources/pride/drag_queen_names.txt new file mode 100644 index 00000000..1701b760 --- /dev/null +++ b/bot/resources/pride/drag_queen_names.txt @@ -0,0 +1,248 @@ +Adelle Lectible +Adelle Light +Adelle Lirious +Alison Wonder +Amie Thyst +Amie Zonite +Angela Develle +Anna Conda +Anne Amaley +Annie Nigma +Aria Hymn +Aria Viderci +Aroa Mattic +Aster Starr +Aura Aurora +Aura Ley +Aurora Dorea +Barba Rouse +Bea Constrictor +Bella Lush +Belle Icoza +Belle Ligerrente +Betty Brilliance +Bo Deysious +Carol Chorale +Cecil Clouds +Cecil Sunshine +Celeste Booday +Chichi Swank +Claire Geeman +Claire Rickal +Claire Voyance +Cleo Patrix +Connie Fidence +Corra Rageous +Daye Light +Deedee Cation +Deedee Sign +Dianne Gerous +Didi Divine +Diemme Monds +Dorothy Doughty +Dutches Dauntless +Ella Gance +Ella Gants +Ella Menterry +Ella Stique +Elle Lectrick +Elle Lure +Emma Geddon +Emma Phasis +Emma Rald +Emme Plosion +Emme Pulse +Emme Vention +Enna Fincible +Enne Phinite +Enne Treppide +Etha Nitty +Etha Reyal +Euphoria Bliss +Eva Nessent +Eve Forric +Eve Ningowne +Eve Ville +Faith Lesse +Faschia Nation +Faye Boulous +Faye Lacious +Faye Minine +Faye Nixx +Felicity Spice +Freya Domme +Gal Gallant +Gal Galore +Gal Lante +Gemma Safir +Gena Rocity +Genna Russ +Gigi Lamour +Gigi Rand +Glemma Rouss +Grace Iyus +Haye Light +Hazel Nutt +Hella Billy +Hella Centrique +Hella Cious +Hella Riouss +Hella Whole +Hellen Back +Herra Zee +Ina Creddeble +Ina Fernalle +Jo Nee +Jo Phial +Joye Ryde +Jue Cee +Jue Wells +Juju Bee +Kaia Cayenne +Kaye Bye +Kitsch Kitsch Bang Bang +Lady Lace +Lavish Lazuli +Lea Ness +Leye Berty +Lisse Truss +Liv Lee +Lola Lavish +Lolo Yaltie +Lucy Fur +Lucy Luck +Lulu LaBye +Lulu Xuri +Lunaye Clipse +Lyra Kall +Maggie Magma +Mara Bells +Marry Golds +Marry Nayde +Marry Sipan +Marve Vellus +Mary Ganal +Mary Malade +May Jestic +May Lancholly +May Licious +May Lodi +May Morable +May Stirius +May Varlous +Melody Gale +Melody Toune +Miss Adora +Miss Alure +Miss Chieff +Miss Fortune +Miss Mash +Miss Mood +Miss Nomer +Miss Sanguine +Miss Sublime +Mistress Galore +Monique Mystique +Morgan Fatana +Nashay Kitt +Nicole Lorful +Noë Stalgia +Ora Kelle +Ora Nate +Patty Siyens +Penny Laized +Penny Ramma +Penny Rammic +Penny Talloons +Percey Ferance +Perry Fomance +Phara Waye +Phata Morgana +Pho Latyle +Pho Lume +Phoebe Rant +Phoenix Bright +Pippa Pepper +Pippa Pizazz +Polly Tickle +Poppy Corn +Poppy Cox +Poppy Domm +Poppy Larr +Poppy Lerry +Poppy Sickles +Portia Bella +Portia Nette +Pria Steegious +Pria Steen +Prissa Teen +Raye Bitt +Raye Diante +Raye Nessance +Raye Storm +Remi Nissent +Rey Mantique +Rey Markeble +Rey Moorse +Rey Torric +Rococo Jazz +Roma Ence +Rose Budd +Ruby Redd +Ruby Ree +Ruth Lezz +Sall Laikeen +Sall Lay +Sally Ness +Sam Armie +Sam Ooth +Sara Castique +Sara Donique +Sara Penth +Sarah Pentine +Sarah Reen +Sasha Sass +Satty Phection +Sella Fish +Sella Stice +Selly Foxx +Senna Guinne +Senna Seer +Shia Mirring +Sia Dellic +Sia Dowe +Siam Pathy +Silver Foxx +Siri Price +Sofie Moore +Sofie Stication +Su Blime +Sue Burben +Sue Missif +Sue Pernova +Sue Preem +Super Nova +Suse Pense +Suzu Blime +Temma Tation +Tempest Wilde +Terra Gique +Thea Terre +Tina Cious +Tina Scious +Tira Mendus +Tira Quoise +Trinity Quart +Trixie Foxx +Tye Gress +Tye Phun +Vall Canno +Vall Iant +Vall Orous +Vanity Fairchild +Vicki Tory +Vivi Venus +Vivian Foxx +Vye Vacius +Zahara Dessert + -- cgit v1.2.3 From a1c9078e69ddaec24c632bd1bd85826d6abe2d65 Mon Sep 17 00:00:00 2001 From: Will Da Silva Date: Tue, 1 Oct 2019 15:44:40 -0400 Subject: Add drag queen name generator Could be improved by writing a message that says: "@command_invoker's drag queen name is " --- bot/seasons/pride/drag_queen_name.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 bot/seasons/pride/drag_queen_name.py (limited to 'bot') diff --git a/bot/seasons/pride/drag_queen_name.py b/bot/seasons/pride/drag_queen_name.py new file mode 100644 index 00000000..f34da00e --- /dev/null +++ b/bot/seasons/pride/drag_queen_name.py @@ -0,0 +1,32 @@ +import logging +import random +from pathlib import Path + +from discord.ext import commands + +log = logging.getLogger(__name__) + + +class DragNames(commands.Cog): + """Gives a random drag queen name""" + + def __init__(self, bot: commands.Bot): + self.bot = bot + self.names = self.load_names() + + @staticmethod + def load_names() -> list: + """Loads a list of drag queen names.""" + with open(Path("bot/resources/pride/drag_queen_names.txt"), "r", encoding="utf-8") as f: + return f.readlines() + + @commands.command(name="dragname", aliases=["dragqueenname", "queenme"]) + async def dragname(self, ctx: commands.Context) -> None: + """Sends a message with a drag queen name.""" + await ctx.send(random.choice(self.names)) + + +def setup(bot: commands.Bot) -> None: + """Cog loader for drag queen name generator.""" + bot.add_cog(DragNames(bot)) + log.info("Drag queen name generator cog loaded!") -- cgit v1.2.3 From 63e98827e44d3049922c14fd32ca104548c44b60 Mon Sep 17 00:00:00 2001 From: Will Da Silva Date: Tue, 1 Oct 2019 21:25:50 -0400 Subject: Fix linter issue --- bot/seasons/pride/drag_queen_name.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/seasons/pride/drag_queen_name.py b/bot/seasons/pride/drag_queen_name.py index f34da00e..8f0219f3 100644 --- a/bot/seasons/pride/drag_queen_name.py +++ b/bot/seasons/pride/drag_queen_name.py @@ -8,7 +8,7 @@ log = logging.getLogger(__name__) class DragNames(commands.Cog): - """Gives a random drag queen name""" + """Gives a random drag queen name!""" def __init__(self, bot: commands.Bot): self.bot = bot -- cgit v1.2.3 From c06ec338c1e6d955c4244ed60d08bbeccb90c359 Mon Sep 17 00:00:00 2001 From: vivax3794 <51753506+vivax3794@users.noreply.github.com> Date: Wed, 2 Oct 2019 22:05:23 +0200 Subject: added embed. --- bot/seasons/halloween/hacktober-issue-finder.py | 39 ++++++++++++++++++------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'bot') diff --git a/bot/seasons/halloween/hacktober-issue-finder.py b/bot/seasons/halloween/hacktober-issue-finder.py index 17eec95a..54f205cf 100644 --- a/bot/seasons/halloween/hacktober-issue-finder.py +++ b/bot/seasons/halloween/hacktober-issue-finder.py @@ -1,15 +1,16 @@ import datetime import logging +import random from typing import Dict, List import aiohttp +import discord from discord.ext import commands log = logging.getLogger(__name__) -URL = "https://api.github.com/search/issues" +URL = "https://api.github.com/search/issues?q=label:hacktoberfest+language:python+state:open&per_page=100" HEADERS = {"Accept": "application / vnd.github.v3 + json"} -SEARCH = "label:hacktoberfest+language:python+state:open" class HacktoberIssues(commands.Cog): @@ -24,8 +25,10 @@ class HacktoberIssues(commands.Cog): async def hacktoberissues(self, ctx: commands.Context) -> None: """Get a random python hacktober issue from Github.""" with ctx.typing(): - data = await self.get_issues(ctx) - print("need to use data somehow to commit...", data) + issues = await self.get_issues(ctx) + issue = random.choice(issues) + embed = self.format_embed(issue) + await ctx.send(embed=embed) async def get_issues(self, ctx: commands.Context) -> List[Dict]: """Get a list of the python issues with the label 'hacktoberfest' from the Github api.""" @@ -34,17 +37,31 @@ class HacktoberIssues(commands.Cog): async with aiohttp.ClientSession() as session: # text = TEXT # + "+label:hacktober" - params = { - "q": SEARCH - } - async with session.get(URL, headers=HEADERS, params=params) as response: + + async with session.get(URL, headers=HEADERS) as response: if response.status != 200: await ctx.send(f"ERROR: expected 200 status (got {response.status}) from the GitHub api.") await ctx.send(await response.text()) - data = (await response.json())["items"] - self.cache = data + data = await response.json() + issues = data["items"] + self.cache = issues self.cache_timer = ctx.message.created_at - return data + return issues + + @staticmethod + def format_embed(issue: Dict) -> discord.Embed: + """Format the issue data into a embed.""" + title = issue["title"] + issue_url = issue["url"].replace("api.", "").replace("/repos/", "/") + body = issue["body"] + labels = [label["name"] for label in issue["labels"]] + + embed = discord.Embed(title=title) + embed.description = body + embed.add_field(name="labels", value="\n".join(labels)) + embed.url = issue_url + + return embed def setup(bot: commands.Bot) -> None: -- cgit v1.2.3 From 9fab6ec2d5762d6d25f232efd419e62622270eff Mon Sep 17 00:00:00 2001 From: Will Da Silva Date: Wed, 2 Oct 2019 22:59:24 -0400 Subject: Change drag queen name list to JSON --- bot/resources/pride/drag_queen_names.json | 249 ++++++++++++++++++++++++++++++ bot/resources/pride/drag_queen_names.txt | 248 ----------------------------- bot/seasons/pride/drag_queen_name.py | 5 +- 3 files changed, 252 insertions(+), 250 deletions(-) create mode 100644 bot/resources/pride/drag_queen_names.json delete mode 100644 bot/resources/pride/drag_queen_names.txt (limited to 'bot') diff --git a/bot/resources/pride/drag_queen_names.json b/bot/resources/pride/drag_queen_names.json new file mode 100644 index 00000000..f63cdec3 --- /dev/null +++ b/bot/resources/pride/drag_queen_names.json @@ -0,0 +1,249 @@ +[ + "Adelle Lectible", + "Adelle Light", + "Adelle Lirious", + "Alison Wonder", + "Amie Thyst", + "Amie Zonite", + "Angela Develle", + "Anna Conda", + "Anne Amaley", + "Annie Nigma", + "Aria Hymn", + "Aria Viderci", + "Aroa Mattic", + "Aster Starr", + "Aura Aurora", + "Aura Ley", + "Aurora Dorea", + "Barba Rouse", + "Bea Constrictor", + "Bella Lush", + "Belle Icoza", + "Belle Ligerrente", + "Betty Brilliance", + "Bo Deysious", + "Carol Chorale", + "Cecil Clouds", + "Cecil Sunshine", + "Celeste Booday", + "Chichi Swank", + "Claire Geeman", + "Claire Rickal", + "Claire Voyance", + "Cleo Patrix", + "Connie Fidence", + "Corra Rageous", + "Daye Light", + "Deedee Cation", + "Deedee Sign", + "Dianne Gerous", + "Didi Divine", + "Diemme Monds", + "Dorothy Doughty", + "Dutches Dauntless", + "Ella Gance", + "Ella Gants", + "Ella Menterry", + "Ella Stique", + "Elle Lectrick", + "Elle Lure", + "Emma Geddon", + "Emma Phasis", + "Emma Rald", + "Emme Plosion", + "Emme Pulse", + "Emme Vention", + "Enna Fincible", + "Enne Phinite", + "Enne Treppide", + "Etha Nitty", + "Etha Reyal", + "Euphoria Bliss", + "Eva Nessent", + "Eve Forric", + "Eve Ningowne", + "Eve Ville", + "Faith Lesse", + "Faschia Nation", + "Faye Boulous", + "Faye Lacious", + "Faye Minine", + "Faye Nixx", + "Felicity Spice", + "Freya Domme", + "Gal Gallant", + "Gal Galore", + "Gal Lante", + "Gemma Safir", + "Gena Rocity", + "Genna Russ", + "Gigi Lamour", + "Gigi Rand", + "Glemma Rouss", + "Grace Iyus", + "Haye Light", + "Hazel Nutt", + "Hella Billy", + "Hella Centrique", + "Hella Cious", + "Hella Riouss", + "Hella Whole", + "Hellen Back", + "Herra Zee", + "Ina Creddeble", + "Ina Fernalle", + "Jo Nee", + "Jo Phial", + "Joye Ryde", + "Jue Cee", + "Jue Wells", + "Juju Bee", + "Kaia Cayenne", + "Kaye Bye", + "Kitsch Kitsch Bang Bang", + "Lady Lace", + "Lavish Lazuli", + "Lea Ness", + "Leye Berty", + "Lisse Truss", + "Liv Lee", + "Lola Lavish", + "Lolo Yaltie", + "Lucy Fur", + "Lucy Luck", + "Lulu LaBye", + "Lulu Xuri", + "Lunaye Clipse", + "Lyra Kall", + "Maggie Magma", + "Mara Bells", + "Marry Golds", + "Marry Nayde", + "Marry Sipan", + "Marve Vellus", + "Mary Ganal", + "Mary Malade", + "May Jestic", + "May Lancholly", + "May Licious", + "May Lodi", + "May Morable", + "May Stirius", + "May Varlous", + "Melody Gale", + "Melody Toune", + "Miss Adora", + "Miss Alure", + "Miss Chieff", + "Miss Fortune", + "Miss Mash", + "Miss Mood", + "Miss Nomer", + "Miss Sanguine", + "Miss Sublime", + "Mistress Galore", + "Monique Mystique", + "Morgan Fatana", + "Nashay Kitt", + "Nicole Lorful", + "Noë Stalgia", + "Ora Kelle", + "Ora Nate", + "Patty Siyens", + "Penny Laized", + "Penny Ramma", + "Penny Rammic", + "Penny Talloons", + "Percey Ferance", + "Perry Fomance", + "Phara Waye", + "Phata Morgana", + "Pho Latyle", + "Pho Lume", + "Phoebe Rant", + "Phoenix Bright", + "Pippa Pepper", + "Pippa Pizazz", + "Polly Tickle", + "Poppy Corn", + "Poppy Cox", + "Poppy Domm", + "Poppy Larr", + "Poppy Lerry", + "Poppy Sickles", + "Portia Bella", + "Portia Nette", + "Pria Steegious", + "Pria Steen", + "Prissa Teen", + "Raye Bitt", + "Raye Diante", + "Raye Nessance", + "Raye Storm", + "Remi Nissent", + "Rey Mantique", + "Rey Markeble", + "Rey Moorse", + "Rey Torric", + "Rococo Jazz", + "Roma Ence", + "Rose Budd", + "Ruby Redd", + "Ruby Ree", + "Ruth Lezz", + "Sall Laikeen", + "Sall Lay", + "Sally Ness", + "Sam Armie", + "Sam Ooth", + "Sara Castique", + "Sara Donique", + "Sara Penth", + "Sarah Pentine", + "Sarah Reen", + "Sasha Sass", + "Satty Phection", + "Sella Fish", + "Sella Stice", + "Selly Foxx", + "Senna Guinne", + "Senna Seer", + "Shia Mirring", + "Sia Dellic", + "Sia Dowe", + "Siam Pathy", + "Silver Foxx", + "Siri Price", + "Sofie Moore", + "Sofie Stication", + "Su Blime", + "Sue Burben", + "Sue Missif", + "Sue Pernova", + "Sue Preem", + "Super Nova", + "Suse Pense", + "Suzu Blime", + "Temma Tation", + "Tempest Wilde", + "Terra Gique", + "Thea Terre", + "Tina Cious", + "Tina Scious", + "Tira Mendus", + "Tira Quoise", + "Trinity Quart", + "Trixie Foxx", + "Tye Gress", + "Tye Phun", + "Vall Canno", + "Vall Iant", + "Vall Orous", + "Vanity Fairchild", + "Vicki Tory", + "Vivi Venus", + "Vivian Foxx", + "Vye Vacius", + "Zahara Dessert" +] \ No newline at end of file diff --git a/bot/resources/pride/drag_queen_names.txt b/bot/resources/pride/drag_queen_names.txt deleted file mode 100644 index 1701b760..00000000 --- a/bot/resources/pride/drag_queen_names.txt +++ /dev/null @@ -1,248 +0,0 @@ -Adelle Lectible -Adelle Light -Adelle Lirious -Alison Wonder -Amie Thyst -Amie Zonite -Angela Develle -Anna Conda -Anne Amaley -Annie Nigma -Aria Hymn -Aria Viderci -Aroa Mattic -Aster Starr -Aura Aurora -Aura Ley -Aurora Dorea -Barba Rouse -Bea Constrictor -Bella Lush -Belle Icoza -Belle Ligerrente -Betty Brilliance -Bo Deysious -Carol Chorale -Cecil Clouds -Cecil Sunshine -Celeste Booday -Chichi Swank -Claire Geeman -Claire Rickal -Claire Voyance -Cleo Patrix -Connie Fidence -Corra Rageous -Daye Light -Deedee Cation -Deedee Sign -Dianne Gerous -Didi Divine -Diemme Monds -Dorothy Doughty -Dutches Dauntless -Ella Gance -Ella Gants -Ella Menterry -Ella Stique -Elle Lectrick -Elle Lure -Emma Geddon -Emma Phasis -Emma Rald -Emme Plosion -Emme Pulse -Emme Vention -Enna Fincible -Enne Phinite -Enne Treppide -Etha Nitty -Etha Reyal -Euphoria Bliss -Eva Nessent -Eve Forric -Eve Ningowne -Eve Ville -Faith Lesse -Faschia Nation -Faye Boulous -Faye Lacious -Faye Minine -Faye Nixx -Felicity Spice -Freya Domme -Gal Gallant -Gal Galore -Gal Lante -Gemma Safir -Gena Rocity -Genna Russ -Gigi Lamour -Gigi Rand -Glemma Rouss -Grace Iyus -Haye Light -Hazel Nutt -Hella Billy -Hella Centrique -Hella Cious -Hella Riouss -Hella Whole -Hellen Back -Herra Zee -Ina Creddeble -Ina Fernalle -Jo Nee -Jo Phial -Joye Ryde -Jue Cee -Jue Wells -Juju Bee -Kaia Cayenne -Kaye Bye -Kitsch Kitsch Bang Bang -Lady Lace -Lavish Lazuli -Lea Ness -Leye Berty -Lisse Truss -Liv Lee -Lola Lavish -Lolo Yaltie -Lucy Fur -Lucy Luck -Lulu LaBye -Lulu Xuri -Lunaye Clipse -Lyra Kall -Maggie Magma -Mara Bells -Marry Golds -Marry Nayde -Marry Sipan -Marve Vellus -Mary Ganal -Mary Malade -May Jestic -May Lancholly -May Licious -May Lodi -May Morable -May Stirius -May Varlous -Melody Gale -Melody Toune -Miss Adora -Miss Alure -Miss Chieff -Miss Fortune -Miss Mash -Miss Mood -Miss Nomer -Miss Sanguine -Miss Sublime -Mistress Galore -Monique Mystique -Morgan Fatana -Nashay Kitt -Nicole Lorful -Noë Stalgia -Ora Kelle -Ora Nate -Patty Siyens -Penny Laized -Penny Ramma -Penny Rammic -Penny Talloons -Percey Ferance -Perry Fomance -Phara Waye -Phata Morgana -Pho Latyle -Pho Lume -Phoebe Rant -Phoenix Bright -Pippa Pepper -Pippa Pizazz -Polly Tickle -Poppy Corn -Poppy Cox -Poppy Domm -Poppy Larr -Poppy Lerry -Poppy Sickles -Portia Bella -Portia Nette -Pria Steegious -Pria Steen -Prissa Teen -Raye Bitt -Raye Diante -Raye Nessance -Raye Storm -Remi Nissent -Rey Mantique -Rey Markeble -Rey Moorse -Rey Torric -Rococo Jazz -Roma Ence -Rose Budd -Ruby Redd -Ruby Ree -Ruth Lezz -Sall Laikeen -Sall Lay -Sally Ness -Sam Armie -Sam Ooth -Sara Castique -Sara Donique -Sara Penth -Sarah Pentine -Sarah Reen -Sasha Sass -Satty Phection -Sella Fish -Sella Stice -Selly Foxx -Senna Guinne -Senna Seer -Shia Mirring -Sia Dellic -Sia Dowe -Siam Pathy -Silver Foxx -Siri Price -Sofie Moore -Sofie Stication -Su Blime -Sue Burben -Sue Missif -Sue Pernova -Sue Preem -Super Nova -Suse Pense -Suzu Blime -Temma Tation -Tempest Wilde -Terra Gique -Thea Terre -Tina Cious -Tina Scious -Tira Mendus -Tira Quoise -Trinity Quart -Trixie Foxx -Tye Gress -Tye Phun -Vall Canno -Vall Iant -Vall Orous -Vanity Fairchild -Vicki Tory -Vivi Venus -Vivian Foxx -Vye Vacius -Zahara Dessert - diff --git a/bot/seasons/pride/drag_queen_name.py b/bot/seasons/pride/drag_queen_name.py index 8f0219f3..43813fbd 100644 --- a/bot/seasons/pride/drag_queen_name.py +++ b/bot/seasons/pride/drag_queen_name.py @@ -1,3 +1,4 @@ +import json import logging import random from pathlib import Path @@ -17,8 +18,8 @@ class DragNames(commands.Cog): @staticmethod def load_names() -> list: """Loads a list of drag queen names.""" - with open(Path("bot/resources/pride/drag_queen_names.txt"), "r", encoding="utf-8") as f: - return f.readlines() + with open(Path("bot/resources/pride/drag_queen_names.json"), "r", encoding="utf-8") as f: + return json.load(f) @commands.command(name="dragname", aliases=["dragqueenname", "queenme"]) async def dragname(self, ctx: commands.Context) -> None: -- cgit v1.2.3 From 15ad5e5e689f5769ff8419466c96207cd5efec0d Mon Sep 17 00:00:00 2001 From: Will Da Silva Date: Thu, 3 Oct 2019 00:18:57 -0400 Subject: Add pride facts for 2020 --- bot/resources/pride/facts.json | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 bot/resources/pride/facts.json (limited to 'bot') diff --git a/bot/resources/pride/facts.json b/bot/resources/pride/facts.json new file mode 100644 index 00000000..0b7a4358 --- /dev/null +++ b/bot/resources/pride/facts.json @@ -0,0 +1,34 @@ +{ + "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\".", + "October 8th is lesbian pride day!", + "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.", + "Every year for the past few decades, a greater percentage of people have identified as being homosexual or bisexual.", + "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.", + "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 newline at end of file -- cgit v1.2.3 From 1ef715bd24a08abb6b2c9b9a23edb46ac9838787 Mon Sep 17 00:00:00 2001 From: Will Da Silva Date: Thu, 3 Oct 2019 03:08:36 -0400 Subject: Add pride facts cog --- bot/seasons/pride/pride_facts.py | 83 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 bot/seasons/pride/pride_facts.py (limited to 'bot') diff --git a/bot/seasons/pride/pride_facts.py b/bot/seasons/pride/pride_facts.py new file mode 100644 index 00000000..90804d65 --- /dev/null +++ b/bot/seasons/pride/pride_facts.py @@ -0,0 +1,83 @@ +from datetime import datetime +import json +import logging +from typing import Union +import random +from pathlib import Path + +import dateutil.parser +from discord.ext import commands + +log = logging.getLogger(__name__) + + +class PrideFacts(commands.Cog): + """Provides a new fact every day during the Pride season!""" + + def __init__(self, bot: commands.Bot): + self.bot = bot + self.facts = self.load_facts() + + @staticmethod + def load_facts() -> dict: + """Loads a dictionary of years mapping to lists of facts.""" + with open(Path("bot/resources/pride/facts.json"), "r", encoding="utf-8") as f: + return json.load(f) + + async def random_fact(self, ctx: commands.Context): + """Provides a fact from any valid day.""" + now = datetime.utcnow() + previous_years_facts = (self.facts[x] for x in self.facts.keys() if int(x) < now.year) + current_year_facts = self.facts.get(str(now.year), [])[:now.day] + previous_facts = current_year_facts + [x for y in previous_years_facts for x in y] + try: + await ctx.send(random.choice(previous_facts)) + except IndexError: + await ctx.send("No facts available") + + async def select_fact(self, ctx: commands.Context, _date: Union[str, datetime]): + """Provides the fact for the specified day, if valid.""" + now = datetime.utcnow() + if isinstance(_date, str): + try: + date = dateutil.parser.parse(_date, dayfirst=True, fuzzy=True) + except (ValueError, OverflowError) as err: + await ctx.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 ctx.send(self.facts[str(date.year)][date.day - 1]) + except KeyError: + await ctx.send(f"The year {date.year} is not yet supported") + return + except IndexError: + await ctx.send(f"Day {date.day} of {date.year} is not yet support") + return + else: + await ctx.send("The fact for the selected day is not yet available.") + + @commands.command(name="pridefact", aliases=["pridefacts"]) + async def pridefact(self, ctx: commands.Context) -> 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. + """ + message_body = ctx.message.content[len(ctx.invoked_with) + 2:] + if message_body == "": + await self.select_fact(ctx, datetime.utcnow()) + elif message_body.lower().startswith("rand"): + await self.random_fact(ctx) + else: + await self.select_fact(ctx, message_body) + + +def setup(bot: commands.Bot) -> None: + """Cog loader for pride facts.""" + bot.add_cog(PrideFacts(bot)) + log.info("Pride facts cog loaded!") -- cgit v1.2.3 From 000110847972c6d74f57830737f599e0efe9bd3e Mon Sep 17 00:00:00 2001 From: Will Da Silva Date: Thu, 3 Oct 2019 03:28:22 -0400 Subject: Minor improvements for pride facts cog --- bot/resources/pride/facts.json | 6 +++--- bot/seasons/pride/pride_facts.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'bot') diff --git a/bot/resources/pride/facts.json b/bot/resources/pride/facts.json index 0b7a4358..f6597201 100644 --- a/bot/resources/pride/facts.json +++ b/bot/resources/pride/facts.json @@ -3,11 +3,11 @@ "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\".", - "October 8th is lesbian pride day!", - "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.", - "Every year for the past few decades, a greater percentage of people have identified as being homosexual or bisexual.", + "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.", diff --git a/bot/seasons/pride/pride_facts.py b/bot/seasons/pride/pride_facts.py index 90804d65..d691b7e7 100644 --- a/bot/seasons/pride/pride_facts.py +++ b/bot/seasons/pride/pride_facts.py @@ -40,7 +40,7 @@ class PrideFacts(commands.Cog): now = datetime.utcnow() if isinstance(_date, str): try: - date = dateutil.parser.parse(_date, dayfirst=True, fuzzy=True) + date = dateutil.parser.parse(_date, dayfirst=False, yearfirst=False, fuzzy=True) except (ValueError, OverflowError) as err: await ctx.send(f"Error parsing date: {err}") return -- cgit v1.2.3 From 76caa7577230a9a5617c9ea9ba28190b2082b571 Mon Sep 17 00:00:00 2001 From: Will Da Silva Date: Thu, 3 Oct 2019 03:46:29 -0400 Subject: Fix linter issues I don't understand why these linter issues don't come up when I run flake8 myself --- bot/seasons/pride/pride_facts.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bot') diff --git a/bot/seasons/pride/pride_facts.py b/bot/seasons/pride/pride_facts.py index d691b7e7..3673fa95 100644 --- a/bot/seasons/pride/pride_facts.py +++ b/bot/seasons/pride/pride_facts.py @@ -1,8 +1,8 @@ -from datetime import datetime import json +from datetime import datetime import logging -from typing import Union import random +from typing import Union from pathlib import Path import dateutil.parser @@ -24,7 +24,7 @@ class PrideFacts(commands.Cog): with open(Path("bot/resources/pride/facts.json"), "r", encoding="utf-8") as f: return json.load(f) - async def random_fact(self, ctx: commands.Context): + async def random_fact(self, ctx: commands.Context) -> None: """Provides a fact from any valid day.""" now = datetime.utcnow() previous_years_facts = (self.facts[x] for x in self.facts.keys() if int(x) < now.year) @@ -35,7 +35,7 @@ class PrideFacts(commands.Cog): except IndexError: await ctx.send("No facts available") - async def select_fact(self, ctx: commands.Context, _date: Union[str, datetime]): + async def select_fact(self, ctx: commands.Context, _date: Union[str, datetime]) -> None: """Provides the fact for the specified day, if valid.""" now = datetime.utcnow() if isinstance(_date, str): -- cgit v1.2.3 From c03db25cfda6e5bf302c1fcd8ad682422ad144bf Mon Sep 17 00:00:00 2001 From: Will Da Silva Date: Thu, 3 Oct 2019 03:49:40 -0400 Subject: Fix linter issues --- bot/seasons/pride/pride_facts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/seasons/pride/pride_facts.py b/bot/seasons/pride/pride_facts.py index 3673fa95..95ca4d24 100644 --- a/bot/seasons/pride/pride_facts.py +++ b/bot/seasons/pride/pride_facts.py @@ -1,9 +1,9 @@ import json -from datetime import datetime import logging import random -from typing import Union +from datetime import datetime from pathlib import Path +from typing import Union import dateutil.parser from discord.ext import commands -- cgit v1.2.3 From 3492e0871d08523755ecc62c3e1559617d5360d4 Mon Sep 17 00:00:00 2001 From: Will Da Silva Date: Thu, 3 Oct 2019 13:17:21 -0400 Subject: Add task to post daily pride fact Also, pride facts are posted as embeds now --- bot/seasons/pride/pride_facts.py | 49 +++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 13 deletions(-) (limited to 'bot') diff --git a/bot/seasons/pride/pride_facts.py b/bot/seasons/pride/pride_facts.py index 95ca4d24..d2ea0461 100644 --- a/bot/seasons/pride/pride_facts.py +++ b/bot/seasons/pride/pride_facts.py @@ -1,3 +1,4 @@ +import asyncio import json import logging import random @@ -6,10 +7,16 @@ from pathlib import Path from typing import Union import dateutil.parser +import discord from discord.ext import commands +from bot.constants import Channels +from bot.constants import Colours + log = logging.getLogger(__name__) +Sendable = Union[commands.Context, discord.TextChannel] + class PrideFacts(commands.Cog): """Provides a new fact every day during the Pride season!""" @@ -24,39 +31,46 @@ class PrideFacts(commands.Cog): with open(Path("bot/resources/pride/facts.json"), "r", encoding="utf-8") as f: return json.load(f) - async def random_fact(self, ctx: commands.Context) -> None: - """Provides a fact from any valid day.""" + async def send_pride_fact_daily(self) -> None: + """Background task to post the daily pride fact every day.""" + channel = self.bot.get_channel(Channels.seasonalbot_chat) + while True: + await self.send_select_fact(channel, datetime.utcnow()) + await asyncio.sleep(24 * 60 * 60) + + async def send_random_fact(self, ctx: commands.Context) -> None: + """Provides a fact from any previous day, or today.""" now = datetime.utcnow() previous_years_facts = (self.facts[x] for x in self.facts.keys() if int(x) < now.year) current_year_facts = self.facts.get(str(now.year), [])[:now.day] previous_facts = current_year_facts + [x for y in previous_years_facts for x in y] try: - await ctx.send(random.choice(previous_facts)) + await ctx.send(embed=self.make_embed(random.choice(previous_facts))) except IndexError: await ctx.send("No facts available") - async def select_fact(self, ctx: commands.Context, _date: Union[str, datetime]) -> None: - """Provides the fact for the specified day, if valid.""" + async def send_select_fact(self, target: Sendable, _date: Union[str, datetime]) -> None: + """Provides the fact for the specified day, if the day is today, or is in the past.""" now = datetime.utcnow() if isinstance(_date, str): try: date = dateutil.parser.parse(_date, dayfirst=False, yearfirst=False, fuzzy=True) except (ValueError, OverflowError) as err: - await ctx.send(f"Error parsing date: {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 ctx.send(self.facts[str(date.year)][date.day - 1]) + await target.send(embed=self.make_embed(self.facts[str(date.year)][date.day - 1])) except KeyError: - await ctx.send(f"The year {date.year} is not yet supported") + await target.send(f"The year {date.year} is not yet supported") return except IndexError: - await ctx.send(f"Day {date.day} of {date.year} is not yet support") + await target.send(f"Day {date.day} of {date.year} is not yet support") return else: - await ctx.send("The fact for the selected day is not yet available.") + await target.send("The fact for the selected day is not yet available.") @commands.command(name="pridefact", aliases=["pridefacts"]) async def pridefact(self, ctx: commands.Context) -> None: @@ -70,14 +84,23 @@ class PrideFacts(commands.Cog): """ message_body = ctx.message.content[len(ctx.invoked_with) + 2:] if message_body == "": - await self.select_fact(ctx, datetime.utcnow()) + await self.send_select_fact(ctx, datetime.utcnow()) elif message_body.lower().startswith("rand"): - await self.random_fact(ctx) + await self.send_random_fact(ctx) else: - await self.select_fact(ctx, message_body) + await self.send_select_fact(ctx, message_body) + + def make_embed(self, fact) -> discord.Embed: + """Makes a nice embed for the fact to be sent.""" + return discord.Embed( + colour=Colours.pink, + title="Pride Fact!", + description=fact + ) def setup(bot: commands.Bot) -> None: """Cog loader for pride facts.""" + bot.loop.create_task(PrideFacts(bot).send_pride_fact_daily()) bot.add_cog(PrideFacts(bot)) log.info("Pride facts cog loaded!") -- cgit v1.2.3 From bcfe86418da57a0c66fc077c1607171b29448aca Mon Sep 17 00:00:00 2001 From: Will Da Silva Date: Thu, 3 Oct 2019 13:34:11 -0400 Subject: Fix linter issue --- bot/seasons/pride/pride_facts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/seasons/pride/pride_facts.py b/bot/seasons/pride/pride_facts.py index d2ea0461..b705bfb4 100644 --- a/bot/seasons/pride/pride_facts.py +++ b/bot/seasons/pride/pride_facts.py @@ -90,7 +90,7 @@ class PrideFacts(commands.Cog): else: await self.send_select_fact(ctx, message_body) - def make_embed(self, fact) -> discord.Embed: + def make_embed(self, fact: str) -> discord.Embed: """Makes a nice embed for the fact to be sent.""" return discord.Embed( colour=Colours.pink, -- cgit v1.2.3 From c2df3759d697db782f9553b7fdef646291f427e9 Mon Sep 17 00:00:00 2001 From: Numerlor Date: Thu, 3 Oct 2019 20:11:59 +0200 Subject: limit issue command to global whitelist and seasonalbot_chat --- bot/seasons/evergreen/issues.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/seasons/evergreen/issues.py b/bot/seasons/evergreen/issues.py index 438ab475..08d78e30 100644 --- a/bot/seasons/evergreen/issues.py +++ b/bot/seasons/evergreen/issues.py @@ -3,10 +3,11 @@ import logging import discord from discord.ext import commands -from bot.constants import Colours +from bot.constants import Channels, Colours, WHITELISTED_CHANNELS from bot.decorators import override_in_channel log = logging.getLogger(__name__) +ISSUE_WHITELIST = WHITELISTED_CHANNELS + (Channels.seasonalbot_chat,) class Issues(commands.Cog): @@ -16,7 +17,7 @@ class Issues(commands.Cog): self.bot = bot @commands.command(aliases=("issues",)) - @override_in_channel() + @override_in_channel(ISSUE_WHITELIST) async def issue( self, ctx: commands.Context, number: int, repository: str = "seasonalbot", user: str = "python-discord" ) -> None: -- cgit v1.2.3 From eaf49758e7a175aeeeeafdb66c3c1a5fc96a4b10 Mon Sep 17 00:00:00 2001 From: Numerlor Date: Thu, 3 Oct 2019 20:21:39 +0200 Subject: add the adventofcode channel to Channels constant --- bot/constants.py | 1 + 1 file changed, 1 insertion(+) (limited to 'bot') diff --git a/bot/constants.py b/bot/constants.py index 0d4321c8..c1722158 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -22,6 +22,7 @@ class AdventOfCode: class Channels(NamedTuple): admins = 365960823622991872 + advent_of_code = 517745814039166986 announcements = int(environ.get("CHANNEL_ANNOUNCEMENTS", 354619224620138496)) big_brother_logs = 468507907357409333 bot = 267659945086812160 -- cgit v1.2.3 From 9d6ea0f020a448cb1498f0c4eeb560858c510a69 Mon Sep 17 00:00:00 2001 From: Numerlor Date: Thu, 3 Oct 2019 20:27:09 +0200 Subject: limit Advent Of Code commands to global whitelist and the AoC channel --- bot/seasons/christmas/adventofcode.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/seasons/christmas/adventofcode.py b/bot/seasons/christmas/adventofcode.py index 513c1020..a88e5ac3 100644 --- a/bot/seasons/christmas/adventofcode.py +++ b/bot/seasons/christmas/adventofcode.py @@ -13,7 +13,7 @@ from bs4 import BeautifulSoup from discord.ext import commands from pytz import timezone -from bot.constants import AdventOfCode as AocConfig, Channels, Colours, Emojis, Tokens +from bot.constants import AdventOfCode as AocConfig, Channels, Colours, Emojis, Tokens, WHITELISTED_CHANNELS from bot.decorators import override_in_channel log = logging.getLogger(__name__) @@ -24,6 +24,8 @@ AOC_SESSION_COOKIE = {"session": Tokens.aoc_session_cookie} EST = timezone("EST") COUNTDOWN_STEP = 60 * 5 +AOC_WHITELIST = WHITELISTED_CHANNELS + (Channels.advent_of_code,) + def is_in_advent() -> bool: """Utility function to check if we are between December 1st and December 25th.""" @@ -126,7 +128,7 @@ class AdventOfCode(commands.Cog): self.status_task = asyncio.ensure_future(self.bot.loop.create_task(status_coro)) @commands.group(name="adventofcode", aliases=("aoc",), invoke_without_command=True) - @override_in_channel() + @override_in_channel(AOC_WHITELIST) async def adventofcode_group(self, ctx: commands.Context) -> None: """All of the Advent of Code commands.""" await ctx.send_help(ctx.command) -- cgit v1.2.3 From bc866f5e5bdfe49318601a12c5bac8134d5c06be Mon Sep 17 00:00:00 2001 From: Numerlor Date: Fri, 4 Oct 2019 21:06:32 +0200 Subject: override global whitelist on all hacktober subcommands --- bot/seasons/halloween/hacktoberstats.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bot') diff --git a/bot/seasons/halloween/hacktoberstats.py b/bot/seasons/halloween/hacktoberstats.py index 9ad44e3f..ab8d865c 100644 --- a/bot/seasons/halloween/hacktoberstats.py +++ b/bot/seasons/halloween/hacktoberstats.py @@ -58,6 +58,7 @@ class HacktoberStats(commands.Cog): await self.get_stats(ctx, github_username) @hacktoberstats_group.command(name="link") + @override_in_channel(HACKTOBER_WHITELIST) async def link_user(self, ctx: commands.Context, github_username: str = None) -> None: """ Link the invoking user's Github github_username to their Discord ID. @@ -91,6 +92,7 @@ class HacktoberStats(commands.Cog): await ctx.send(f"{author_mention}, a GitHub username is required to link your account") @hacktoberstats_group.command(name="unlink") + @override_in_channel(HACKTOBER_WHITELIST) async def unlink_user(self, ctx: commands.Context) -> None: """Remove the invoking user's account link from the log.""" author_id, author_mention = HacktoberStats._author_mention_from_context(ctx) -- cgit v1.2.3 From a7c7fb7aacc477eb498c3872adf71d10cb798f67 Mon Sep 17 00:00:00 2001 From: vivax3794 <51753506+vivax3794@users.noreply.github.com> Date: Sat, 5 Oct 2019 06:30:48 +0200 Subject: added beginner --- bot/seasons/halloween/hacktober-issue-finder.py | 50 ++++++++++++++++++------- 1 file changed, 36 insertions(+), 14 deletions(-) (limited to 'bot') diff --git a/bot/seasons/halloween/hacktober-issue-finder.py b/bot/seasons/halloween/hacktober-issue-finder.py index 54f205cf..3c4780a9 100644 --- a/bot/seasons/halloween/hacktober-issue-finder.py +++ b/bot/seasons/halloween/hacktober-issue-finder.py @@ -1,7 +1,7 @@ import datetime import logging import random -from typing import Dict, List +from typing import Dict, List, Optional import aiohttp import discord @@ -9,7 +9,7 @@ from discord.ext import commands log = logging.getLogger(__name__) -URL = "https://api.github.com/search/issues?q=label:hacktoberfest+language:python+state:open&per_page=100" +URL = "https://api.github.com/search/issues?per_page=100&q=is:issue+label:hacktoberfest+language:python+state:open" HEADERS = {"Accept": "application / vnd.github.v3 + json"} @@ -18,34 +18,55 @@ class HacktoberIssues(commands.Cog): def __init__(self, bot: commands.Bot): self.bot = bot - self.cache = None - self.cache_timer = datetime.datetime(1, 1, 1) + self.cache_normal = None + self.cache_timer_normal = datetime.datetime(1, 1, 1) + self.cache_beginner = None + self.cache_timer_beginner = datetime.datetime(1, 1, 1) @commands.command() - async def hacktoberissues(self, ctx: commands.Context) -> None: + async def hacktoberissues(self, ctx: commands.Context, option: str = "") -> None: """Get a random python hacktober issue from Github.""" with ctx.typing(): - issues = await self.get_issues(ctx) + issues = await self.get_issues(ctx, option) + if issues is None: + return issue = random.choice(issues) embed = self.format_embed(issue) - await ctx.send(embed=embed) + await ctx.send(embed=embed) - async def get_issues(self, ctx: commands.Context) -> List[Dict]: + async def get_issues(self, ctx: commands.Context, option: str) -> Optional[List[Dict]]: """Get a list of the python issues with the label 'hacktoberfest' from the Github api.""" - if (ctx.message.created_at - self.cache_timer).seconds <= 60: - return self.cache + if option == "beginner": + if (ctx.message.created_at - self.cache_timer_beginner).seconds <= 60: + return self.cache_beginner + elif (ctx.message.created_at - self.cache_timer_normal).seconds <= 60: + return self.cache_normal async with aiohttp.ClientSession() as session: - # text = TEXT # + "+label:hacktober" + if option == "beginner": + url = URL + '+label:"good first issue"' + else: + url = URL - async with session.get(URL, headers=HEADERS) as response: + async with session.get(url, headers=HEADERS) as response: if response.status != 200: await ctx.send(f"ERROR: expected 200 status (got {response.status}) from the GitHub api.") await ctx.send(await response.text()) + return None data = await response.json() issues = data["items"] - self.cache = issues - self.cache_timer = ctx.message.created_at + + if len(issues) == 0: + await ctx.send(f"ERROR: no issues returned from GitHub api. with url: {response.url}") + return None + + if option == "beginner": + self.cache_beginner = issues + self.cache_timer_beginner = ctx.message.created_at + else: + self.cache_normal = issues + self.cache_timer_normal = ctx.message.created_at + return issues @staticmethod @@ -60,6 +81,7 @@ class HacktoberIssues(commands.Cog): embed.description = body embed.add_field(name="labels", value="\n".join(labels)) embed.url = issue_url + embed.set_footer(text=issue_url) return embed -- cgit v1.2.3 From cb90d1269dbad0a29fe0a03a7219428ff5a38f51 Mon Sep 17 00:00:00 2001 From: vivax3794 <51753506+vivax3794@users.noreply.github.com> Date: Sat, 5 Oct 2019 07:29:53 +0200 Subject: bug fixes --- bot/seasons/halloween/hacktober-issue-finder.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'bot') diff --git a/bot/seasons/halloween/hacktober-issue-finder.py b/bot/seasons/halloween/hacktober-issue-finder.py index 3c4780a9..a9cff610 100644 --- a/bot/seasons/halloween/hacktober-issue-finder.py +++ b/bot/seasons/halloween/hacktober-issue-finder.py @@ -1,7 +1,7 @@ import datetime import logging import random -from typing import Dict, List, Optional +from typing import Dict, Optional import aiohttp import discord @@ -27,14 +27,14 @@ class HacktoberIssues(commands.Cog): async def hacktoberissues(self, ctx: commands.Context, option: str = "") -> None: """Get a random python hacktober issue from Github.""" with ctx.typing(): - issues = await self.get_issues(ctx, option) + issues = (await self.get_issues(ctx, option))["items"] if issues is None: return issue = random.choice(issues) embed = self.format_embed(issue) await ctx.send(embed=embed) - async def get_issues(self, ctx: commands.Context, option: str) -> Optional[List[Dict]]: + async def get_issues(self, ctx: commands.Context, option: str) -> Optional[Dict]: """Get a list of the python issues with the label 'hacktoberfest' from the Github api.""" if option == "beginner": if (ctx.message.created_at - self.cache_timer_beginner).seconds <= 60: @@ -45,8 +45,14 @@ class HacktoberIssues(commands.Cog): async with aiohttp.ClientSession() as session: if option == "beginner": url = URL + '+label:"good first issue"' + if self.cache_beginner is not None: + page = random.randint(1, min(1000, self.cache_beginner["total_count"]) // 100) + url += f"&page={page}" else: url = URL + if self.cache_normal is not None: + page = random.randint(1, min(1000, self.cache_normal["total_count"])) + url += f"&page={page}" async with session.get(url, headers=HEADERS) as response: if response.status != 200: @@ -54,20 +60,19 @@ class HacktoberIssues(commands.Cog): await ctx.send(await response.text()) return None data = await response.json() - issues = data["items"] - if len(issues) == 0: + if len(data["items"]) == 0: await ctx.send(f"ERROR: no issues returned from GitHub api. with url: {response.url}") return None if option == "beginner": - self.cache_beginner = issues + self.cache_beginner = data self.cache_timer_beginner = ctx.message.created_at else: - self.cache_normal = issues + self.cache_normal = data self.cache_timer_normal = ctx.message.created_at - return issues + return data @staticmethod def format_embed(issue: Dict) -> discord.Embed: -- cgit v1.2.3 From 3e7f5904aed66ab753e5d186cfcd5f63adc58ede Mon Sep 17 00:00:00 2001 From: vivax3794 <51753506+vivax3794@users.noreply.github.com> Date: Mon, 7 Oct 2019 15:03:29 +0200 Subject: Added logging to "get_issues". --- bot/seasons/halloween/hacktober-issue-finder.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'bot') diff --git a/bot/seasons/halloween/hacktober-issue-finder.py b/bot/seasons/halloween/hacktober-issue-finder.py index a9cff610..57273ee7 100644 --- a/bot/seasons/halloween/hacktober-issue-finder.py +++ b/bot/seasons/halloween/hacktober-issue-finder.py @@ -27,10 +27,10 @@ class HacktoberIssues(commands.Cog): async def hacktoberissues(self, ctx: commands.Context, option: str = "") -> None: """Get a random python hacktober issue from Github.""" with ctx.typing(): - issues = (await self.get_issues(ctx, option))["items"] + issues = await self.get_issues(ctx, option) if issues is None: return - issue = random.choice(issues) + issue = random.choice(issues["items"]) embed = self.format_embed(issue) await ctx.send(embed=embed) @@ -38,8 +38,10 @@ class HacktoberIssues(commands.Cog): """Get a list of the python issues with the label 'hacktoberfest' from the Github api.""" if option == "beginner": if (ctx.message.created_at - self.cache_timer_beginner).seconds <= 60: + log.debug("using cache") return self.cache_beginner elif (ctx.message.created_at - self.cache_timer_normal).seconds <= 60: + log.debug("using cache") return self.cache_normal async with aiohttp.ClientSession() as session: @@ -54,14 +56,17 @@ class HacktoberIssues(commands.Cog): page = random.randint(1, min(1000, self.cache_normal["total_count"])) url += f"&page={page}" + log.debug(f"making api request to url: {url}") async with session.get(url, headers=HEADERS) as response: if response.status != 200: + log.error(f"expected 200 status (got {response.status}) from the GitHub api.") await ctx.send(f"ERROR: expected 200 status (got {response.status}) from the GitHub api.") await ctx.send(await response.text()) return None data = await response.json() if len(data["items"]) == 0: + log.error(f"no issues returned from GitHub api. with url: {response.url}") await ctx.send(f"ERROR: no issues returned from GitHub api. with url: {response.url}") return None -- cgit v1.2.3 From d38f7c384487c5ee3da9fca1cff8df5dfb84ec21 Mon Sep 17 00:00:00 2001 From: vivax3794 <51753506+vivax3794@users.noreply.github.com> Date: Sat, 12 Oct 2019 02:18:32 +0200 Subject: Added Beginner to docstring. --- bot/seasons/halloween/hacktober-issue-finder.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/seasons/halloween/hacktober-issue-finder.py b/bot/seasons/halloween/hacktober-issue-finder.py index 57273ee7..5978eb95 100644 --- a/bot/seasons/halloween/hacktober-issue-finder.py +++ b/bot/seasons/halloween/hacktober-issue-finder.py @@ -25,7 +25,12 @@ class HacktoberIssues(commands.Cog): @commands.command() async def hacktoberissues(self, ctx: commands.Context, option: str = "") -> None: - """Get a random python hacktober issue from Github.""" + """ + Get a random python hacktober issue from Github. + + If the command is run with beginner (`!hacktoberissues beginner`): + It will also narrow it down to the "first good issue label". + """ with ctx.typing(): issues = await self.get_issues(ctx, option) if issues is None: -- cgit v1.2.3 From 2ed67377928c55ab766e08c17e392eae5667f0e9 Mon Sep 17 00:00:00 2001 From: vivax3794 <51753506+vivax3794@users.noreply.github.com> Date: Sat, 12 Oct 2019 02:19:14 +0200 Subject: fixed " misplace meant. --- bot/seasons/halloween/hacktober-issue-finder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/seasons/halloween/hacktober-issue-finder.py b/bot/seasons/halloween/hacktober-issue-finder.py index 5978eb95..8b8ea41d 100644 --- a/bot/seasons/halloween/hacktober-issue-finder.py +++ b/bot/seasons/halloween/hacktober-issue-finder.py @@ -29,7 +29,7 @@ class HacktoberIssues(commands.Cog): Get a random python hacktober issue from Github. If the command is run with beginner (`!hacktoberissues beginner`): - It will also narrow it down to the "first good issue label". + It will also narrow it down to the "first good issue" label. """ with ctx.typing(): issues = await self.get_issues(ctx, option) -- cgit v1.2.3 From fd1a2a68139f83a2313e18ec42cba1b4f9220e7c Mon Sep 17 00:00:00 2001 From: vivax3794 <51753506+vivax3794@users.noreply.github.com> Date: Sat, 12 Oct 2019 02:22:45 +0200 Subject: had the wrong prefix in docstring xD --- bot/seasons/halloween/hacktober-issue-finder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/seasons/halloween/hacktober-issue-finder.py b/bot/seasons/halloween/hacktober-issue-finder.py index 8b8ea41d..2f1d6ac7 100644 --- a/bot/seasons/halloween/hacktober-issue-finder.py +++ b/bot/seasons/halloween/hacktober-issue-finder.py @@ -28,7 +28,7 @@ class HacktoberIssues(commands.Cog): """ Get a random python hacktober issue from Github. - If the command is run with beginner (`!hacktoberissues beginner`): + If the command is run with beginner (`.hacktoberissues beginner`): It will also narrow it down to the "first good issue" label. """ with ctx.typing(): -- cgit v1.2.3 From 3afb3ce056d225464333b8f633ec3dac40024da8 Mon Sep 17 00:00:00 2001 From: Numerlor Date: Sat, 12 Oct 2019 22:24:00 +0200 Subject: allow all AoC commands in whitelisted channels --- bot/seasons/christmas/adventofcode.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'bot') diff --git a/bot/seasons/christmas/adventofcode.py b/bot/seasons/christmas/adventofcode.py index a88e5ac3..007e4783 100644 --- a/bot/seasons/christmas/adventofcode.py +++ b/bot/seasons/christmas/adventofcode.py @@ -138,6 +138,7 @@ class AdventOfCode(commands.Cog): aliases=("sub", "notifications", "notify", "notifs"), brief="Notifications for new days" ) + @override_in_channel(AOC_WHITELIST) async def aoc_subscribe(self, ctx: commands.Context) -> None: """Assign the role for notifications about new days being ready.""" role = ctx.guild.get_role(AocConfig.role_id) @@ -152,6 +153,7 @@ class AdventOfCode(commands.Cog): f"If you don't want them any more, run `{unsubscribe_command}` instead.") @adventofcode_group.command(name="unsubscribe", aliases=("unsub",), brief="Notifications for new days") + @override_in_channel(AOC_WHITELIST) async def aoc_unsubscribe(self, ctx: commands.Context) -> None: """Remove the role for notifications about new days being ready.""" role = ctx.guild.get_role(AocConfig.role_id) @@ -163,6 +165,7 @@ class AdventOfCode(commands.Cog): await ctx.send("Hey, you don't even get any notifications about new Advent of Code tasks currently anyway.") @adventofcode_group.command(name="countdown", aliases=("count", "c"), brief="Return time left until next day") + @override_in_channel(AOC_WHITELIST) async def aoc_countdown(self, ctx: commands.Context) -> None: """Return time left until next day.""" if not is_in_advent(): @@ -180,11 +183,13 @@ class AdventOfCode(commands.Cog): await ctx.send(f"There are {hours} hours and {minutes} minutes left until day {tomorrow.day}.") @adventofcode_group.command(name="about", aliases=("ab", "info"), brief="Learn about Advent of Code") + @override_in_channel(AOC_WHITELIST) async def about_aoc(self, ctx: commands.Context) -> None: """Respond with an explanation of all things Advent of Code.""" await ctx.send("", embed=self.cached_about_aoc) @adventofcode_group.command(name="join", aliases=("j",), brief="Learn how to join PyDis' private AoC leaderboard") + @override_in_channel(AOC_WHITELIST) async def join_leaderboard(self, ctx: commands.Context) -> None: """DM the user the information for joining the PyDis AoC private leaderboard.""" author = ctx.message.author @@ -205,6 +210,7 @@ class AdventOfCode(commands.Cog): aliases=("board", "lb"), brief="Get a snapshot of the PyDis private AoC leaderboard", ) + @override_in_channel(AOC_WHITELIST) async def aoc_leaderboard(self, ctx: commands.Context, number_of_people_to_display: int = 10) -> None: """ Pull the top number_of_people_to_display members from the PyDis leaderboard and post an embed. @@ -246,6 +252,7 @@ class AdventOfCode(commands.Cog): aliases=("dailystats", "ds"), brief="Get daily statistics for the PyDis private leaderboard" ) + @override_in_channel(AOC_WHITELIST) async def private_leaderboard_daily_stats(self, ctx: commands.Context) -> None: """ Respond with a table of the daily completion statistics for the PyDis private leaderboard. @@ -289,6 +296,7 @@ class AdventOfCode(commands.Cog): aliases=("globalboard", "gb"), brief="Get a snapshot of the global AoC leaderboard", ) + @override_in_channel(AOC_WHITELIST) async def global_leaderboard(self, ctx: commands.Context, number_of_people_to_display: int = 10) -> None: """ Pull the top number_of_people_to_display members from the global AoC leaderboard and post an embed. -- cgit v1.2.3