Skip to content

Commit

Permalink
[PATCH] Fixes to make CI less of a hellscape
Browse files Browse the repository at this point in the history
  • Loading branch information
Diapolo10 committed Dec 22, 2023
1 parent 660bb9a commit 550a8a3
Show file tree
Hide file tree
Showing 7 changed files with 1,112 additions and 358 deletions.
42 changes: 30 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,50 @@ Lorem Ipsum dolor sit amet.
<!--
_______________________________________________________________________________
## [0.3.0] - 2023-05-11
`README.md` is now more up-to-date, the new Wilderness bosses are now in the
list of bosses, and the project's linters were replaced with Ruff. The codebase
has also been cleaned up somewhat as a result in order to pass the new linter
guidelines.
## [0.3.1] - 2023-12-22
### Added
- Added support for listing the new Wilderness bosses, fixing incorrect scores
for existing bosses.
Fixed username insertion to URLs to get unit tests working again, fixed logging
caused by moving everything to `src`, updated dependencies, and updated
minigame/boss lists.
### Changed
- Updated `README.md` with clearer instructions for using the bot
- Updated the minigame and boss lists to show correct output
- Updated dependencies
- Updated localisation files
### Fixed
- Boss hiscores are no longer broken
- The bot no longer breaks when used with usernames containing spaces (mostly
affected unit tests)
- Logging configuration is found again, previously moving the source code broke
this as the filepath wasn't updated, leading to errors
-->

_______________________________________________________________________________

## [0.3.1] - 2023-12-22

Fixed username insertion to URLs to get unit tests working again, fixed logging
caused by moving everything to `src`, updated dependencies, and updated
minigame/boss lists.

### Changed

- Updated the minigame and boss lists to show correct output
- Updated dependencies
- Updated localisation files

### Fixed

- The bot no longer breaks when used with usernames containing spaces (mostly
affected unit tests)
- Logging configuration is found again, previously moving the source code broke
this as the filepath wasn't updated, leading to errors

_______________________________________________________________________________

## [0.3.0] - 2023-05-11

`README.md` is now more up-to-date, the new Wilderness bosses are now in the
Expand Down
1,211 changes: 950 additions & 261 deletions poetry.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ omit = [

[tool.poetry]
name = "growlery"
version = "0.3.0"
version = "0.3.1"
description = "An OSRS Discord bot for Clan Quest."

packages = [
Expand Down Expand Up @@ -66,30 +66,30 @@ classifiers = [

[tool.poetry.dependencies]
python = "^3.10"
aiohttp = "^3.8.6"
aiohttp = "^3.9.1"
"discord.py" = "^2.3.2"
python-dotenv = "^1.0.0"
reactionmenu = "^3.1.3"


[tool.poetry.group.dev.dependencies]
mypy = "^1.6.1"
mypy = "^1.8.0"


[tool.poetry.group.linters]
optional = true


[tool.poetry.group.linters.dependencies]
ruff = "^0.1.3"
ruff = "^0.1.9"


[tool.poetry.group.tests]
optional = true


[tool.poetry.group.tests.dependencies]
coverage = {version = "^7.3.2", extras = ["toml",]}
coverage = {version = "^7.3.4", extras = ["toml",]}
dpytest = "^0.7.0"
pytest = "^7.2.2"
pytest-asyncio = ">=0.21.1,<0.24.0"
Expand Down
13 changes: 8 additions & 5 deletions src/growlery/cogs/hiscores.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
from http import HTTPStatus
from typing import TYPE_CHECKING
from urllib.parse import quote

from discord.ext import commands
from reactionmenu import ViewButton, ViewMenu # type: ignore[import]
Expand Down Expand Up @@ -130,7 +131,8 @@ async def reply_with_hiscores(cls: type[Hiscores],
return await ctx.send(result)

hiscores = await cls._fetch_hiscores(username, account_type)
if hiscores:

if hiscores and not hiscores[0][0].startswith('<!DOCTYPE'):
result = SkillsTable(username, account_type, account_type_name, hiscores).render_table() # type: ignore[assignment]

return await ctx.send(result)
Expand All @@ -149,7 +151,8 @@ async def reply_with_minigames(cls: type[Hiscores],
return await ctx.send(result)

hiscores = await cls._fetch_hiscores(username, account_type)
if hiscores:

if hiscores and not hiscores[0][0].startswith('<!DOCTYPE'):
result = MinigamesTable(username, account_type, account_type_name, hiscores).render_table() # type: ignore[assignment]

return await ctx.send(result)
Expand All @@ -168,7 +171,7 @@ async def reply_with_bosses(cls: type[Hiscores],
return await ctx.send(result)

hiscores = await cls._fetch_hiscores(username, account_type)
if hiscores:
if hiscores and not hiscores[0][0].startswith('<!DOCTYPE'):
menu = ViewMenu(ctx, menu_type=ViewMenu.TypeText)
result = BossesTable(username, account_type, account_type_name, hiscores).render_table() # type: ignore[assignment]
if isinstance(result, str):
Expand All @@ -189,8 +192,8 @@ async def _fetch_hiscores(username: str, account_type: AccountType) -> list[list
"""Handle fetching the hiscores for RuneScape accounts."""
url: str = RUNESCAPE_HISCORES_LITE_URL.format(
hiscores='_oldschool',
gamemode=account_type,
player_name=username,
gamemode=account_type.value,
player_name=quote(username),
)
status_messages = {
HTTPStatus.NOT_FOUND: "Could not find player hiscores",
Expand Down
9 changes: 8 additions & 1 deletion src/growlery/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dotenv import load_dotenv

PROJECT_DIR = Path(__file__).parent
ROOT_DIR = PROJECT_DIR.parent
ROOT_DIR = PROJECT_DIR.parent.parent
DOCS_DIR = ROOT_DIR / 'docs'
CODE_EXAMPLES = DOCS_DIR / 'example_code'
ENV_FILE = PROJECT_DIR / '.env'
Expand Down Expand Up @@ -56,9 +56,12 @@
)

MINIGAME_NAMES = (
'Unknown Minigame',
'Unknown Minigame',
'Bounty Hunter - Hunter',
'Bounty Hunter - Rogue',
'Bounty Hunter (Legacy) - Hunter',
'Bounty Hunter (Legacy) - Rogue',
'Clue Scrolls (all)',
'Clue Scrolls (beginner)',
'Clue Scrolls (easy)',
Expand Down Expand Up @@ -92,6 +95,7 @@
'Dagannoth Rex',
'Dagannoth Supreme',
'Deranged Archaeologist',
'Duke Sucellus',
'General Graardor',
'Giant Mole',
'Grotesque Guardians',
Expand All @@ -114,13 +118,16 @@
'Tempoross',
'The Gauntlet',
'The Corrupted Gauntlet',
'The Leviathan',
'The Whisperer',
'Theatre of Blood',
'Theatre of Blood: Hard Mode',
'Thermonuclear Smoke Devil',
'Tombs of Amascut',
'Tombs of Amascut: Expert Mode',
'TzKal-Zuk',
'TzTok-Jad',
'Vardorvis',
'Venenatis',
'Vet\'ion',
'Vorkath',
Expand Down
2 changes: 1 addition & 1 deletion src/growlery/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def generate_header(self: Table) -> list[str]:
def generate_body(self: Table) -> tuple[list[str], list[str], list[str]]:
"""Generate the table body."""
# There is a current max boss limit of 51, so rows per page can be set to 17.
max_row_per_page = 17
max_row_per_page = 25 # NOTE: Refactor the whole mess and make this only apply to bosses
body = []
second_row = []
third_row = []
Expand Down
Loading

0 comments on commit 550a8a3

Please sign in to comment.