public void TestEvaluateTimeOut() { _chatBot = new ChatBot(); ConfigurationManager.AppSettings["timeoutMax"] = "10"; _node = new Node(); _request = new Request("Test 1", new User("1", _chatBot), _chatBot); var path = "Test 1 <that> that <topic> topic"; var template = "<srai>TEST</srai>"; _node = new Node(); _node.AddCategory(path, template); var pathAlt = "Alt Test <that> that <topic> topic"; var templateAlt = "<srai>TEST ALT</srai>"; _node.AddCategory(pathAlt, templateAlt); _subQuery = new SubQuery(path); Thread.Sleep(20); var result = _node.Evaluate("Test 1 <that> that <topic> topic", _subQuery, _request, MatchState.UserInput, new StringBuilder()); Assert.AreEqual(string.Empty, result); Assert.AreEqual(true, _request.HasTimedOut); }
public void Setup() { var path = @"AIML\ChatBotTests.aiml"; _chatBot = new ChatBot(); _chatBot.LoadAIML(path); _user = new User(); }
/// <summary> /// The main entry point for the application. /// </summary> private static void Main() { // This application will run as a console app if it is compiled so. If it is compiled as a Windows app, // it will be a Windows service (hence non-interactive) if (Environment.UserInteractive) { var chatBot = new ChatBot("ConsoleUser"); while (true) { Console.Write("You: "); var input = Console.ReadLine(); if (string.IsNullOrEmpty(input) || input.ToLower() == "exit" || input.ToLower() == "quit" || input.ToLower() == "close") { break; } var response = chatBot.Chat(input); Console.WriteLine("Bot: " + response); } } else { var servicesToRun = new ServiceBase[] { new ChatService() }; ServiceBase.Run(servicesToRun); } }
/// <summary> /// Ctor /// </summary> /// <param name="chatBot">The ChatBot involved in this request</param> /// <param name="user">The user making the request</param> /// <param name="query">The query that originated this node</param> /// <param name="request">The request inputted into the system</param> /// <param name="template">The node to be processed</param> public Sr(ChatBot chatBot, User user, SubQuery query, Request request, XmlNode template) : base(template) { ChatBot = chatBot; User = user; Query = query; Request = request; }
public void TestLoadFromBinary() { _chatBot = new ChatBot(); _chatBot.LoadFromBinaryFile(); var output = _chatBot.Chat("bye", "1"); Assert.AreEqual("Cheerio.", output.RawOutput); }
public void Setup() { _chatBot = new ChatBot(); ConfigurationManager.AppSettings["timeoutMax"] = Int32.MaxValue.ToString(); _node = new Node(); _request = new Request("Test 1", new User("1", _chatBot), _chatBot); _subQuery = new SubQuery("Test 1 <that> * <topic> *"); }
public void Setup() { _appender = new MemoryAppender(); BasicConfigurator.Configure(_appender); _chatBot = new ChatBot(); var filePath = $@"{Environment.CurrentDirectory}\AIML\ChatBotTests.aiml"; _chatBot.LoadAIML(filePath); }
public void Setup() { _chatBot = new ChatBot(); ChatBot.Size = 0; _loader = new AIMLLoader(); var path = $@"{Environment.CurrentDirectory}\AIML\Salutations.aiml"; _loader.LoadAIML(path); }
public void Initialize() { _chatBot = new ChatBot(); _loader = new AIMLLoader(); const string path = @"AIML\ChatBotTests.aiml"; { _loader.LoadAIML(path); } }
/// <summary> /// Ctor /// </summary> /// <param name="chatBot">The ChatBot involved in this request</param> /// <param name="user">The user making the request</param> /// <param name="request">The request inputted into the system</param> /// <param name="templateNode">The node to be processed</param> public Srai(ChatBot chatBot, User user, Request request, XmlNode templateNode) : base(templateNode) { ChatBot = chatBot; User = user; Request = request; }
public void Initialize() { _chatBot = new ChatBot(); _loader = new AIMLLoader(_chatBot); var assembly = Assembly.GetExecutingAssembly(); using (var stream = assembly.GetManifestResourceStream("AIMLbot.UnitTest.AIML.Salutations.aiml")) { _loader.LoadAIML(stream); } }
public void TestTimeOutChatWorks() { var chatBot = new ChatBot(); const string path = @"AIML\Srai.aiml"; { _loader.LoadAIML(path); } ChatBot.TimeOut = 30; var output = chatBot.Chat("infiniteloop1", "1"); Assert.AreEqual("ERROR: The request has timed out.", output.Output); }
public void Setup() { _chatBot = new ChatBot(); var filePath = $@"{Environment.CurrentDirectory}\AIML\Srai.aiml"; _chatBot.LoadAIML(filePath); _user = new User(); _request = new Request("This is a test", _user); _query = new SubQuery(); _query.InputStar.Insert(0, "first star"); _query.InputStar.Insert(0, "second star"); }
public override string Run(McTcpClient handler, string command) { if (hasArg(command)) { ChatBot.LogToConsole(getArg(command)); return(""); } else { return(CMDDesc); } }
private static async Task Main(string[] args) { // set debug level foreach (var arg in args) if (arg == "--debug") Log.ShowDebug = true; // selamat datang Console.Title = AppNameWithVersion; var log = new Log("Main"); log.Info(AppNameWithVersion); log.Debug("Working Directory: {0}", WorkingDirectory); log.Debug("Data Directory: {0}", DataDirectory); // buka konfigurasi var isBotConfigLoaded = Bot.Loaded(); var isBotResponseLoaded = BotResponse.Loaded(); if (!isBotConfigLoaded || !isBotResponseLoaded) Terminate(1); // bot menerima pesan while (true) try { log.Debug("Mengakses akun bot..."); var receive = await BotClient.StartReceivingMessage(); if (receive) break; } catch (Exception ex) { log.Error(ex.Message); Task.Delay(10000).Wait(); } // reSchedule Schedule.ReSchedule(); // chatbot load library await ChatBot.LoadLibraryAsync(); // tunggu key ctrl+c untuk keluar dari aplikasi var exitEvent = new ManualResetEvent(false); Console.CancelKeyPress += (sender, eventArgs) => { eventArgs.Cancel = true; exitEvent.Set(); }; exitEvent.WaitOne(); // keluar dari aplikasi Terminate(); }
public void TextBoxCore() { try { b = new ChatBot(driver); browserOps.Goto("https://uitesting.eb-test.site/bots"); driver.SwitchTo().Frame("ebbot_iframe7"); elementOps.ExistsId("anon_mail"); b.BotBodyMsgEmail.SendKeys("*****@*****.**"); b.MailSubmitButton.Click(); elementOps.ExistsXpath("/html/body/div[2]/div[1]/div[3]/div/div/div/button[3]"); b.Form3ChooseButton.Click(); elementOps.ExistsId("TextBox8"); Assert.True(b.TextBoxNameIcon.GetAttribute("class").Contains("fa-user"), "Success!!", "Success!!"); b.TextBox8.SendKeys("Test User" + Keys.Enter); elementOps.ExistsId("TextBox1"); b.TextBox1.SendKeys("Test User 1" + Keys.Enter); elementOps.ExistsId("TextBox3"); b.TextBox3.SendKeys("Test User" + Keys.Enter); elementOps.ExistsXpath("/html/body/div[2]/div[1]/div[9]/div[1]/div"); Assert.True(b.TextBoxUpperCase.GetAttribute("innerHTML").Contains("TEST USER"), "Success", "Success"); elementOps.ExistsId("TextBox2"); b.TextBox2.SendKeys("Test User" + Keys.Enter); elementOps.ExistsXpath("/html/body/div[2]/div[1]/div[11]/div[1]/div"); Assert.True(b.TextBoxLowerCase.GetAttribute("innerHTML").Contains("test user"), "Success", "Success"); elementOps.ExistsId("TextBox4"); Assert.True(b.TextBoxPasswordIcon.GetAttribute("class").Contains("fa-key"), "Success!!", "Success!!"); b.TextBox4.SendKeys("password" + Keys.Enter); elementOps.ExistsId("TextBox5"); Assert.True(b.TextBoxEmailIcon.GetAttribute("class").Contains("fa-envelope"), "Success!!", "Success!!"); b.TextBox5.SendKeys("*****@*****.**" + Keys.Enter); elementOps.ExistsId("TextBox7"); Assert.True(elementOps.CheckForAttribute("TextBox7", "rows"), "Success!!", "Success!!"); b.TextBox7.SendKeys("Test User Bio" + Keys.Enter); elementOps.ExistsId("TextBox6"); elementOps.SetValue("TextBox6", "#b42727"); b.ColorSubmitButton.Click(); elementOps.ExistsName("formsubmit"); b.FormSubmitButton.Click(); } catch (Exception e) { Console.WriteLine("Faliure!!\n" + e.Message); } }
/// <summary> /// Triggered when a new player joins the game /// </summary> /// <param name="uuid">UUID of the player</param> /// <param name="name">Name of the player</param> public void OnPlayerJoin(Guid uuid, string name) { //Ignore placeholders eg 0000tab# from TabListPlus if (!ChatBot.IsValidName(name)) { return; } lock (onlinePlayers) { onlinePlayers[uuid] = name; } }
/// <summary> /// Initializes a new instance of the <see cref="Provider"/> class. /// </summary> /// <param name="jobManager">The value of <see cref="jobManager"/>.</param> /// <param name="logger">The value of <see cref="Logger"/>.</param> /// <param name="chatBot">The value of <paramref name="chatBot"/>.</param> protected Provider(IJobManager jobManager, ILogger <Provider> logger, ChatBot chatBot) { this.jobManager = jobManager ?? throw new ArgumentNullException(nameof(jobManager)); Logger = logger ?? throw new ArgumentNullException(nameof(logger)); ChatBot = chatBot ?? throw new ArgumentNullException(nameof(chatBot)); messageQueue = new Queue <Message>(); nextMessage = new TaskCompletionSource <object>(); initialConnectionTcs = new TaskCompletionSource <object>(); reconnectTaskLock = new object(); logger.LogTrace("Created."); }
public TwitchChatService(IOptionsMonitor<TwitchConfiguration> options, IServiceProvider services, ChatBot bot) { _services = services; _bot = bot; _twitchConfig = options.CurrentValue; options.OnChange(config => { _twitchConfig = config; }); _client = new TwitchClient(); _client.Connect(); _client.OnChatCommandReceived += _client_OnChatCommandReceived; }
public static void Init() { var subKey = GlobalData.SpeechKey; var region = GlobalData.SpeechRegion; Recognizer.Setup(subKey, region); Recognizer.SilenceTimeOut = 1500; var botId = GlobalData.BotId; var directLi = GlobalData.DirectLine; ChatBot.Setup(directLi, botId); }
public void LoginWithOTP() { try { b = new ChatBot(driver); browserOps.Goto("https://uitesting.eb-test.site/bots"); elementOps.ExistsId("botno14"); b.UITestBot6.Click(); elementOps.ExistsId("ebbot_iframe14"); driver.SwitchTo().Frame("ebbot_iframe14"); elementOps.ExistsId("otp_login_id"); b.OTPLoginId.SendKeys("*****@*****.**"); b.OTPIdSubmitButton.Click(); browserOps.NewTab("https://accounts.zoho.in/signin?servicename=VirtualOffice&signupurl=https://www.zoho.in/mail/zohomail-pricing.html&serviceurl=https://mail.zoho.in"); driver.SwitchTo().Window(driver.WindowHandles.Last()); elementOps.ExistsId("login_id"); b.ZohoMailId.SendKeys("*****@*****.**"); b.MailIdNextButton.Click(); wait.Until(webDriver => (driver.PageSource.Contains("id=\"login_id_container\" style=\"display: none;\""))); elementOps.ExistsId("password"); b.ZohoPassword.SendKeys("@n00p@95"); b.MailIdNextButton.Click(); elementOps.ExistsXpath("//*[@id=\"zm_centerHolder\"]/div/div/div/div[2]/div/div/div[5]/i"); b.Mail1.Click(); elementOps.ExistsXpath("//*[@id=\"zm_centerHolder\"]/div[1]/div/div/div[3]/div[1]/div[1]/div[2]/div[3]/div/div/div"); string str = b.Mail1Msg.GetAttribute("innerHTML"); Regex regex = new Regex(@"\d{6}"); MatchCollection matches = regex.Matches(str); string otp = matches[0].ToString().Trim(); Console.WriteLine(otp); driver.Close(); driver.SwitchTo().Window(driver.WindowHandles.Last()); elementOps.ExistsId("ebbot_iframe14"); driver.SwitchTo().Frame("ebbot_iframe14"); elementOps.ExistsId("partitioned"); b.OTPField.Click(); b.OTPField.SendKeys(otp); b.OTPValidateButton.Click(); wait.Until(webDriver => (driver.PageSource.Contains("Click to explore"))); Console.WriteLine(driver.Manage().Cookies.AllCookies.Count); driver.Manage().Cookies.DeleteCookieNamed("bot_rToken"); driver.Manage().Cookies.DeleteCookieNamed("bot_bToken"); } catch (Exception e) { Console.WriteLine("Faliure!!\n" + e.Message); } }
/// <inheritdoc /> public async Task <ChatBot> GetByIdAsync( string id, CancellationToken cancellationToken = default ) { var filter = Filter.Eq(_ => _.Id, id); ChatBot bot = await _collection .Find(filter) .SingleOrDefaultAsync(cancellationToken) .ConfigureAwait(false); return(bot); }
/// <summary> /// Static helper that applies replacements from the passed dictionary object to the /// target string /// </summary> /// <param name="chatBot">The ChatBot for whom this is being processed</param> /// <param name="dictionary">The dictionary containing the substitutions</param> /// <param name="target">the target string to which the substitutions are to be applied</param> /// <returns>The processed string</returns> public static string Substitute(ChatBot chatBot, SettingsDictionary dictionary, string target) { string marker = GetMarker(5); string result = target; foreach (string pattern in dictionary.SettingNames) { string p2 = MakeRegexSafe(pattern); //string match = "\\b"[email protected]().Replace(" ","\\s*")+"\\b"; string match = "\\b" + p2.TrimEnd().TrimStart() + "\\b"; string replacement = marker + dictionary.GrabSetting(pattern).Trim() + marker; result = Regex.Replace(result, match, replacement, RegexOptions.IgnoreCase); } return result.Replace(marker, ""); }
/// <inheritdoc /> public async Task <ChatBot> GetByNameAsync( string name, CancellationToken cancellationToken = default ) { name = Regex.Escape(name); var filter = Filter.Regex(b => b.Name, new BsonRegularExpression($"^{name}$", "i")); ChatBot bot = await _collection .Find(filter) .SingleOrDefaultAsync(cancellationToken) .ConfigureAwait(false); return(bot); }
public async Task Run() { var firstBot = new ChatBot { ConnectionString = Environment.GetEnvironmentVariable("TGS4_TEST_DISCORD_TOKEN"), Enabled = false, Name = "r4407", Provider = ChatProvider.Discord, ReconnectionInterval = 1 }; firstBot = await chatClient.Create(firstBot, default); Assert.AreNotEqual(0, firstBot.Id); var bots = await chatClient.List(default);
public MessageSendPacketHandler( UserManager users, ChannelManager channels, ChannelUserRelations channelUsers, MessageManager messages, ChatBot bot, IEnumerable <ICommand> commands ) { Users = users ?? throw new ArgumentNullException(nameof(users)); Channels = channels ?? throw new ArgumentNullException(nameof(channels)); ChannelUsers = channelUsers ?? throw new ArgumentNullException(nameof(channelUsers)); Messages = messages ?? throw new ArgumentNullException(nameof(messages)); Bot = bot ?? throw new ArgumentNullException(nameof(bot)); Commands = commands ?? throw new ArgumentNullException(nameof(commands)); }
public void Setup() { this.clientFactory = new Mock <ITwitchClientFactory>(); this.client = new Mock <ITwitchClient>(); this.clientFactory.Setup(f => f.Create(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(this.client.Object); this.chattersCache = new Mock <IChattersCache>(); this.commandHandler1 = new Mock <ICommandHandler>(); this.commandHandler2 = new Mock <ICommandHandler>(); ICommandHandler[] commandHandlers = { this.commandHandler1.Object, this.commandHandler2.Object }; this.messageHandler1 = new Mock <IMessageHandler>(); this.messageHandler2 = new Mock <IMessageHandler>(); IMessageHandler[] messageHandlers = { this.messageHandler1.Object, this.messageHandler2.Object }; this.chatBot = new ChatBot(this.clientFactory.Object, commandHandlers, messageHandlers, this.chattersCache.Object); }
public static SessionToken FromString(string tokenString) { string[] fields = tokenString.Split(','); if (fields.Length < 4) { throw new InvalidDataException("Invalid string format"); } SessionToken session = new SessionToken(); session.ID = fields[0]; session.PlayerName = fields[1]; session.PlayerID = fields[2]; session.ClientID = fields[3]; // Backward compatible with old session file without refresh token field if (fields.Length > 4) { session.RefreshToken = fields[4]; } else { session.RefreshToken = String.Empty; } Guid temp; if (!JwtRegex.IsMatch(session.ID)) { throw new InvalidDataException("Invalid session ID"); } if (!ChatBot.IsValidName(session.PlayerName)) { throw new InvalidDataException("Invalid player name"); } if (!Guid.TryParseExact(session.PlayerID, "N", out temp)) { throw new InvalidDataException("Invalid player ID"); } if (!Guid.TryParseExact(session.ClientID, "N", out temp)) { throw new InvalidDataException("Invalid client ID"); } // No validation on refresh token because it is custom format token (not Jwt) return(session); }
public static void LyncChat(List<BotRule> rules) { client = LyncClient.GetClient(); client.ConversationManager.ConversationAdded += ConversationManager_ConversationAdded; client.ConversationManager.ConversationRemoved += ConversationManager_ConversationRemoved; while (_conversation == null) { Thread.Sleep(1000); } ChatBot cb = new ChatBot(rules); cb.talkWith(_LyncConversation); Console.ReadKey(); }
public Task InitializeAsync(ILogger logger, IValueCallback valueCallback, string configFilePath) { _logger = logger; _valueCallback = valueCallback; _logger.Info("zenBot driver extension started."); _askBot = new ChatBot(new ZenonQuestions(), JulieVirtualAssistantConnection); _tellBot = new ChatBot(new ZenonFacts(), BrainBotConnection); //Initialize Conversation var askBotAnswer = _askBot.GetNewAnswer(new ZenBotMessage() { Message = "Hello from zenon!" }); _tellBot.GetNewAnswer(askBotAnswer); return(Task.CompletedTask); }
public ActionResult AnswerQuestion(string sentence) { ChatBot chat = new ChatBot(); string answer1 = "You want a fighting Game"; string answer2 = "You want a Shooting Game"; string answer3 = "You want a Open World Game"; string answer4 = "You want a New Console"; string answer5 = "Yes this game is Great"; string answer6 = "You Want GTA V"; string answer7 = "You Want Dragonball Xeneoverse"; string answer8 = "Tekken Would Be Great for You"; string answer9 = "Call Of Duty Black Ops 3 Is the fastest"; string answer10 = "Battlefield 1 would suit you well"; string answer11 = "How Can I Help You"; string answer12 = "It has Great Reviews"; string answer13 = "They All are Great"; string answer14 = "You want a Xbox Then"; string answer15 = "No Problem!"; string answer16 = "How Can I Help You"; chat.KeyResponseAny(answer1, "Violent", "fight", "fun"); chat.KeyResponseAny(answer2, "Guns", "Running", "fun"); chat.KeyResponseAny(answer3, "Driving", "Shoot", "Drive", "game"); chat.KeyResponseAny(answer4, "play", "want", "i"); chat.KeyResponseAny(answer5, "is", "that", "game", "fun"); chat.KeyResponseAny(answer6, "driving", "shoot", "hugh"); chat.KeyResponseAny(answer7, "fly", "fighting", "game", "where"); chat.KeyResponseAny(answer8, "skill", "fighting", "oldschool"); chat.KeyResponseAny(answer9, "fast", "pace", "popular", "shooting"); chat.KeyResponseAny(answer10, "traditional", "shooting", "realistic", "game"); chat.KeyResponseAny(answer11, ""); chat.KeyResponseAny(answer12, "reviews", "what", "ratings"); chat.KeyResponseAny(answer13, "good", "Game", "which", "console"); chat.KeyResponseAny(answer14, "cheapest", "console"); chat.KeyResponseAny(answer15, "Thank", "you", "Thanks", "cool"); chat.KeyResponseAny(answer16, "Hello", "Hey", "Hi"); chat.KeyResponseAny("Hello, how can I help you?", "Hello", "Hi", "What's up"); chat.NoMatchMessage("Can you reprase that?"); chat.NoMatchMessage("Your terminology is unfamiliar with me?"); chat.NoMatchMessage("I don't understand?"); string answer = chat.GetResponse(sentence, true); return(Content(answer)); }
public static void LyncChat(List <BotRule> rules) { client = LyncClient.GetClient(); client.ConversationManager.ConversationAdded += ConversationManager_ConversationAdded; client.ConversationManager.ConversationRemoved += ConversationManager_ConversationRemoved; while (_conversation == null) { Thread.Sleep(1000); } ChatBot cb = new ChatBot(rules); cb.talkWith(_LyncConversation); Console.ReadKey(); }
public void Patch(ref ChatBot bot) { if (Name != null) { bot.Name = Name; } if (Questions != null) { bot.Questions.Clear(); foreach (var q in Questions) { bot.Questions.Add(new Question { Text = q.Question, Value = q.SerializedValue() }); } } }
private void Awake() { Instance = this; string filename = Application.streamingAssetsPath + "/Data/Game Info/keywords.txt"; keywords = new Dictionary <string, string>(); string[] temp = File.ReadAllLines(filename); foreach (string line in temp) { string[] pair = line.Split(','); keywords.Add(pair[0].ToLower(), pair[1]); } uiController = GetComponent <ChatBotUI>(); }
public LootsClient() { Cache = new Cache(this); Thread.Sleep(1); Settings = new Settings(this); Thread.Sleep(1); ChatBot = new ChatBot(this); Thread.Sleep(1); Commands = new Commands(this); Thread.Sleep(1); Counter = new Counter(this); Thread.Sleep(1); MessageHelper = new Message(this); ActiveInstance = this; Commands.PrepareCommands(); }
/// <inheritdoc /> public async Task AddAsync( ChatBot bot, CancellationToken cancellationToken = default ) { try { await _collection.InsertOneAsync(bot, cancellationToken : cancellationToken) .ConfigureAwait(false); } catch (MongoWriteException e) when( e.WriteError.Category == ServerErrorCategory.DuplicateKey && e.WriteError.Message.Contains($" index: {MongoConstants.Collections.Bots.Indexes.BotId} ") ) { throw new DuplicateKeyException(nameof(ChatBot.Name)); } }
/// <summary> /// Construct a <see cref="DiscordProvider"/> /// </summary> /// <param name="jobManager">The <see cref="IJobManager"/> for the <see cref="Provider"/>.</param> /// <param name="assemblyInformationProvider">The value of <see cref="assemblyInformationProvider"/>.</param> /// <param name="logger">The <see cref="ILogger"/> for the <see cref="Provider"/>.</param> /// <param name="chatBot">The <see cref="ChatBot"/> for the <see cref="Provider"/>.</param> public DiscordProvider( IJobManager jobManager, IAssemblyInformationProvider assemblyInformationProvider, ILogger <DiscordProvider> logger, ChatBot chatBot) : base(jobManager, logger, chatBot) { this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider)); var csb = new DiscordConnectionStringBuilder(chatBot.ConnectionString); botToken = csb.BotToken; basedMeme = csb.BasedMeme; outputDisplayType = csb.DMOutputDisplay; client = new DiscordSocketClient(); client.MessageReceived += Client_MessageReceived; mappedChannels = new List <ulong>(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller}/{action=Index}/{id?}"); }); app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseReactDevelopmentServer(npmScript: "start"); } }); _requestrrBot = (RequestrrBot.ChatBot)app.ApplicationServices.GetService(typeof(RequestrrBot.ChatBot)); _requestrrBot.Start(); }
public void BotClose() { try { b = new ChatBot(driver); browserOps.Goto("https://uitesting.eb-test.site/bots"); elementOps.ExistsId("botno7"); b.UITestBot1.Click(); elementOps.ExistsId("closediv7"); browserOps.ClickableWait(b.BotClose); b.BotClose.Click(); Assert.AreEqual("display: none;", b.BotFrame.GetAttribute("style").ToString(), "Success", "Success"); b.UITestBot1.Click(); Assert.AreNotEqual("display: none;", b.BotFrame.GetAttribute("style").ToString(), "Success", "Success"); } catch (Exception e) { Console.WriteLine("Faliure!!\n" + e.Message); } }
public object Get(BotListRequest request) { List <ChatBot> res = new List <ChatBot>(); string sql = @" SELECT id, name, url, botid, (SELECT firstname FROM eb_users WHERE id = eb_bots.created_by) AS created_by, created_at, (SELECT firstname FROM eb_users WHERE id = eb_bots.modified_by) AS modified_by, modified_at, welcome_msg FROM eb_bots WHERE solution_id = @solid;" ; parameters.Add(this.TenantDbFactory.ObjectsDB.GetNewParameter("@solid", System.Data.DbType.Int32, 100));//request.SolutionId)); var dt = this.TenantDbFactory.ObjectsDB.DoQuery(sql, parameters.ToArray()); foreach (var dr in dt.Rows) { ChatBot bot = new ChatBot { BotId = dr[0].ToString(), Name = dr[1].ToString(), WebsiteURL = dr[2].ToString(), ChatId = dr[3].ToString(), CreatedBy = dr[4].ToString(), CreatedAt = Convert.ToDateTime(dr[5]), LastModifiedBy = dr[6].ToString(), LastModifiedAt = Convert.ToDateTime(dr[7]), WelcomeMsg = dr[8].ToString() }; res.Add(bot); } return(new BotListResponse { Data = res }); }
/// <summary> /// Create a Twitch chatbot. /// </summary> public ChatController(AuthInfo info) { var _state = _stateMachine = new StateMachine <State, Trigger>(State.SignedOff); _state.OnTransitioned((transition => { _log.DebugFormat("{0} => {1}", transition.Source.ToString("G"), transition.Destination.ToString("G")); })); _state.Configure(State.Conceived) .Permit(Trigger.DisconnectRequested, State.SignedOff); _state.Configure(State.SignedOff) .SubstateOf(State.Conceived) .OnEntry(() => Task.Run(() => Whisperer.Stop())) .OnEntry(() => Task.Run(() => Talker.Stop())) .Ignore(Trigger.ChatbotsUnready) .Permit(Trigger.ConnectRequested, State.Connecting); _state.Configure(State.Connecting) .SubstateOf(State.Conceived) .OnEntry(() => Task.Run(() => Whisperer.Start())) .OnEntry(() => Task.Run(() => Talker.Start())) .Ignore(Trigger.ConnectRequested) .Ignore(Trigger.ChatbotsUnready) .Permit(Trigger.ChatbotsReady, State.Ready); _state.Configure(State.Ready) .SubstateOf(State.Conceived) .Ignore(Trigger.ChatbotsReady) .OnEntry(() => Ready?.Invoke(this, EventArgs.Empty)) .OnExit(() => Unready?.Invoke(this, EventArgs.Empty)); Whisperer = new ChatBot(info, true); Whisperer.Ready += CheckBotStates; Whisperer.Unready += CheckBotStates; Talker = new ChatBot(info, false); Talker.Ready += CheckBotStates; Talker.Unready += CheckBotStates; }
static void Main(string[] args) { string shutdown = ""; ChatBot bot = new ChatBot(); bot.Connect(); do { shutdown = Console.ReadLine(); if (bot.GetClient().IsConnected == false) { bot.Connect(); } } while (shutdown != "exit" || shutdown != "Exit" || shutdown != "quit" || shutdown != "Quit"); Console.WriteLine("You shouldn't be here. Something broke"); bot.Disconnect(); }
public static void SpeechChat(List <BotRule> rules) { using (SpeechRecognitionEngine speechRecognition = new SpeechRecognitionEngine( new System.Globalization.CultureInfo("en-US") )) { // Create a default dictation grammar. DictationGrammar defaultDictationGrammar = new DictationGrammar() { Name = "default dictation", Enabled = true }; speechRecognition.LoadGrammar(defaultDictationGrammar); // Create the spelling dictation grammar. DictationGrammar spellingDictationGrammar = new DictationGrammar("grammar:dictation#spelling") { Name = "spelling dictation", Enabled = true }; speechRecognition.LoadGrammar(spellingDictationGrammar); // Add Grammar for the demo, to make it more reliable: // https://msdn.microsoft.com/en-us/library/hh362944(v=office.14).aspx // http://dailydotnettips.com/2014/01/18/using-wildcard-with-grammar-builder-kinect-speech-recognition/ // Configure input to the speech recognizer. speechRecognition.SetInputToDefaultAudioDevice(); using (_SpeechConversation = new SpeechConversation(speechRecognition: speechRecognition)) { ChatBot cb = new ChatBot(rules); cb.talkWith(_SpeechConversation); Console.ReadKey(); } } }
public void CheckBotRender() { try { b = new ChatBot(driver); browserOps.Goto("https://uitesting.eb-test.site/bots"); elementOps.ExistsId("botno7"); b.UITestBot1.Click(); elementOps.ExistsId("ebbot_iframe7"); Assert.Multiple(() => { Assert.AreEqual("True", elementOps.IsWebElementPresent(b.BotFrame).ToString(), "Success!!", "Success!!"); Assert.AreEqual("True", elementOps.IsWebElementPresent(b.BotHeader).ToString(), "Success!!", "Success!!"); Console.WriteLine("Header Present"); Assert.AreEqual("True", elementOps.IsWebElementPresent(b.BotBody).ToString(), "Success!!", "Success!!"); Console.WriteLine("Body Present"); }); } catch (Exception e) { Console.WriteLine("Faliure!!\n" + e.Message); } }
//[Test, Order(6)] public void BotStartOver() { try { b = new ChatBot(driver); browserOps.Goto("https://uitesting.eb-test.site/bots"); elementOps.ExistsId("botno7"); b.UITestBot1.Click(); elementOps.ExistsId("ebbot_iframe7"); driver.SwitchTo().Frame("ebbot_iframe7"); elementOps.ExistsId("anon_mail"); b.BotBodyMsgEmail.SendKeys("*****@*****.**"); b.MailSubmitButton.Click(); wait.Until(webDriver => (driver.PageSource.Contains("Click to explore"))); elementOps.ExistsClass("startOvercont"); b.BotBodyStartOver.Click(); wait.Until(webDriver => (driver.PageSource.Contains("Click to explore"))); } catch (Exception e) { Console.WriteLine("Faliure!!\n" + e.Message); } }
public static void SpeechChat(List<BotRule> rules) { using(SpeechRecognitionEngine speechRecognition = new SpeechRecognitionEngine( new System.Globalization.CultureInfo("en-US") )) { // Create a default dictation grammar. DictationGrammar defaultDictationGrammar = new DictationGrammar() { Name = "default dictation", Enabled = true }; speechRecognition.LoadGrammar(defaultDictationGrammar); // Create the spelling dictation grammar. DictationGrammar spellingDictationGrammar = new DictationGrammar("grammar:dictation#spelling") { Name = "spelling dictation", Enabled = true }; speechRecognition.LoadGrammar(spellingDictationGrammar); // Add Grammar for the demo, to make it more reliable: // https://msdn.microsoft.com/en-us/library/hh362944(v=office.14).aspx // http://dailydotnettips.com/2014/01/18/using-wildcard-with-grammar-builder-kinect-speech-recognition/ // Configure input to the speech recognizer. speechRecognition.SetInputToDefaultAudioDevice(); using (_SpeechConversation = new SpeechConversation(speechRecognition: speechRecognition)) { ChatBot cb = new ChatBot(rules); cb.talkWith(_SpeechConversation); Console.ReadKey(); } } }
public StripIllegalCharacters(ChatBot chatBot, string inputString) : base(chatBot, inputString) { }
public MakeCaseInsensitive(ChatBot chatBot) : base(chatBot) { }
public MakeCaseInsensitive(ChatBot chatBot, string inputString) : base(chatBot, inputString) { }
private void Initialize(AimlBotConfig config) { _config = config; _users = new Dictionary<string, User>(); _bot = new ChatBot(config.SettingsPath); }
/// <summary> /// Ctor /// </summary> /// <param name="chatBot">The ChatBot this sentence splitter is associated with</param> /// <param name="inputString">The raw input string to be processed</param> public SplitIntoSentences(ChatBot chatBot, string inputString) { this._chatBot = chatBot; this._inputString = inputString; }
/// <summary> /// Ctor /// </summary> /// <param name="chatBot">The ChatBot this sentence splitter is associated with</param> public SplitIntoSentences(ChatBot chatBot) { this._chatBot = chatBot; }
/// <summary> /// The ask bot command. /// </summary> /// <param name="chatBot"> /// The chatBot to use. /// </param> /// <param name="message"> /// The message. /// </param> /// <param name="userName"> /// The user name. /// </param> /// <param name="botName"> /// The bot name. /// </param> /// <exception cref="ArgumentOutOfRangeException"></exception> /// <returns> /// The <see cref="string"/>. /// </returns> internal static string AskBot(ChatBot chatBot, string message, string userName, string botName) { try { string answer; string searchForStart; string searchForEnd; switch (chatBot) { case ChatBot.Romulus: answer = Rest.Post( new Uri("http://www.pandorabots.com"), "/pandora/talk?botid=823a1209ae36baf3", new KeyValuePair<string, string>("botcust2", userName), new KeyValuePair<string, string>("input", message)); searchForStart = @"Dr. Romulon:</b> "; searchForEnd = "<br>"; break; case ChatBot.Chato: answer = Rest.Post( new Uri("http://nlp-addiction.com"), "/chatbot/chato/f.php", new KeyValuePair<string, string>("chat", message), new KeyValuePair<string, string>("response_Array[sessionid]", "19dm6ogm92mc4krked08138c40"), new KeyValuePair<string, string>("response_Array[userid]", "24876"), new KeyValuePair<string, string>("action", "checkresponse"), new KeyValuePair<string, string>("response_Array[rname]", "Array#0")); searchForStart = @"Bot: <b><font size='+1'>"; searchForEnd = "</font>"; break; default: throw new ArgumentOutOfRangeException("chatBot", chatBot, "Unknown"); } // Interprete answer answer = Rest.FindPart(answer, searchForStart, searchForEnd); if (answer == null) { throw new Exception("Could not find the chatbot answer."); } answer = WebUtility.HtmlDecode(answer); answer = answer.Replace("ALICE A.I.", "Zeniox Inc."); answer = answer.Replace("ALICE", "Zeniox"); answer = answer.Replace("seeker", "sir"); switch (chatBot) { case ChatBot.Romulus: if (!string.IsNullOrWhiteSpace(botName)) { // Replace the bot name with our own answer = answer.Replace("Dr. Romulon", botName); answer = answer.Replace("Romulon", botName); } break; case ChatBot.Chato: if (!string.IsNullOrWhiteSpace(botName)) { // Replace the bot name with our own answer = answer.Replace("Chato", botName); } break; default: throw new ArgumentOutOfRangeException("chatBot", chatBot, "Unknown"); } return answer; } catch (Exception) { Console.WriteLine("Failed to ask external bot {0}", chatBot); return null; } }
public StripIllegalCharacters(ChatBot chatBot) : base(chatBot) { }
/// <summary> /// Ctor /// </summary> /// <param name="chatBot">The ChatBot for whom this is a settings dictionary</param> public SettingsDictionary(ChatBot chatBot) { this.ChatBot = chatBot; }
public mockTextTransformer(ChatBot chatBot, string inputString) : base(chatBot, inputString) { }
public void Setup() { _mockChatBot = new ChatBot(); }
public mockTextTransformer(ChatBot chatBot) : base(chatBot) { }
public void TearDown() { _chatBot = null; }
public void SetupMockObjects() { _chatBot = new ChatBot(); }