public static void AddRandom() { if (UserId.Id == Settings.Default.AdminId) { var temp = Message?.Substring(11).Trim(); if (temp != null && temp.Length > 2) { try { ConnectToDb.db.RandomPhrases.Add(new RandomPhrase() { Phrase = temp }); ConnectToDb.db.SaveChanges(); BotSender.SendMessage(ChatId, Resources.AddToBase + temp); } catch (Exception e) { Console.WriteLine("AddRandom Exception: " + e.Message); } } else { BotSender.SendMessage(ChatId, Resources.AddToBase_error); } } else { BotSender.SendMessage(ChatId, Resources.Access_denied); } }
static void HandleMessage(object sender, MessageEventArgs messageEventArgs) { try { // Variables ChatId = messageEventArgs.Message.Chat.Id; if (messageEventArgs.Message.Text != null) { Message = messageEventArgs.Message.Text.ToLower(); } else { Message = string.Empty; } UserId = messageEventArgs.Message.From; UserName = UserId.FirstName + " " + UserId.LastName; // Welcome if (!Welcome) { BotSender.SendMessage(ChatId, Resources.Hello); Welcome = true; } // Filling collections Collections.CreatingCollecrions(); // Logic BotCommnands.DoSomething(); // Debug Console.WriteLine(ChatId); } catch (Exception e) { Console.WriteLine("HandleMessage Exception: " + e.Message); Console.WriteLine("HandleMessage Exception: " + e.Source); } }
public static void DogsStatsForToday() { if (DogsStats.Count > 0) { var temp = DogsStats.Aggregate("", (current, s) => current + s.Key + " - " + s.Value + Resources.DogOfTheDay_stats + "\n"); BotSender.SendMessage(ChatId, temp); } else { BotSender.SendMessage(ChatId, Resources.DogOfTheDay_no_found); } }
public static void FoundDog(List <string> users) { if (users.Count > 1) { var randomGysb = Random.Next(0, users.Count); BotSender.SendMessage(ChatId, Resources.DogOfTheDay + users[randomGysb]); if (!DogsStats.ContainsKey(users[randomGysb])) { DogsStats.Add(users[randomGysb], 1); } else { DogsStats[users[randomGysb]]++; } } else { BotSender.SendMessage(ChatId, Resources.DogOfTheDay_few_players); } }
public static void Agr() { var x = 0; if (Int32.TryParse(Message.Substring(5), out x)) { if (x > 2 && x < 10) { Agressor = x; BotSender.SendMessage(ChatId, Resources.Agressor_value + Agressor); } else { BotSender.SendMessage(ChatId, Resources.Agressor_correct); } } else { BotSender.SendMessage(ChatId, Resources.Agressor_correct); } }
public static void Currency() { var currency = GetCurrency(GetHtmlPage(Settings.Default.CurrencyUrl)); BotSender.SendMessage(ChatId, Resources.Currency + String.Format("{0:dd/MM/yyyy}", DateTime.Today) + " = " + currency + "грн"); }
public static void Joke() { var joke = GetJoke(GetHtmlPage(Settings.Default.JokeUrl)); BotSender.SendMessage(ChatId, joke); }
public static void RandomAggression(string idUser) { BotSender.SendMessage(ChatId, "@" + idUser + " " + AggressionList[Random.Next(0, AggressionList.Count - 1)]); }
public static void Pic() { var pic = GetPic(GetHtmlPage(Settings.Default.PicUrl)); BotSender.SendPicture(ChatId, new InputOnlineFile(pic)); }
public static void RandomAction(long chatId) { BotSender.SendMessage(chatId, RandomList[Random.Next(0, RandomList.Count - 1)]); }