Skip to content

Commit

Permalink
chore: bump version 0.5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
JayDwee committed Apr 19, 2022
1 parent f547eaf commit 29b8d25
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ administrators

## [Unreleased]

## [0.5.6] - 19-04-2022
### TwitchAlert
- Fix issue where duplicate team alerts cannot be removed
### Base
- Command Checks now are presented well to the client

## [0.5.5] - 19-04-2022
### TwitchAlert
- Fix issue where team twitch alerts would not show
- Add logging and error handling to team loop


## [0.5.4] - 12-04-2022
### Base
- Add scheduled activities for bot owners
Expand Down Expand Up @@ -274,6 +279,7 @@ manually if a timer is deleted.
- `removeProtectedRoleColour <role_str>` Removes a role, via ID, mention or name, from the list of protected roles.

[Unreleased]: https://github.com/KoalaBotUK/KoalaBot/compare/v0.1.0...HEAD
[0.5.6]: https://github.com/KoalaBotUK/KoalaBot/compare/v0.5.5...v0.5.6
[0.5.5]: https://github.com/KoalaBotUK/KoalaBot/compare/v0.5.4...v0.5.5
[0.5.4]: https://github.com/KoalaBotUK/KoalaBot/compare/v0.5.3...v0.5.4
[0.5.3]: https://github.com/KoalaBotUK/KoalaBot/compare/v0.5.2...v0.5.3
Expand Down
6 changes: 3 additions & 3 deletions koala/cogs/twitch_alert/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ async def remove_user_from_ta(self, channel_id, twitch_username):
with session_manager() as session:
message = session.execute(select(UserInTwitchAlert)
.filter_by(twitch_username=twitch_username, channel_id=channel_id)
).scalars().one_or_none()
).scalars().first()
if message is not None:
await self.delete_message(message.message_id, channel_id)
session.delete(message)
Expand Down Expand Up @@ -233,7 +233,7 @@ async def remove_team_from_ta(self, channel_id, team_name):
with session_manager() as session:
team = session.execute(select(TeamInTwitchAlert)
.filter_by(twitch_team_name=team_name, channel_id=channel_id)
).scalars().one_or_none()
).scalars().first()
if not team:
raise AttributeError("Team name not found")

Expand Down Expand Up @@ -298,7 +298,7 @@ async def delete_all_offline_team_streams(self, usernames):
)
).scalars().all()

if results is None:
if not results:
return
logger.debug("Deleting offline streams: %s" % results)
for result in results:
Expand Down
14 changes: 9 additions & 5 deletions koalabot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"Bill Cao", "Aqeel Little", "Charlie Bowe", "Ponmile Femi-Sunmaila",
"see full list of developers at: https://koalabot.uk/"]
__license__ = "MIT License"
__version__ = "0.5.5"
__version__ = "0.5.6"
__maintainer__ = "Jack Draper, Kieran Allinson, Viraj Shah, Stefan Cooper, Otto Hooper"
__email__ = "koalabotuk@gmail.com"
__status__ = "Development" # "Prototype", "Development", or "Production"
Expand Down Expand Up @@ -153,10 +153,16 @@ def check_guild_has_ext(ctx, extension_id):
raise PermissionError(PERMISSION_ERROR_TEXT)
return True


@bot.event
async def on_command_error(ctx, error: Exception):
if isinstance(error, commands.MissingRequiredArgument):
if error.__class__ in [commands.MissingRequiredArgument,
commands.CommandNotFound]:
await ctx.send(embed=error_embed(description=error))
if error.__class__ in [commands.CheckFailure]:
await ctx.send(embed=error_embed(error_type=str(type(error).__name__),
description=str(error)+"\nPlease ensure you have administrator permissions, "
"and have enabled this extension."))
elif isinstance(error, commands.CommandOnCooldown):
await ctx.send(embed=error_embed(description=f"{ctx.author.mention}, this command is still on cooldown for "
f"{str(error.retry_after)}s."))
Expand All @@ -165,10 +171,8 @@ async def on_command_error(ctx, error: Exception):
elif isinstance(error, commands.CommandInvokeError):
# logger.warning("CommandInvokeError(%s), guild_id: %s, message: %s", error.original, ctx.guild.id, ctx.message)
await ctx.send(embed=error_embed(description=error.original))
elif isinstance(error, commands.CommandNotFound):
await ctx.send(embed=error_embed(description=error))
else:
logger.error(f"Unexpected Error in guild {ctx.guild.name}: {error}")
logger.error(f"Unexpected Error in guild %s : %s", ctx.guild.name, error, exc_info=error)
await ctx.send(embed=error_embed(
description=f"An unexpected error occurred, please contact an administrator Timestamp: {time.time()}")) # FIXME: better timestamp
raise error
Expand Down
12 changes: 12 additions & 0 deletions tests/cogs/twitch_alert/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,18 @@ async def test_remove_team_from_ta(twitch_alert_db_manager_tables):
assert session.execute(sql_select_team).one_or_none() is None


@pytest.mark.asyncio()
async def test_remove_team_from_ta_duplicate(twitch_alert_db_manager_tables):
test_add_team_to_ta_custom_message(twitch_alert_db_manager_tables, channel_id=590, guild_id=591)
test_add_team_to_ta_custom_message(twitch_alert_db_manager_tables, channel_id=590, guild_id=591)
await twitch_alert_db_manager_tables.remove_team_from_ta(590, "faze")

sql_select_team = select(TeamInTwitchAlert.custom_message)\
.where(and_(TeamInTwitchAlert.channel_id == 590, TeamInTwitchAlert.twitch_team_name == 'faze'))
with session_manager() as session:
assert session.execute(sql_select_team).one_or_none() is not None


@pytest.mark.asyncio()
async def test_remove_team_from_ta_invalid(twitch_alert_db_manager_tables):
with pytest.raises(AttributeError,
Expand Down

0 comments on commit 29b8d25

Please sign in to comment.