Skip to content

Commit

Permalink
Merge pull request #8 from wh0o7/7-music-status-saving-bug
Browse files Browse the repository at this point in the history
fix: saving music status as bio bug and code style
  • Loading branch information
wh0o7 authored Aug 13, 2024
2 parents 1045bc0 + 0c05791 commit 686a63d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 2 additions & 4 deletions TelegramMusicStatus/Services/LastFmService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ public interface ILastFmService : IMusicService

public class LastFmService : ILastFmService
{
private IConfig<MainConfig> _config;
private readonly LastfmClient _client;
private readonly string _username;

public LastFmService(IConfig<MainConfig> config)
{
this._config = config;
this._client = new LastfmClient(this._config.Entries.LastFmApi.ApiKey);
this._username = this._config.Entries.LastFmApi.Username;
this._client = new LastfmClient(config.Entries.LastFmApi.ApiKey);
this._username = config.Entries.LastFmApi.Username;
}

public async Task<(bool IsPlaying, string? Bio)> GetCurrentlyPlayingStatus()
Expand Down
3 changes: 2 additions & 1 deletion TelegramMusicStatus/Services/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Text.RegularExpressions;
using ImprovedConsole;
using Swan;

namespace TelegramMusicStatus.Services;

Expand All @@ -15,7 +16,7 @@ public static string FormatTrackInfo(string input)
public static bool IsValidTrackInfoFormat(string input)
{
const string pattern = "^Now Playing: .+ - .+$";
return Regex.IsMatch(input, pattern);
return Regex.IsMatch(input.Replace(".", ""), pattern);
}

public static string FormatStatus(string input) => input.Length <= _maxCharacters ? input :$"{input[..(_maxCharacters - 3)]}...".TrimEnd();
Expand Down

0 comments on commit 686a63d

Please sign in to comment.