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

Bold watched films in /history #55

Merged
merged 1 commit into from
Feb 23, 2024
Merged
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
11 changes: 7 additions & 4 deletions discord_handler/discord_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,12 @@ def display_users_by_nomination(users):
return f"{position}. [No nomination] <@{discordUserID}>"


def display_watched(f: Film):
return f"- <t:{int(f.DateWatched.timestamp())}:d> {f.FilmName} - <@{f.DiscordUserID}>"
def display_watched(f: Film, user):
film = f"**{f.FilmName}**" if user in f.UsersAttended else f.FilmName
return f"- <t:{int(f.DateWatched.timestamp())}:d> {film} - <@{f.DiscordUserID}>"


def get_history(filmbot: FilmBot, nextKey=None, MessagePrefix=""):
def get_history(filmbot: FilmBot, user, nextKey=None, MessagePrefix=""):
(films, nextKey) = filmbot.get_watched_films_after(
Limit=HISTORY_LIMIT, ExclusiveStartKey=nextKey
)
Expand All @@ -128,7 +129,7 @@ def get_history(filmbot: FilmBot, nextKey=None, MessagePrefix=""):

lastFilmKey = None
for film in films:
line = display_watched(film) + "\n"
line = display_watched(film, user) + "\n"
if len(message) + len(line) > MAX_MESSAGE_SIZE:
nextKey = lastFilmKey
break
Expand Down Expand Up @@ -344,6 +345,7 @@ def print_user(u):
elif command == "history":
return get_history(
filmbot,
user_id,
MessagePrefix="Here are the films that have been watched:\n",
)
else:
Expand Down Expand Up @@ -469,6 +471,7 @@ def display_user(user):
filmbot = FilmBot(DynamoDBClient=client, GuildID=body["guild_id"])
return get_history(
filmbot,
body["member"]["user"]["id"],
nextKey=custom_id.removeprefix(MessageComponentID.MORE_HISTORY),
)
else:
Expand Down
Loading