!m d added, some improvements?!
This commit is contained in:
		@@ -7,6 +7,10 @@ namespace NadekoBot.Classes.JSONModels {
 | 
				
			|||||||
        public bool ForwardMessages = true;
 | 
					        public bool ForwardMessages = true;
 | 
				
			||||||
        public HashSet<ulong> ServerBlacklist = new HashSet<ulong>();
 | 
					        public HashSet<ulong> ServerBlacklist = new HashSet<ulong>();
 | 
				
			||||||
        public HashSet<ulong> ChannelBlacklist = new HashSet<ulong>();
 | 
					        public HashSet<ulong> ChannelBlacklist = new HashSet<ulong>();
 | 
				
			||||||
        public HashSet<ulong> UserBlacklist = new HashSet<ulong>();
 | 
					        public HashSet<ulong> UserBlacklist = new HashSet<ulong>() {
 | 
				
			||||||
 | 
					            105309315895693312,
 | 
				
			||||||
 | 
					            119174277298782216,
 | 
				
			||||||
 | 
					            143515953525817344
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -43,6 +43,9 @@ namespace NadekoBot.Classes.Music {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        public Channel PlaybackVoiceChannel { get; private set; }
 | 
					        public Channel PlaybackVoiceChannel { get; private set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private bool Stopped { get; set; }
 | 
				
			||||||
 | 
					        private readonly object disconnectLock = new object();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public MusicPlayer(Channel startingVoiceChannel, float? defaultVolume) {
 | 
					        public MusicPlayer(Channel startingVoiceChannel, float? defaultVolume) {
 | 
				
			||||||
            if (startingVoiceChannel == null)
 | 
					            if (startingVoiceChannel == null)
 | 
				
			||||||
                throw new ArgumentNullException(nameof(startingVoiceChannel));
 | 
					                throw new ArgumentNullException(nameof(startingVoiceChannel));
 | 
				
			||||||
@@ -55,7 +58,7 @@ namespace NadekoBot.Classes.Music {
 | 
				
			|||||||
            cancelToken = SongCancelSource.Token;
 | 
					            cancelToken = SongCancelSource.Token;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Task.Run(async () => {
 | 
					            Task.Run(async () => {
 | 
				
			||||||
                while (true) {
 | 
					                while (!Stopped) {
 | 
				
			||||||
                    try {
 | 
					                    try {
 | 
				
			||||||
                        audioClient = await PlaybackVoiceChannel.JoinAudio();
 | 
					                        audioClient = await PlaybackVoiceChannel.JoinAudio();
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
@@ -96,17 +99,11 @@ namespace NadekoBot.Classes.Music {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void Stop() {
 | 
					        public void Stop(bool disconnect = false) {
 | 
				
			||||||
            lock (playlistLock) {
 | 
					            lock (playlistLock) {
 | 
				
			||||||
                playlist.Clear();
 | 
					                playlist.Clear();
 | 
				
			||||||
                try {
 | 
					                if (!SongCancelSource.IsCancellationRequested)
 | 
				
			||||||
                    if (!SongCancelSource.IsCancellationRequested)
 | 
					                    SongCancelSource.Cancel();
 | 
				
			||||||
                        SongCancelSource.Cancel();
 | 
					 | 
				
			||||||
                    audioClient.Disconnect();
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                catch {
 | 
					 | 
				
			||||||
                    Console.WriteLine("STOP");
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -174,5 +171,17 @@ namespace NadekoBot.Classes.Music {
 | 
				
			|||||||
                playlist.Clear();
 | 
					                playlist.Clear();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void Destroy() {
 | 
				
			||||||
 | 
					            lock (playlistLock) {
 | 
				
			||||||
 | 
					                playlist.Clear();
 | 
				
			||||||
 | 
					                if (!SongCancelSource.IsCancellationRequested)
 | 
				
			||||||
 | 
					                    SongCancelSource.Cancel();
 | 
				
			||||||
 | 
					                try {
 | 
				
			||||||
 | 
					                    audioClient.Disconnect();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch {}
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -166,11 +166,21 @@ namespace NadekoBot.Classes.Music {
 | 
				
			|||||||
                } finally {
 | 
					                } finally {
 | 
				
			||||||
                    Console.WriteLine($"Buffering done." + $" [{songBuffer.ContentLength}]");
 | 
					                    Console.WriteLine($"Buffering done." + $" [{songBuffer.ContentLength}]");
 | 
				
			||||||
                    if (p != null) {
 | 
					                    if (p != null) {
 | 
				
			||||||
                        p.CancelOutputRead();
 | 
					                        try {
 | 
				
			||||||
                        p.StandardOutput.Dispose();
 | 
					                            p.CancelOutputRead();
 | 
				
			||||||
                        p.CloseMainWindow();
 | 
					                        } catch { }
 | 
				
			||||||
                        p.Close();
 | 
					                        try {
 | 
				
			||||||
                        p.Dispose();
 | 
					                            p.StandardOutput.Dispose();
 | 
				
			||||||
 | 
					                        } catch { }
 | 
				
			||||||
 | 
					                        try {
 | 
				
			||||||
 | 
					                            p.CloseMainWindow();
 | 
				
			||||||
 | 
					                        } catch { }
 | 
				
			||||||
 | 
					                        try {
 | 
				
			||||||
 | 
					                            p.Close();
 | 
				
			||||||
 | 
					                        } catch { }
 | 
				
			||||||
 | 
					                        try {
 | 
				
			||||||
 | 
					                            p.Dispose();
 | 
				
			||||||
 | 
					                        } catch { }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
@@ -193,8 +203,8 @@ namespace NadekoBot.Classes.Music {
 | 
				
			|||||||
                var read = songBuffer.Read(buffer, blockSize);
 | 
					                var read = songBuffer.Read(buffer, blockSize);
 | 
				
			||||||
                if (read == 0)
 | 
					                if (read == 0)
 | 
				
			||||||
                    if (attempt++ == 20) {
 | 
					                    if (attempt++ == 20) {
 | 
				
			||||||
                        voiceClient.Wait();
 | 
					 | 
				
			||||||
                        Console.WriteLine("Nothing to read.");
 | 
					                        Console.WriteLine("Nothing to read.");
 | 
				
			||||||
 | 
					                        voiceClient.Wait();
 | 
				
			||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
                    } else
 | 
					                    } else
 | 
				
			||||||
                        await Task.Delay(50, cancelToken);
 | 
					                        await Task.Delay(50, cancelToken);
 | 
				
			||||||
@@ -208,13 +218,7 @@ namespace NadekoBot.Classes.Music {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            await bufferTask;
 | 
					            await bufferTask;
 | 
				
			||||||
            cancelToken.ThrowIfCancellationRequested();
 | 
					            cancelToken.ThrowIfCancellationRequested();
 | 
				
			||||||
            //try {
 | 
					            voiceClient.Clear();
 | 
				
			||||||
            //    voiceClient.Clear();
 | 
					 | 
				
			||||||
            //    Console.WriteLine("CLEARED");
 | 
					 | 
				
			||||||
            //}
 | 
					 | 
				
			||||||
            //catch {
 | 
					 | 
				
			||||||
            //    Console.WriteLine("CLEAR FAILED!!!");
 | 
					 | 
				
			||||||
            //}
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //stackoverflow ftw
 | 
					        //stackoverflow ftw
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,10 +41,17 @@ namespace NadekoBot.Commands {
 | 
				
			|||||||
            //cw.Start();
 | 
					            //cw.Start();
 | 
				
			||||||
            wars.Add(cw);
 | 
					            wars.Add(cw);
 | 
				
			||||||
            cw.OnUserTimeExpired += async (u) => {
 | 
					            cw.OnUserTimeExpired += async (u) => {
 | 
				
			||||||
                await e.Channel.SendMessage($"❗🔰**Claim from @{u} for a war against {cw.ShortPrint()} has expired.**");
 | 
					                try {
 | 
				
			||||||
 | 
					                    await
 | 
				
			||||||
 | 
					                        e.Channel.SendMessage($"❗🔰**Claim from @{u} for a war against {cw.ShortPrint()} has expired.**");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch {}
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            cw.OnWarEnded += async () => {
 | 
					            cw.OnWarEnded += async () => {
 | 
				
			||||||
                await e.Channel.SendMessage($"❗🔰**War against {cw.ShortPrint()} ended.**");
 | 
					                try {
 | 
				
			||||||
 | 
					                    await e.Channel.SendMessage($"❗🔰**War against {cw.ShortPrint()} ended.**");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch {}
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            await e.Channel.SendMessage($"❗🔰**CREATED CLAN WAR AGAINST {cw.ShortPrint()}**");
 | 
					            await e.Channel.SendMessage($"❗🔰**CREATED CLAN WAR AGAINST {cw.ShortPrint()}**");
 | 
				
			||||||
            //war with the index X started.
 | 
					            //war with the index X started.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -52,16 +52,24 @@ namespace NadekoBot.Modules {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                cgb.CreateCommand("s")
 | 
					                cgb.CreateCommand("s")
 | 
				
			||||||
                    .Alias("stop")
 | 
					                    .Alias("stop")
 | 
				
			||||||
                    .Description("Completely stops the music, unbinds the bot from the channel, and cleans up files.")
 | 
					                    .Description("Stops the music and clears the playlist. Stays in the channel.")
 | 
				
			||||||
                    .Do(async e => {
 | 
					                    .Do(async e => {
 | 
				
			||||||
                        MusicPlayer musicPlayer;
 | 
					                        await Task.Run(() => {
 | 
				
			||||||
                        if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer)) return;
 | 
					                            MusicPlayer musicPlayer;
 | 
				
			||||||
                        musicPlayer.Stop();
 | 
					                            if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer)) return;
 | 
				
			||||||
                        var msg = await e.Channel.SendMessage("⚠Due to music issues, NadekoBot is unable to leave voice channels at this moment.\nIf this presents inconvenience, you can use `!m mv` command to make her join your current voice channel.");
 | 
					                            musicPlayer.Stop();
 | 
				
			||||||
                        await Task.Delay(5000);
 | 
					                        });
 | 
				
			||||||
                        try {
 | 
					                    });
 | 
				
			||||||
                            await msg.Delete();
 | 
					
 | 
				
			||||||
                        } catch { }
 | 
					                cgb.CreateCommand("d")
 | 
				
			||||||
 | 
					                    .Alias("destroy")
 | 
				
			||||||
 | 
					                    .Description("Completely stops the music and unbinds the bot from the channel. (may cause weird behaviour)")
 | 
				
			||||||
 | 
					                    .Do(async e => {
 | 
				
			||||||
 | 
					                        await Task.Run(() => {
 | 
				
			||||||
 | 
					                            MusicPlayer musicPlayer;
 | 
				
			||||||
 | 
					                            if (!MusicPlayers.TryRemove(e.Server, out musicPlayer)) return;
 | 
				
			||||||
 | 
					                            musicPlayer.Destroy();
 | 
				
			||||||
 | 
					                        });
 | 
				
			||||||
                    });
 | 
					                    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                cgb.CreateCommand("p")
 | 
					                cgb.CreateCommand("p")
 | 
				
			||||||
@@ -324,8 +332,7 @@ namespace NadekoBot.Modules {
 | 
				
			|||||||
                    OnCompleted = async song => {
 | 
					                    OnCompleted = async song => {
 | 
				
			||||||
                        try {
 | 
					                        try {
 | 
				
			||||||
                            await textCh.SendMessage($"🎵`Finished`{song.PrettyName}");
 | 
					                            await textCh.SendMessage($"🎵`Finished`{song.PrettyName}");
 | 
				
			||||||
                        }
 | 
					                        } catch { }
 | 
				
			||||||
                        catch {}
 | 
					 | 
				
			||||||
                    },
 | 
					                    },
 | 
				
			||||||
                    OnStarted = async (song) => {
 | 
					                    OnStarted = async (song) => {
 | 
				
			||||||
                        try {
 | 
					                        try {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -171,15 +171,8 @@ namespace NadekoBot {
 | 
				
			|||||||
            try {
 | 
					            try {
 | 
				
			||||||
                if (e.Server != null || e.User.Id == Client.CurrentUser.Id) return;
 | 
					                if (e.Server != null || e.User.Id == Client.CurrentUser.Id) return;
 | 
				
			||||||
                if (PollCommand.ActivePolls.SelectMany(kvp => kvp.Key.Users.Select(u => u.Id)).Contains(e.User.Id)) return;
 | 
					                if (PollCommand.ActivePolls.SelectMany(kvp => kvp.Key.Users.Select(u => u.Id)).Contains(e.User.Id)) return;
 | 
				
			||||||
                // just ban this trash AutoModerator
 | 
					 | 
				
			||||||
                // and cancer christmass spirit
 | 
					 | 
				
			||||||
                // and crappy shotaslave
 | 
					 | 
				
			||||||
                if (IsBlackListed(e))
 | 
					                if (IsBlackListed(e))
 | 
				
			||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
                if (e.User.Id == 105309315895693312 ||
 | 
					 | 
				
			||||||
                    e.User.Id == 119174277298782216 ||
 | 
					 | 
				
			||||||
                    e.User.Id == 143515953525817344)
 | 
					 | 
				
			||||||
                    return; // FU
 | 
					 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
                if (!NadekoBot.Config.DontJoinServers) {
 | 
					                if (!NadekoBot.Config.DontJoinServers) {
 | 
				
			||||||
                    try {
 | 
					                    try {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,5 +3,9 @@
 | 
				
			|||||||
  "ForwardMessages": true,
 | 
					  "ForwardMessages": true,
 | 
				
			||||||
  "ServerBlacklist": [],
 | 
					  "ServerBlacklist": [],
 | 
				
			||||||
  "ChannelBlacklist": [],
 | 
					  "ChannelBlacklist": [],
 | 
				
			||||||
  "UserBlacklist": []
 | 
					  "UserBlacklist": [
 | 
				
			||||||
 | 
					    105309315895693312,
 | 
				
			||||||
 | 
					    119174277298782216,
 | 
				
			||||||
 | 
					    143515953525817344
 | 
				
			||||||
 | 
					  ]
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user