8000 tiny text · RegorForgot/fmbot-regor-dev@686d766 · GitHub
[go: up one dir, main page]

Skip to content

Commit

Permalink
tiny text
Browse files Browse the repository at this point in the history
  • Loading branch information
th0mk committed Jul 11, 2024
1 parent 2a65f67 commit 686d766
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/FMBot.Bot/Builders/AlbumBuilders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ public async Task<ResponseModel> AlbumPlaysAsync(
}

var reply =
$"**{StringExtensions.Sanitize(userSettings.DisplayName)}{userSettings.UserType.UserTypeToIcon()}** has `{albumSearch.Album.UserPlaycount}` {StringExtensions.GetPlaysString(albumSearch.Album.UserPlaycount)} " +
$"**{StringExtensions.Sanitize(userSettings.DisplayName)}{userSettings.UserType.UserTypeToIcon()}** has **{albumSearch.Album.UserPlaycount}** {StringExtensions.GetPlaysString(albumSearch.Album.UserPlaycount)} " +
$"for **{StringExtensions.Sanitize(albumSearch.Album.AlbumName)}** by **{StringExtensions.Sanitize(albumSearch.Album.ArtistName)}**";

if (albumSearch.Album.UserPlaycount.HasValue && !userSettings.DifferentUser)
Expand All @@ -981,7 +981,7 @@ await this._updateService.CorrectUserAlbumPlaycount(context.ContextUser.UserId,
await this._playService.GetWeekAlbumPlaycountAsync(userSettings.UserId, albumSearch.Album.AlbumName, albumSearch.Album.ArtistName);
if (playsLastWeek != 0)
{
reply += $" (`{playsLastWeek}` last week)";
reply += $"\n-# *{playsLastWeek} {StringExtensions.GetPlaysString(playsLastWeek)} last week*";
}
}

Expand Down
18 changes: 10 additions & 8 deletions src/FMBot.Bot/Builders/ArtistBuilders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,14 +437,15 @@ public async Task<ResponseModel> ArtistOverviewAsync(ContextModel context,
}

var description = new StringBuilder();
description.Append("-# *");
if (user.UserType != UserType.User && artistSearch.Artist.UserPlaycount > 0)
{
var firstPlay = await this._playService.GetArtistFirstPlayDate(user.UserId, artistSearch.Artist.ArtistName);
if (firstPlay != null)
{
var firstListenValue = ((DateTimeOffset)firstPlay).ToUnixTimeSeconds();

description.AppendLine($"Discovered on: <t:{firstListenValue}:D>");
description.Append($"Discovered on: <t:{firstListenValue}:D>");
}
}
else
Expand All @@ -453,28 +454,29 @@ public async Task<ResponseModel> ArtistOverviewAsync(ContextModel context,
if (randomHintNumber == 1 && this._supporterService.ShowSupporterPromotionalMessage(context.ContextUser.UserType, context.DiscordGuild?.Id))
{
this._supporterService.SetGuildSupporterPromoCache(context.DiscordGuild?.Id);
description.AppendLine($"*[Supporters]({Constants.GetSupporterDiscordLink}) can see artist discovery dates.*");
description.Append($"*[Supporters]({Constants.GetSupporterDiscordLink}) can see artist discovery dates.*");
}
}

if (artistSearch.Artist.UserPlaycount > 0)
{
description.Append(
$"`{artistSearch.Artist.UserPlaycount}` {StringExtensions.GetPlaysString(artistSearch.Artist.UserPlaycount)} on this artist");
$"{artistSearch.Artist.UserPlaycount} {StringExtensions.GetPlaysString(artistSearch.Artist.UserPlaycount)} on this artist");

var playsLastWeek =
await this._playService.GetArtistPlaycountForTimePeriodAsync(userSettings.UserId, artistSearch.Artist.ArtistName);
if (playsLastWeek != 0)
{
description.Append(
$" - `{playsLastWeek}` last week");
description.Append($" — {playsLastWeek} {StringExtensions.GetPlaysString(playsLastWeek)} last week");
}
}
else
{
description.Append("No plays on this artist yet.");
description.Append("No plays on this artist yet");
}

description.Append("*");

response.Embed.WithDescription(description.ToString());

if (user.UserDiscogs != null && user.DiscogsReleases.Any())
Expand Down Expand Up @@ -1240,7 +1242,7 @@ public async Task<ResponseModel> ArtistPlaysAsync(ContextModel context,

var reply =
$"**{StringExtensions.Sanitize(userSettings.DisplayName)}{userSettings.UserType.UserTypeToIcon()}** has " +
$"`{artistSearch.Artist.UserPlaycount}` {StringExtensions.GetPlaysString(artistSearch.Artist.UserPlaycount)} for " +
$"**{artistSearch.Artist.UserPlaycount}** {StringExtensions.GetPlaysString(artistSearch.Artist.UserPlaycount)} for " +
$"**{StringExtensions.Sanitize(artistSearch.Artist.ArtistName)}**";

if (!userSettings.DifferentUser && context.ContextUser.LastUpdated != null)
Expand All @@ -1249,7 +1251,7 @@ public async Task<ResponseModel> ArtistPlaysAsync(ContextModel context,
await this._playService.GetArtistPlaycountForTimePeriodAsync(userSettings.UserId, artistSearch.Artist.ArtistName);
if (playsLastWeek != 0)
{
reply += $" (`{playsLastWeek}` last week)";
reply += $"\n-# *{playsLastWeek} {StringExtensions.GetPlaysString(playsLastWeek)} last week*";
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/FMBot.Bot/Builders/PlayBuilders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ public async Task<ResponseModel> OverviewAsync(
$"<t:{TimeZoneInfo.ConvertTimeToUtc(day.Date, timeZone).ToUnixEpochDate()}:D> - " +
$"{StringExtensions.GetListeningTimeString(day.ListeningTime)} - " +
$"{day.Playcount} {StringExtensions.GetPlaysString(day.Playcount)}",
$"{genreString}\n" +
$"-# *{genreString}*\n" +
$"{day.TopArtist}\n" +
$"{day.TopAlbum}\n" +
$"{day.TopTrack}\n"
Expand Down
4 changes: 2 additions & 2 deletions src/FMBot.Bot/Builders/TrackBuilders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ public async Task<ResponseModel> TrackPlays(
}

var reply =
$"**{StringExtensions.Sanitize(userSettings.DisplayName)}{userSettings.UserType.UserTypeToIcon()}** has `{trackSearch.Track.UserPlaycount}` {StringExtensions.GetPlaysString(trackSearch.Track.UserPlaycount)} " +
$"**{StringExtensions.Sanitize(userSettings.DisplayName)}{userSettings.UserType.UserTypeToIcon()}** has **{trackSearch.Track.UserPlaycount}** {StringExtensions.GetPlaysString(trackSearch.Track.UserPlaycount)} " +
$"for **{StringExtensions.Sanitize(trackSearch.Track.TrackName)}** by **{StringExtensions.Sanitize(trackSearch.Track.ArtistName)}**";

if (trackSearch.Track.UserPlaycount.HasValue && !userSettings.DifferentUser)
Expand All @@ -694,7 +694,7 @@ await this._updateService.CorrectUserTrackPlaycount(context.ContextUser.UserId,
await this._playService.GetWeekTrackPlaycountAsync(userSettings.UserId, trackSearch.Track.TrackName, trackSearch.Track.ArtistName);
if (playsLastWeek != 0)
{
reply += $" (`{playsLastWeek}` last week)";
reply += $"\n-# *{playsLastWeek} {StringExtensions.GetPlaysString(playsLastWeek)} last week*";
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/FMBot.Bot/Services/PlayService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ public async Task<int> GetWeekTrackPlaycountAsync(int userId, string trackName,
{
var plays = await GetWeekPlays(userId);

return plays.Count(t => t.TrackName.ToLower() == trackName.ToLower() &&
t.ArtistName.ToLower() == artistName.ToLower());
return plays.Count(t => t.TrackName.Equals(trackName, StringComparison.OrdinalIgnoreCase) &&
t.ArtistName.Equals(artistName, StringComparison.OrdinalIgnoreCase));
}

public async Task<int> GetWeekAlbumPlaycountAsync(int userId, string albumName, string artistName)
Expand Down
12 changes: 9 additions & 3 deletions src/FMBot.Bot/Services/StringService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public static string TrackToLinkedStringWithTimestamp(RecentTrack track, bool? r
var description = new StringBuilder();

description.AppendLine($"**[{StringExtensions.Sanitize(StringExtensions.TruncateLongString(track.TrackName, 200))}]({track.TrackUrl})** by **{StringExtensions.Sanitize(track.ArtistName)}**");

description.Append("-# ");

if (!track.TimePlayed.HasValue || track.NowPlaying)
{
Expand Down Expand Up @@ -82,6 +84,8 @@ public static string TrackToLinkedStringWithTimestamp(RecentTrack track, bool? r

if (!string.IsNullOrWhiteSpace(track.AlbumName))
{
description.Append("*");

if (rymEnabled == true)
{
var searchTerm = track.AlbumName.Replace(" - Single", "");
Expand All @@ -97,17 +101,19 @@ public static string TrackToLinkedStringWithTimestamp(RecentTrack track, bool? r

if (url.Length < 180)
{
description.Append($"*[{StringExtensions.Sanitize(StringExtensions.TruncateLongString(track.AlbumName, 160))}]({url})*");
description.Append($"[{StringExtensions.Sanitize(StringExtensions.TruncateLongString(track.AlbumName, 160))}]({url})");
}
else
{
description.Append($"*{StringExtensions.Sanitize(StringExtensions.TruncateLongString(track.AlbumName, 200))}*");
description.Append($"{StringExtensions.Sanitize(StringExtensions.TruncateLongString(track.AlbumName, 200))}");
}
}
else
{
description.Append($"*{StringExtensions.Sanitize(StringExtensions.TruncateLongString(track.AlbumName, 200))}*");
description.Append($"{StringExtensions.Sanitize(StringExtensions.TruncateLongString(track.AlbumName, 200))}");
}

description.Append("*");
}

description.AppendLine();
Expand Down
2 changes: 1 addition & 1 deletion src/FMBot.Bot/TextCommands/AppleMusicCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public async Task AppleMusicAsync([Remainder] string searchValue = null)
var rnd = new Random();
if (rnd.Next(0, 8) == 1 && string.IsNullOrWhiteSpace(searchValue) && !await this._userService.HintShownBefore(userSettings.UserId, "applemusic"))
{
response.Text += $"\n*Tip: Search for other songs by simply adding the searchvalue behind {prfx}applemusic.*";
response.Text += $"\n-# *Tip: Search for other songs by simply adding the searchvalue behind {prfx}applemusic.*";
response.HintShown = true;
}

Expand Down
6 changes: 3 additions & 3 deletions src/FMBot.Bot/TextCommands/SpotifyCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public async Task SpotifyAsync([Remainder] string searchValue = null)
var rnd = new Random();
if (rnd.Next(0, 2) == 1 && string.IsNullOrWhiteSpace(searchValue) && !await this._userService.HintShownBefore(userSettings.UserId, "spotify"))
{
response.Text += $"\n*Tip: Search for other songs by simply adding the searchvalue behind {prfx}spotify.*";
response.Text += $"\n-# *Tip: Search for other songs by simply adding the searchvalue behind {prfx}spotify.*";
response.HintShown = true;
}

Expand Down Expand Up @@ -220,7 +220,7 @@ public async Task SpotifyAlbumAsync([Remainder] string searchValue = null)
var rnd = new Random();
if (rnd.Next(0, 8) == 1 && string.IsNullOrWhiteSpace(searchValue) && !await this._userService.HintShownBefore(userSettings.UserId, "spotifyalbum"))
{
response.Text += $"\n*Tip: Search for other albums by simply adding the searchvalue behind `{prfx}spotifyalbum` (or `.fmspab`).*";
response.Text += $"\n-# *Tip: Search for other albums by simply adding the searchvalue behind `{prfx}spotifyalbum` (or `.fmspab`).*";
response.HintShown = true;
}

Expand Down Expand Up @@ -311,7 +311,7 @@ public async Task SpotifyArtistAsync([Remainder] string searchValue = null)
var rnd = new Random();
if (rnd.Next(0, 8) == 1 && string.IsNullOrWhiteSpace(searchValue) && !await this._userService.HintShownBefore(userSettings.UserId, "spotifyartist"))
{
response.Text += $"\n*Tip: Search for other artists by simply adding the searchvalue behind `{prfx}spotifyartist` (or `{prfx}spa`).*";
response.Text += $"\n-# *Tip: Search for other artists by simply adding the searchvalue behind `{prfx}spotifyartist` (or `{prfx}spa`).*";
response.HintShown = true;
}

Expand Down
7 changes: 4 additions & 3 deletions src/FMBot.Bot/TextCommands/YoutubeCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,21 @@ public async Task YoutubeAsync([Remainder] string searchValue = null)
{
response.Text += $"\n<https://youtube.com/watch?v={youtubeResult.VideoId}>" +
$"\n`{youtubeResult.Title}`" +
$"\n*Embed disabled because video might not be SFW.*";
$"\n" +
$"-# *Embed disabled because video might not be SFW.*";
}
}
else
{
response.Text += $"\n<https://youtube.com/watch?v={youtubeResult.VideoId}>" +
$"\n`{youtubeResult.Title}`" +
$"\n*Embed disabled because user that requested link is not allowed to embed links.*";
$"\n-# *Embed disabled because user that requested link is not allowed to embed links.*";
}

var rnd = new Random();
if (rnd.Next(0, 8) == 1 && string.IsNullOrWhiteSpace(searchValue) && !await this._userService.HintShownBefore(userSettings.UserId, "youtube"))
{
response.Text += $"\n*Tip: Search for other songs or videos by simply adding the searchvalue behind {prfx}youtube.*";
response.Text += $"\n-# *Tip: Search for other songs or videos by simply adding the searchvalue behind {prfx}youtube.*";
response.HintShown = true;
}

Expand Down

0 comments on commit 686d766

Please sign in to comment.
0