public void TestMethod1() { Settings.SettingsManager settings = new Settings.SettingsManager("CheongBot"); BotAutoReply reply; reply = new BotAutoReply(settings.OracleURL, settings.OraclePort, settings.OracleDBName, settings.OracleUserName, settings.OracleUserPassword); reply.RegisterMessage("chlee", "가나다", "빠가"); reply.FindMessage("가나다"); }
protected void Page_Load(object sender, EventArgs e) { _settings = new SettingsManager("CheongBot"); _comm = new MessageCommunicator(_settings.BotToken); var Bot = new Telegram.Bot.TelegramBotClient(_settings.BotToken); ChatMessage msg = null; BotCommander bot; string content = ""; long defaultRcpt = _settings.DefaultRcpt; try { using (var reader = new StreamReader(Request.InputStream)) { content = reader.ReadToEnd(); msg = ChatMessage.FromJsonString(content); //defaultRcpt = msg.Message.Chat.ID; // Save message before the process (only for registered room) if (msg.Message.Chat.ID == _settings.RegisteredRoom1) { SaveMessage(msg, "messages"); } else if (msg.Message.Chat.ID == _settings.RegisteredRoom2) { SaveMessage(msg, "test.messages"); } bot = new BotCommander(_settings); string msgReturn; if (bot.ProcessCommand(msg.Message.From.ToString(), msg.Message.Text, out msgReturn)) { //Bot.SendTextMessageAsync(msg.Message.Chat.ID, msgReturn); if (msgReturn != "") { _comm.SendMessage(msg.Message.Chat.ID, msgReturn); } } else { BotAutoReply botAutoReply; botAutoReply = new BotAutoReply(_settings.OracleURL, _settings.OraclePort, _settings.OracleDBName, _settings.OracleUserName, _settings.OracleUserPassword); string reply = botAutoReply.FindMessage(msg.Message.Text); if (reply != "") { _comm.SendMessage(msg.Message.Chat.ID, reply); } } } } catch (Exception ex) { Bot.SendTextMessageAsync(defaultRcpt, ex.ToString()); Bot.SendTextMessageAsync(defaultRcpt, content); } }