Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.39 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using Telegram.Bot;
  4.  
  5. namespace BUNDbot
  6. {
  7.     class Program
  8.     {
  9.         public static readonly string[] gimn = "Союз нерушимый республик свободных Сплотила навеки Великая Русь Да здравствует созданный волей народов Единый могучий Советский Союз Славься Отечество наше свободное Дружбы народов надёжный оплот Знамя Советское знамя народное Пусть от победы к победе ведёт".ToUpper().Split(" ");
  10.         static TelegramBotClient bot = new TelegramBotClient("789946714:AAGfbet4D-yGwO4u1nOF0pppKZT32UwGDZc");
  11.         static Dictionary<long, Room> rooms = new Dictionary<long, Room>();
  12.         static void Main()
  13.         {
  14.             bot.OnMessage += Bot_OnMessage;
  15.             bot.StartReceiving();
  16.             Console.ReadKey();
  17.         }
  18.  
  19.         static void Bot_OnMessage(object sender, Telegram.Bot.Args.MessageEventArgs e)
  20.         {
  21.             Console.WriteLine(rooms.Count);
  22.             Console.WriteLine(e.Message.Text);
  23.             if (rooms.ContainsKey(e.Message.Chat.Id))
  24.             {
  25.                 var result = rooms[e.Message.Chat.Id].NextMessage(e.Message.Text);
  26.                 if (result == null) return;
  27.                 else bot.SendTextMessageAsync(e.Message.Chat,result);
  28.             }
  29.             else
  30.             {
  31.                 var room = new Room();
  32.                 rooms.Add(e.Message.Chat.Id,room);
  33.                 var result = room.NextMessage(e.Message.Text);
  34.                 if (result == null) return;
  35.                 else bot.SendTextMessageAsync(e.Message.Chat, result);
  36.             }
  37.         }
  38.  
  39.        
  40.     }
  41.  
  42.     public class Room
  43.     {
  44.         private bool isBund = false;
  45.         private int stage = 0;
  46.  
  47.         private readonly string[] gimn;
  48.         public string NextMessage(string message)
  49.         {
  50.             Console.WriteLine("test");
  51.             if (!isBund)
  52.             {
  53.                 if (message != "БУНД") return null;
  54.                 else return WhileBund();
  55.             }
  56.             else
  57.             {
  58.               return WhileBund(message);
  59.             }          
  60.         }
  61.  
  62.         string WhileBund(string message = "БУНД")
  63.         {
  64.             try
  65.             {
  66.                 if (message == "БУНД")
  67.             {
  68.                 isBund = true;
  69.                 stage++;
  70.                 return "Вам нужно будет пропеть гимн по очереди со мной!\n \n \n"
  71.                        + String.Join(" ",Program.gimn) + "\n \n \nЯ начну - СОЮЗ" ;
  72.             }
  73.  
  74.             if (message == Program.gimn[stage])
  75.             {
  76.                
  77.                     stage++;
  78.                     var response = Program.gimn[stage];
  79.                     stage++;
  80.                     return response;
  81.                
  82.             }
  83.             else
  84.             {
  85.                 return "Чё пиздишь, уёбок, пой гимн со мной: " + Program.gimn[stage];
  86.             }
  87.             }
  88.  
  89.  
  90.             catch (Exception e)
  91.             {
  92.                 isBund = false;
  93.                 stage = 0;
  94.                 return "Допели, молдцом!";
  95.             }
  96.  
  97.         }
  98.  
  99.     }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement