mirror of
https://github.com/Jetsparrow/karmabot.git
synced 2026-01-21 00:56:09 +03:00
Try to only stop the bot once
This was causing errors on CTRL+C.
This commit is contained in:
parent
09c07e6296
commit
3544f521f9
@ -27,6 +27,7 @@ namespace JetKarmaBot
|
|||||||
RequestChain Chain;
|
RequestChain Chain;
|
||||||
Task timeoutWaitTask;
|
Task timeoutWaitTask;
|
||||||
CancellationTokenSource timeoutWaitTaskToken;
|
CancellationTokenSource timeoutWaitTaskToken;
|
||||||
|
private bool stopped = false;
|
||||||
|
|
||||||
public async Task Init()
|
public async Task Init()
|
||||||
{
|
{
|
||||||
@ -52,6 +53,7 @@ namespace JetKarmaBot
|
|||||||
|
|
||||||
public async Task Stop()
|
public async Task Stop()
|
||||||
{
|
{
|
||||||
|
if (stopped) return;
|
||||||
Client.StopReceiving();
|
Client.StopReceiving();
|
||||||
timeoutWaitTaskToken.Cancel();
|
timeoutWaitTaskToken.Cancel();
|
||||||
try
|
try
|
||||||
@ -61,6 +63,7 @@ namespace JetKarmaBot
|
|||||||
catch (OperationCanceledException) { }
|
catch (OperationCanceledException) { }
|
||||||
await Timeout.Save();
|
await Timeout.Save();
|
||||||
Dispose();
|
Dispose();
|
||||||
|
stopped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region service
|
#region service
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user