Update github/codeql-action action to v3.25.10
[ArchiSteamFarm.git] / ArchiSteamFarm / Core / Events.cs
blobba66ceb93f597653b8bf6990b1ad109bcfc2c847
1 // ----------------------------------------------------------------------------------------------
2 // _ _ _ ____ _ _____
3 // / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
4 // / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
5 // / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
6 // /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
7 // ----------------------------------------------------------------------------------------------
8 // |
9 // Copyright 2015-2024 Ɓukasz "JustArchi" Domeradzki
10 // Contact: JustArchi@JustArchi.net
11 // |
12 // Licensed under the Apache License, Version 2.0 (the "License");
13 // you may not use this file except in compliance with the License.
14 // You may obtain a copy of the License at
15 // |
16 // http://www.apache.org/licenses/LICENSE-2.0
17 // |
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the License is distributed on an "AS IS" BASIS,
20 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 // See the License for the specific language governing permissions and
22 // limitations under the License.
24 using System.Linq;
25 using System.Threading.Tasks;
26 using ArchiSteamFarm.Localization;
27 using ArchiSteamFarm.Steam;
28 using ArchiSteamFarm.Storage;
30 namespace ArchiSteamFarm.Core;
32 internal static class Events {
33 internal static async Task OnBotShutdown() {
34 bool shutdownIfPossible = ASF.GlobalConfig?.ShutdownIfPossible ?? GlobalConfig.DefaultShutdownIfPossible;
36 if (!shutdownIfPossible || (Bot.Bots?.Values.Any(static bot => bot.KeepRunning) == true)) {
37 return;
40 ASF.ArchiLogger.LogGenericInfo(Strings.NoBotsAreRunning);
42 // We give user extra 5 seconds for eventual config changes
43 await Task.Delay(5000).ConfigureAwait(false);
45 if (Bot.Bots?.Values.Any(static bot => bot.KeepRunning) == true) {
46 return;
49 await Program.Exit().ConfigureAwait(false);