Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to filtering on cp1252 #486

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions charts/agimus/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: agimus
description: A helm chart for a discord bot that also runs a mysql db
type: application
version: v2.4.3
appVersion: v2.4.3
version: v2.4.4
appVersion: v2.4.4
2 changes: 1 addition & 1 deletion cogs/badge_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ async def showcase(self, ctx:discord.ApplicationContext, public:str, tag:str):
await ctx.defer(ephemeral=not public)

# Set up text values for paginated pages
title = f"{ctx.author.display_name.encode('ascii', errors='ignore').decode().strip()}'s Tagged Badges - {tag}"
title = f"{remove_emoji(ctx.author.display_name)}'s Tagged Badges - {tag}"
total_badges_cnt = len(all_badge_info)
tagged_badges_cnt = len(tagged_badges)
collected = f"{tagged_badges_cnt} TAGGED ON THE USS HOOD"
Expand Down
4 changes: 1 addition & 3 deletions cogs/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ async def display(self, ctx:discord.ApplicationContext, public:str):
logger.info(f"{Fore.CYAN}{member.display_name} is looking at their own {Back.WHITE}{Fore.BLACK}profile card!{Back.RESET}{Fore.RESET}")

# clean up username
user_name = f"{member.display_name}"
user_name_encode = user_name.encode("utf-8", errors="ignore")
user_name = user_name_encode.decode().strip()
user_name = remove_emoji(member.display_name)

# get rank
ranks = ["admiral", "captain", "commander", "lt. commander", "lieutenant", "ensign", "cadet"]
Expand Down
12 changes: 6 additions & 6 deletions commands/badges.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,16 @@ async def showcase(ctx:discord.ApplicationContext, public:str, filter:str, sortb

if filter is not None:
if filter == 'unlocked':
title = f"{ctx.author.display_name.encode('ascii', errors='ignore').decode().strip()}'s Badge Collection - Unlocked"
title = f"{remove_emoji(ctx.author.display_name)}'s Badge Collection - Unlocked"
user_badges = db_get_user_unlocked_badges(ctx.author.id)
elif filter == 'locked':
title = f"{ctx.author.display_name.encode('ascii', errors='ignore').decode().strip()}'s Badge Collection - Locked"
title = f"{remove_emoji(ctx.author.display_name)}'s Badge Collection - Locked"
user_badges = db_get_user_locked_badges(ctx.author.id)
elif filter == 'special':
title = f"{ctx.author.display_name.encode('ascii', errors='ignore').decode().strip()}'s Badge Collection - Special"
title = f"{remove_emoji(ctx.author.display_name)}'s Badge Collection - Special"
user_badges = db_get_user_special_badges(ctx.author.id)
else:
title = f"{ctx.author.display_name.encode('ascii', errors='ignore').decode().strip()}'s Badge Collection"
title = f"{remove_emoji(ctx.author.display_name)}'s Badge Collection"
user_badges = db_get_user_badges(ctx.author.id, sortby)

if not user_badges:
Expand Down Expand Up @@ -316,7 +316,7 @@ async def sets(ctx:discord.ApplicationContext, public:str, category:str, selecti
user_all_badge_cnt = db_get_badge_count_for_user(ctx.author.id)

# Set up text values for paginated pages
title = f"{ctx.author.display_name.encode('ascii', errors='ignore').decode().strip()}'s Badge Set: {category_title} - {selection}"
title = f"{remove_emoji(ctx.author.display_name)}'s Badge Set: {category_title} - {selection}"
collected = f"{user_set_badge_cnt} OF {len(set_badges)}"
filename_prefix = f"badge_set_{ctx.author.id}_{selection.lower().replace(' ', '-').replace('/', '-')}-page-"

Expand Down Expand Up @@ -446,7 +446,7 @@ async def completion(ctx:discord.ApplicationContext, public:str, category:str, c
# Format data for the returned embed
category_title = category.replace('_', ' ').title()
total_badges = len(all_badges)
title = f"{ctx.author.display_name.encode('ascii', errors='ignore').decode().strip()}'s Badge Completion - {category_title}"
title = f"{remove_emoji(ctx.author.display_name)}'s Badge Completion - {category_title}"
collected = f"{len(user_badges)} TOTAL ON THE USS HOOD"
filename_prefix = f"badge_set_completion_{ctx.author.id}_affiliations-page-"

Expand Down
2 changes: 1 addition & 1 deletion commands/userinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async def top_channels(ctx:discord.ApplicationContext, public:str):
@to_thread
def generate_user_stats_top_channels_image(ctx, user_member, labels, values):
user_discord_id = user_member.id
user_name = user_member.display_name.encode("ascii", errors="ignore").decode().strip()
user_name = remove_emoji(user_member.display_name)

fig_filename = f"fig-u{user_discord_id}-t{int(time.time())}.png"
fig_filepath = f"./images/viz/figs/{fig_filename}"
Expand Down
6 changes: 6 additions & 0 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,3 +427,9 @@ def print_agimus_ansi_art():
with open(f"data/ansi/{ansi_file}") as f:
agimus_ansi = f.readlines()
logger.info(''.join(agimus_ansi))

def remove_emoji(s: str) -> str:
"""
Cleans out values unprintable in our font. cp1252 because there are a handful of chars in the font not in latin_1
"""
return s.replace("€", '').encode("cp1252", errors="ignore").decode("cp1252").strip()
Loading