if connect crashes, probably wrong username/pass, music mayybeee slightly better
This commit is contained in:
parent
5fa81c1810
commit
127eb37cfe
@ -200,25 +200,22 @@ namespace NadekoBot.Classes.Music {
|
|||||||
Console.WriteLine("Buffering canceled, stream is completed.");
|
Console.WriteLine("Buffering canceled, stream is completed.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (buffer.readPos > 5.MiB() && buffer.writePos > 5.MiB()) {
|
||||||
if (buffer.readPos > 5.MiB() && buffer.writePos > 5.MiB()) { // if buffer is over 5 MiB, create new one
|
var skip = 5.MB();
|
||||||
var skip = 5.MB(); //remove only 5 MB, just in case
|
|
||||||
var newBuffer = new DualStream();
|
|
||||||
|
|
||||||
lock (_bufferLock) {
|
lock (_bufferLock) {
|
||||||
byte[] data = buffer.ToArray().Skip(skip).ToArray();
|
byte[] data = new byte[buffer.Length - skip];
|
||||||
|
Buffer.BlockCopy(buffer.GetBuffer(), skip, data, 0, (int)(buffer.Length - skip));
|
||||||
var newReadPos = buffer.readPos - skip;
|
var newReadPos = buffer.readPos - skip;
|
||||||
var newPos = buffer.Position - skip;
|
var newPos = buffer.Position - skip;
|
||||||
buffer = newBuffer;
|
buffer = new DualStream();
|
||||||
buffer.Write(data, 0, data.Length);
|
buffer.Write(data, 0, data.Length);
|
||||||
buffer.readPos = newReadPos;
|
buffer.readPos = newReadPos;
|
||||||
buffer.Position = newPos;
|
buffer.Position = newPos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var buf = new byte[4096];
|
||||||
var buf = new byte[2048];
|
|
||||||
int read = 0;
|
int read = 0;
|
||||||
read = await p.StandardOutput.BaseStream.ReadAsync(buf, 0, 2048);
|
read = await p.StandardOutput.BaseStream.ReadAsync(buf, 0, buf.Length);
|
||||||
//Console.WriteLine($"Read: {read}");
|
//Console.WriteLine($"Read: {read}");
|
||||||
if (read == 0) {
|
if (read == 0) {
|
||||||
if (attempt == 5) {
|
if (attempt == 5) {
|
||||||
|
@ -105,7 +105,16 @@ namespace NadekoBot {
|
|||||||
|
|
||||||
//run the bot
|
//run the bot
|
||||||
client.ExecuteAndWait(async () => {
|
client.ExecuteAndWait(async () => {
|
||||||
|
try {
|
||||||
await client.Connect(creds.Username, creds.Password);
|
await client.Connect(creds.Username, creds.Password);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Console.WriteLine($"Probably wrong EMAIL or PASSWORD.\n{ex.Message}");
|
||||||
|
Console.ReadKey();
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
Console.ReadKey();
|
||||||
|
return;
|
||||||
|
}
|
||||||
Console.WriteLine("-----------------");
|
Console.WriteLine("-----------------");
|
||||||
Console.WriteLine(NadekoStats.Instance.GetStats());
|
Console.WriteLine(NadekoStats.Instance.GetStats());
|
||||||
Console.WriteLine("-----------------");
|
Console.WriteLine("-----------------");
|
||||||
|
Loading…
Reference in New Issue
Block a user