コード例 #1
0
        public IActionResult RestartBot()
        {
            var sheetBot = new SpreadSheetBot(PermanentValues.GoogleSheetsCredentialsPath,
                                              PermanentValues.Config.SpreadsheetId);
            var vkBot = TryCreateVkBot(PermanentValues.Config, sheetBot);

            if (vkBot != null)
            {
                Logger.Clear();
                RunBot(vkBot);
            }
            return(RedirectToAction("Index", "Home"));
        }
コード例 #2
0
 private VkApiBot TryCreateVkBot(ConfigModel config, SpreadSheetBot sheetBot)
 {
     try
     {
         var adminIds = new List <long>();
         foreach (var id in config.AdminIds.Split(','))
         {
             adminIds.Add(long.Parse(id));
         }
         var bot = new VkApiBot(
             config.Token,
             ulong.Parse(config.GroupId),
             adminIds, sheetBot);
         bot.AuthCheck();
         return(bot);
     }
     catch (Exception ex)
     {
         TempDataMessage("message", "primary", $"Ошибка авторизации: {ex.Message}");
         return(null);
     }
 }