Skip to content

Commit

Permalink
Bold watched films in /history
Browse files Browse the repository at this point in the history
This is a first attempt to show what films you have seen or missed on
the `/history` command.
  • Loading branch information
elliotgoodrich committed Feb 23, 2024
1 parent 8dfbd00 commit f90a217
Showing 1 changed file with 7 additions and 4 deletions.
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

0 comments on commit f90a217

Please sign in to comment.