static void Main(string[] args) { Console.WriteLine("Telegram Bot Application!"); var storage = new InMemoryReminderStorage(); string token = "633428988:AAHLW_LaS7A47PDO2I8sbLkIIM9L0joPOSQ"; IWebProxy proxy = new HttpToSocks5Proxy( "proxy.golyakov.net", 1080); var receiver = new TelegramReminderReceiver(token, proxy); var domain = new ReminderDomain(storage, receiver); var sender = new TelegramReminderSender(token, proxy); domain.SendReminder = (ReminderItem ri) => { sender.Send(ri.ContactId, ri.Message); }; domain.MessageReceived += Domain_MessageReceived; domain.MessageParsingSuccedded += Domain_MessageParsingSuccedded; domain.MessageParsingFailed += Domain_MessageParsingFailed; domain.AddingToStorageSuccedded += Domain_AddingToStorageSuccedded; domain.AddingToStorageFailed += Domain_AddingToStorageFailed; 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); 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 Bot Application!"); var storage = new ReminderStorageWebApiClient( "http://localhost:5000/api/reminders"); //string token = "633428988:AAHLW_LaS7A47PDO2I8sbLkIIM9L0joPOSQ"; string token = "697789387:AAFzSKZg8GmR-_aMktYSwcz0kKiL1D7__ww"; IWebProxy proxy = new HttpToSocks5Proxy( "proxy.golyakov.net", 1080); //var receiver = new TelegramReminderReceiver(token); var receiver = new TelegramReminderReceiver(token, proxy); var domain = new ReminderDomain(storage, receiver); var sender = new TelegramReminderSender(token, proxy); //var sender = new TelegramReminderSender(token); domain.SendReminder = (ReminderItem ri) => { sender.Send(ri.ContactId, ri.Message); }; domain.MessageReceived += Domain_MessageReceived; domain.MessageParsingSuccedded += Domain_MessageParsingSuccedded; domain.MessageParsingFailed += Domain_MessageParsingFailed; domain.AddingToStorageSuccedded += Domain_AddingToStorageSuccedded; domain.AddingToStorageFailed += Domain_AddingToStorageFailed; domain.SendingFailed += Domain_SendingFailed; 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(); }