public static string GetOnlineSurprise() { var danni = new HttpRequest(); danni.AddHeader("Client-ID", "f7eeegwu0xe6hpa9o6ntad48i3au1o"); //клиент айди danni.AddHeader("Authorization", "Bearer " + token); danni.UserAgent = Http.OperaUserAgent(); danni.Cookies = new CookieDictionary(); danni.KeepAlive = true; try { response1 = danni.Get("https://api.twitch.tv/helix/streams?user_login=richiking").ToString(); JObject json = JObject.Parse(response1); richi = Convert.ToString(json["data"].Count()); } catch (Exception ex) { UpdateToken(); GetOnlineSurprise(); } myConnection = new SQLiteConnection("Data Source=tte_bot.sqlite3"); string query = "SELECT live FROM online WHERE name = 'richi'"; SQLiteCommand myCommand = new SQLiteCommand(query, myConnection); myConnection.OpenAsync(); SQLiteDataReader result = myCommand.ExecuteReader(); var onlineList = new List <string>(); if (result.HasRows) { while (result.Read()) { onlineList.Add(result["live"].ToString()); //result["online"] to string array? } onlineList.ToArray(); Console.WriteLine(onlineList[0]); } myConnection.Close(); if (onlineList[0] == "0") { if (richi == "1") { Rabota.MessageSendStream MesSend = new Rabota.MessageSendStream(); Variables data = new Variables(); MesSend.Send(data, "На канале Ричи пошло развитие!" + "\n" + "https://www.twitch.tv/richiking", "photo-195044271_457239019"); } } return(richi); }
public static string GetOnlineChandler1() { var danni = new HttpRequest(); danni.AddHeader("Client-ID", "f7eeegwu0xe6hpa9o6ntad48i3au1o"); danni.UserAgent = Http.OperaUserAgent(); danni.Cookies = new CookieDictionary(); danni.KeepAlive = true; try { danni.Get("https://www.youtube.com/channel/UCPASCsJ6ISdHhQtv6vv5gYQ").ToString(); } catch (Exception ex) { elevator1 = "1"; } finally { string response1 = danni.Get("https://www.youtube.com/channel/UCPASCsJ6ISdHhQtv6vv5gYQ").ToString(); if (response1.Contains("В эфире")) { elevator1 = "1"; } else { elevator1 = "0"; } } myConnection = new SQLiteConnection("Data Source=tte_bot.sqlite3"); string query = "SELECT live FROM online WHERE name = 'elevator1'"; SQLiteCommand myCommand = new SQLiteCommand(query, myConnection); myConnection.OpenAsync(); SQLiteDataReader result = myCommand.ExecuteReader(); var onlineList = new List <string>(); if (result.HasRows) { while (result.Read()) { onlineList.Add(result["live"].ToString()); //result["online"] to string array? } onlineList.ToArray(); Console.WriteLine(onlineList[0]); } myConnection.Close(); if (onlineList[0] == "0") { if (elevator1 == "1") { Rabota.MessageSendStream MesSend = new Rabota.MessageSendStream(); Variables data = new Variables(); MesSend.Send(data, "Виталя вышел в эфир на ЮТУБЕ!" + "\n" + "https://www.youtube.com/channel/UCPASCsJ6ISdHhQtv6vv5gYQ", "photo-195044271_457239022"); } } return(elevator1); }