static void Main(string[] args) { Console.WriteLine("Telegram Bot Application!"); var storage = new InMemoryReminderStorage(); var domain = new ReminderDomain(storage); IWebProxy proxy = new HttpToSocks5Proxy("proxy.golyakov.net", 1080); string token = "874002335:AAHCWlQVHGvM6if784HJ0rHTfcUg7SbSR5s"; var sender = new TelegramReminderSender(token, proxy); var receiver = new TelegramReminderReceiver(token, proxy); receiver.MessageReceived += (s, e) => { Console.WriteLine($"Message from contact '{e.ContactId}' with text '{e.Message}'"); //add new reminderitem to the storage var parsedMessage = MessageParser.Parse(e.Message); var item = new ReminderItem(parsedMessage.Date, parsedMessage.Message, e.ContactId); storage.Add(item); }; receiver.Run(); domain.SendReminder = (ReminderItem ri) => { sender.Send(ri.ContactId, ri.Message); }; domain.Run(); Console.WriteLine("Press any key to continue"); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Telegram Bot Application!"); var storage = new InMemoryReminderStorage(); var domain = new ReminderDomain(storage); string token = "633428988:AAHLW_LaS7A47PDO2I8sbLkIIM9L0joPOSQ"; IWebProxy proxy = new HttpToSocks5Proxy( "proxy.golyakov.net", 1080); var sender = new TelegramReminderSender(token, proxy); var receiver = new TelegramReminderReceiver(token, proxy); receiver.MessageReceived += (s, e) => { Console.WriteLine($"Message received from contact ID {e.ContactId} with text '{e.Message}'"); try { var parsedMessage = MessageParser.Parse(e.Message); var item = new ReminderItem( parsedMessage.Date, parsedMessage.Message, e.ContactId); storage.Add(item); } catch (Exception ex) { Console.WriteLine($"The format of the message is wrong!\n{ex.Message}"); } }; receiver.Run(); domain.SendReminder = (ReminderItem ri) => { sender.Send(ri.ContactId, ri.Message); }; domain.Run(); Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Telegram Bot Aplication!"); var storage = new InMemoryReminderStorage(); var domain = new ReminderDomain(storage); string token = "961862676:AAGPTkcJqLhOkgX7KOTOaEUe3Y3bjvIWJ24"; IWebProxy proxy = new HttpToSocks5Proxy( "proxy.golyakov.net", 1080); var sender = new TelegramReminderSender(token, proxy); var receiver = new TelegramReminderReceiver(token, proxy); receiver.MessageReceived += (s, e) => { Console.WriteLine($"Message received from contact id '{e.ContactId}' with text '{e.Message}'"); //add new ReminderItem to the storage try { var parsedMessage = MessageParser.Parse(e.Message); var item = new ReminderItem( parsedMessage.Date, parsedMessage.Message, e.ContactId); storage.Add(item); } catch (Exception ex) { Console.WriteLine($"Полученное не соответствует формату! \n {ex.Message}"); } }; receiver.Run(); domain.SendReminder = (ReminderItem ri) => { sender.Send(ri.ContactId, ri.Message); }; domain.Run(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Telegram BotApp"); var storage = new InMemoryReminderStorage(); var domain = new ReminderDomain(storage); string token = "697789387:AAFzSKZg8GmR-_aMktYSwcz0kKiL1D7__ww"; IWebProxy proxy = new HttpToSocks5Proxy("proxy.golyakov.net", 1080); var sender = new TelegramReminderSender(token, proxy); var receiver = new TelegramReminderReceiver(token, proxy); receiver.MessageReceived += (s, e) => { Console.WriteLine($"Message received from contactId {e.ContactId} with text {e.Message}"); try { var parsedMessage = MessageParser.Parse(e.Message); var item = new ReminderItem( parsedMessage.Date, parsedMessage.Message, e.ContactId); storage.Add(item); } catch (Exception ex) { Console.WriteLine($"The Format is Wrong \n{ex.Message}"); } }; receiver.Run(); domain.SendReminder = (ReminderItem ri) => { sender.Send(ri.ContactId, ri.Message); }; domain.Run(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Telegram Bot Application!"); var storage = new InMemoryReminderStorage(); var domain = new ReminderDomain(storage); //мой токен string token = "697789387:AAFzSKZg8GmR-aMktYSwcz0kKiL1D7_ww"; IWebProxy proxy = new HttpToSocks5Proxy("proxy.golyakov.net", 1080); var sender = new TelegramReminderSender(token, proxy); var receiver = new TelegramReminderReceiver(token, proxy); receiver.MessageReceived += (s, e) => { //добавляем запись в хранилище Console.WriteLine($"Сообщение от {e.ContactId}, текст {e.Message}"); var parsedMessage = MessageParser.Parse(e.Message); var item = new ReminderItem( parsedMessage.Date, parsedMessage.Message, e.ContactId); storage.Add(item); }; receiver.Run(); domain.SendReminder = (ReminderItem ri) => { sender.Send(ri.ContactId, ri.Message); }; domain.Run(); Console.WriteLine("Нажмите любую клавишу для выхода"); Console.ReadKey(); }