!!smp added (max playtime)
This commit is contained in:
parent
3cf8d100de
commit
54b6af2a19
@ -34,7 +34,16 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
/// Player will prioritize different queuer name
|
/// Player will prioritize different queuer name
|
||||||
/// over the song position in the playlist
|
/// over the song position in the playlist
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool FairPlay { get; set; } = true;
|
public bool FairPlay { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Song will stop playing after this amount of time.
|
||||||
|
/// To prevent people queueing radio or looped songs
|
||||||
|
/// while other people want to listen to other songs too.
|
||||||
|
/// </summary>
|
||||||
|
public uint MaxPlaytimeSeconds { get; set; } = 0;
|
||||||
|
|
||||||
|
public TimeSpan TotalPlaytime => new TimeSpan(playlist.Sum(s => s.TotalTime.Ticks));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Users who recently got their music wish
|
/// Users who recently got their music wish
|
||||||
|
@ -49,7 +49,7 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
|
|
||||||
public string PrettyName => $"**[{SongInfo.Title.TrimTo(65)}]({songUrl})**";
|
public string PrettyName => $"**[{SongInfo.Title.TrimTo(65)}]({songUrl})**";
|
||||||
|
|
||||||
public string PrettyInfo => $"{PrettyTotalTime} | {PrettyProvider} | {QueuerName}";
|
public string PrettyInfo => $"🔉 {(int)(MusicPlayer.Volume * 100)}% | {PrettyTotalTime} | {PrettyProvider} | {QueuerName}";
|
||||||
|
|
||||||
public string PrettyFullName => $"{PrettyName}\n\t\t*{PrettyInfo}*";
|
public string PrettyFullName => $"{PrettyName}\n\t\t*{PrettyInfo}*";
|
||||||
|
|
||||||
@ -185,7 +185,8 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
int nextTime = Environment.TickCount + milliseconds;
|
int nextTime = Environment.TickCount + milliseconds;
|
||||||
|
|
||||||
byte[] buffer = new byte[frameBytes];
|
byte[] buffer = new byte[frameBytes];
|
||||||
while (!cancelToken.IsCancellationRequested)
|
while (!cancelToken.IsCancellationRequested && //song canceled for whatever reason
|
||||||
|
!(MusicPlayer.MaxPlaytimeSeconds != 0 && CurrentTime.TotalSeconds >= MusicPlayer.MaxPlaytimeSeconds)) // or exceedded max playtime
|
||||||
{
|
{
|
||||||
//Console.WriteLine($"Read: {songBuffer.ReadPosition}\nWrite: {songBuffer.WritePosition}\nContentLength:{songBuffer.ContentLength}\n---------");
|
//Console.WriteLine($"Read: {songBuffer.ReadPosition}\nWrite: {songBuffer.WritePosition}\nContentLength:{songBuffer.ContentLength}\n---------");
|
||||||
var read = await inStream.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false);
|
var read = await inStream.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false);
|
||||||
|
@ -232,14 +232,11 @@ namespace NadekoBot.Modules.Music
|
|||||||
return;
|
return;
|
||||||
try { await musicPlayer.UpdateSongDurationsAsync().ConfigureAwait(false); } catch { }
|
try { await musicPlayer.UpdateSongDurationsAsync().ConfigureAwait(false); } catch { }
|
||||||
|
|
||||||
var embed = new EmbedBuilder()
|
var embed = new EmbedBuilder().WithOkColor()
|
||||||
.WithAuthor(eab => eab.WithName("Now Playing")
|
.WithAuthor(eab => eab.WithName("Now Playing").WithMusicIcon())
|
||||||
.WithMusicIcon())
|
.WithDescription(currentSong.PrettyName)
|
||||||
.WithTitle(currentSong.SongInfo.Title)
|
.WithFooter(ef => ef.WithText(currentSong.PrettyFullTime + $" | {currentSong.PrettyProvider} | {currentSong.QueuerName}"));
|
||||||
.WithDescription(currentSong.PrettyFullTime)
|
|
||||||
.WithFooter(ef => ef.WithText($"{currentSong.PrettyProvider} | {currentSong.QueuerName}"))
|
|
||||||
.WithOkColor()
|
|
||||||
.WithThumbnail(tn => tn.Url = currentSong.Thumbnail);
|
|
||||||
await channel.EmbedAsync(embed.Build()).ConfigureAwait(false);
|
await channel.EmbedAsync(embed.Build()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -557,13 +554,29 @@ namespace NadekoBot.Modules.Music
|
|||||||
var channel = (ITextChannel)umsg.Channel;
|
var channel = (ITextChannel)umsg.Channel;
|
||||||
MusicPlayer musicPlayer;
|
MusicPlayer musicPlayer;
|
||||||
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
musicPlayer.MaxQueueSize = size;
|
musicPlayer.MaxQueueSize = size;
|
||||||
await channel.SendConfirmAsync($"🎵 Max queue set to {(size == 0 ? ("unlimited") : size + " tracks")}.");
|
await channel.SendConfirmAsync($"🎵 Max queue set to {(size == 0 ? ("unlimited") : size + " tracks")}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
|
[RequireContext(ContextType.Guild)]
|
||||||
|
public async Task SetMaxPlaytime(IUserMessage imsg, uint seconds)
|
||||||
|
{
|
||||||
|
if (seconds < 15)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var channel = (ITextChannel)imsg.Channel;
|
||||||
|
MusicPlayer musicPlayer;
|
||||||
|
if (!MusicPlayers.TryGetValue(channel.Guild.Id, out musicPlayer))
|
||||||
|
return;
|
||||||
|
musicPlayer.MaxPlaytimeSeconds = seconds;
|
||||||
|
if(seconds == 0)
|
||||||
|
await channel.SendConfirmAsync($"🎵 Max playtime has no limit now.");
|
||||||
|
else
|
||||||
|
await channel.SendConfirmAsync($"🎵 Max playtime set to {seconds} seconds.");
|
||||||
|
}
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task ReptCurSong(IUserMessage umsg)
|
public async Task ReptCurSong(IUserMessage umsg)
|
||||||
@ -845,7 +858,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
playingMessage = await textCh.EmbedAsync(new EmbedBuilder().WithOkColor()
|
playingMessage = await textCh.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||||
.WithAuthor(eab => eab.WithName("Playing Song").WithMusicIcon())
|
.WithAuthor(eab => eab.WithName("Playing Song").WithMusicIcon())
|
||||||
.WithDescription(song.PrettyName)
|
.WithDescription(song.PrettyName)
|
||||||
.WithFooter(ef => ef.WithText($"🔉 {(int)(sender.Volume * 100)}% | {song.PrettyInfo}"))
|
.WithFooter(ef => ef.WithText(song.PrettyInfo))
|
||||||
.Build())
|
.Build())
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
27
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
27
src/NadekoBot/Resources/CommandStrings.Designer.cs
generated
@ -6377,6 +6377,33 @@ namespace NadekoBot.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to setmaxplaytime smp.
|
||||||
|
/// </summary>
|
||||||
|
public static string setmaxplaytime_cmd {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("setmaxplaytime_cmd", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Sets a maximum number of seconds (>14) a song can run before being skipped automatically. Set 0 to have no limit..
|
||||||
|
/// </summary>
|
||||||
|
public static string setmaxplaytime_desc {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("setmaxplaytime_desc", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to `{0}smp 0` or `{0}smp 270`.
|
||||||
|
/// </summary>
|
||||||
|
public static string setmaxplaytime_usage {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("setmaxplaytime_usage", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to setmaxqueue smq.
|
/// Looks up a localized string similar to setmaxqueue smq.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -2826,4 +2826,13 @@
|
|||||||
<data name="define_usage" xml:space="preserve">
|
<data name="define_usage" xml:space="preserve">
|
||||||
<value>`{0}def heresy`</value>
|
<value>`{0}def heresy`</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="setmaxplaytime_cmd" xml:space="preserve">
|
||||||
|
<value>setmaxplaytime smp</value>
|
||||||
|
</data>
|
||||||
|
<data name="setmaxplaytime_desc" xml:space="preserve">
|
||||||
|
<value>Sets a maximum number of seconds (>14) a song can run before being skipped automatically. Set 0 to have no limit.</value>
|
||||||
|
</data>
|
||||||
|
<data name="setmaxplaytime_usage" xml:space="preserve">
|
||||||
|
<value>`{0}smp 0` or `{0}smp 270`</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
Loading…
Reference in New Issue
Block a user