aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar wookie184 <[email protected]>2022-08-02 18:01:27 +0100
committerGravatar GitHub <[email protected]>2022-08-02 18:01:27 +0100
commit57e5f9764dcc135166961747abcb883d6a06df7f (patch)
tree8f72d48beefe43c2566a19f6bb472b49537e0912
parentUpdated docstring for _ext_emoji_replace (diff)
parentGitHub issues embeds: preserve order and display repo name and issue number (... (diff)
Merge branch 'main' into uwu-emoji-fix
-rw-r--r--bot/exts/fun/battleship.py4
-rw-r--r--bot/exts/fun/connect_four.py5
-rw-r--r--bot/exts/fun/fun.py10
-rw-r--r--bot/exts/utilities/githubinfo.py6
-rw-r--r--poetry.lock17
-rw-r--r--pyproject.toml1
6 files changed, 34 insertions, 9 deletions
diff --git a/bot/exts/fun/battleship.py b/bot/exts/fun/battleship.py
index beff196f..77e38427 100644
--- a/bot/exts/fun/battleship.py
+++ b/bot/exts/fun/battleship.py
@@ -110,8 +110,8 @@ class Game:
self.gameover: bool = False
- self.turn: Optional[discord.Member] = None
- self.next: Optional[discord.Member] = None
+ self.turn: Optional[Player] = None
+ self.next: Optional[Player] = None
self.match: Optional[re.Match] = None
self.surrender: bool = False
diff --git a/bot/exts/fun/connect_four.py b/bot/exts/fun/connect_four.py
index f53695d5..1b88d065 100644
--- a/bot/exts/fun/connect_four.py
+++ b/bot/exts/fun/connect_four.py
@@ -5,6 +5,7 @@ from typing import Optional, Union
import discord
import emojis
+from discord import ClientUser, Member
from discord.ext import commands
from bot.bot import Bot
@@ -71,7 +72,9 @@ class Game:
await self.message.add_reaction(CROSS_EMOJI)
await self.message.edit(content=None, embed=embed)
- async def game_over(self, action: str, player1: discord.user, player2: discord.user) -> None:
+ async def game_over(
+ self, action: str, player1: Union[ClientUser, Member], player2: Union[ClientUser, Member]
+ ) -> None:
"""Announces to public chat."""
if action == "win":
await self.channel.send(f"Game Over! {player1.mention} won against {player2.mention}")
diff --git a/bot/exts/fun/fun.py b/bot/exts/fun/fun.py
index a27ad85f..9ec9b9ee 100644
--- a/bot/exts/fun/fun.py
+++ b/bot/exts/fun/fun.py
@@ -3,8 +3,9 @@ import logging
import random
from collections.abc import Iterable
from pathlib import Path
-from typing import Callable, Optional, Union
+from typing import Callable, Literal, Optional, Union
+import pyjokes
from discord import Embed, Message
from discord.ext import commands
from discord.ext.commands import BadArgument, Cog, Context, MessageConverter, clean_content
@@ -41,7 +42,6 @@ class Fun(Cog):
def __init__(self, bot: Bot):
self.bot = bot
-
self._caesar_cipher_embed = json.loads(Path("bot/resources/fun/caesar_info.json").read_text("UTF-8"))
@staticmethod
@@ -212,6 +212,12 @@ class Fun(Cog):
return Embed.from_dict(embed_dict)
+ @commands.command()
+ async def joke(self, ctx: commands.Context, category: Literal["neutral", "chuck", "all"] = "all") -> None:
+ """Retrieves a joke of the specified `category` from the pyjokes api."""
+ joke = pyjokes.get_joke(category=category)
+ await ctx.send(joke)
+
def setup(bot: Bot) -> None:
"""Load the Fun cog."""
diff --git a/bot/exts/utilities/githubinfo.py b/bot/exts/utilities/githubinfo.py
index 963f54e5..046f67df 100644
--- a/bot/exts/utilities/githubinfo.py
+++ b/bot/exts/utilities/githubinfo.py
@@ -149,7 +149,9 @@ class GithubInfo(commands.Cog):
for result in results:
if isinstance(result, IssueState):
- description_list.append(f"{result.emoji} [{result.title}]({result.url})")
+ description_list.append(
+ f"{result.emoji} [[{result.repository}] #{result.number} {result.title}]({result.url})"
+ )
elif isinstance(result, FetchError):
description_list.append(f":x: [{result.return_code}] {result.message}")
@@ -192,7 +194,7 @@ class GithubInfo(commands.Cog):
log.trace(f"Found {issues = }")
# Remove duplicates
- issues = set(issues)
+ issues = list(dict.fromkeys(issues))
if len(issues) > MAXIMUM_ISSUES:
embed = discord.Embed(
diff --git a/poetry.lock b/poetry.lock
index c3bea820..08d0de7e 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -236,8 +236,8 @@ six = ">=1.12"
sortedcontainers = "*"
[package.extras]
-aioredis = ["aioredis"]
lua = ["lupa"]
+aioredis = ["aioredis"]
[[package]]
name = "filelock"
@@ -605,6 +605,18 @@ optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
[[package]]
+name = "pyjokes"
+version = "0.6.0"
+description = "One line jokes for programmers (jokes as a service)"
+category = "main"
+optional = false
+python-versions = "*"
+
+[package.extras]
+test = ["tox", "coverage", "pytest"]
+doc = ["mkdocs"]
+
+[[package]]
name = "pyparsing"
version = "3.0.6"
description = "Python parsing module"
@@ -835,7 +847,7 @@ multidict = ">=4.0"
[metadata]
lock-version = "1.1"
python-versions = "^3.9"
-content-hash = "7b443f1df31c4119783474342f05852ec35bcb4b21c07160ea6aa1ed9164fa34"
+content-hash = "86ef4c274176e805702da51d96711698a09ca6e04c145b607258c34d04638b9e"
[metadata.files]
aiodns = []
@@ -891,6 +903,7 @@ pycodestyle = []
pycparser = []
pydocstyle = []
pyflakes = []
+pyjokes = []
pyparsing = []
pyreadline3 = []
python-dateutil = []
diff --git a/pyproject.toml b/pyproject.toml
index 076f9676..729d67fa 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -22,6 +22,7 @@ coloredlogs = "~=15.0"
colorama = { version = "~=0.4.3", markers = "sys_platform == 'win32'" }
lxml = "~=4.9"
emoji = "^1.6.1"
+pyjokes = "0.6.0"
[tool.poetry.dev-dependencies]
flake8 = "~=3.8"