/// <summary> /// Static helper that applies replacements from the passed dictionary object to the /// target string /// </summary> /// <param name="bot">The bot 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(AIMLbot.Bot bot, AIMLbot.Utils.SettingsDictionary dictionary, string target) { string marker = ApplySubstitutions.getMarker(5); string result = target; foreach (string pattern in dictionary.SettingNames) { string p2 = ApplySubstitutions.makeRegexSafe(pattern); string valueP2 = dictionary.grabSetting(pattern).Trim(); Regex regPattern = new Regex(p2, RegexOptions.Singleline | RegexOptions.IgnoreCase); Match match = regPattern.Match(result); if (match.Success) { string match1 = p2.TrimEnd().TrimStart(); if (!String.IsNullOrEmpty(match1)) { string replacement = marker + dictionary.grabSetting(pattern) + marker; result = Regex.Replace(result, match1, replacement, RegexOptions.IgnoreCase); } } //result = Regex.Replace(result, p2, valueP2, RegexOptions.IgnoreCase); //string match = "\\b"[email protected]().Replace(" ","\\s*")+"\\b"; //string match = p2.TrimEnd().TrimStart(); //string replacement = marker+dictionary.grabSetting(pattern).Trim()+marker; //result = Regex.Replace(result, match, replacement, RegexOptions.IgnoreCase); } return(result.Replace(marker, "")); //return result; }
/// <summary> /// Static helper that applies replacements from the passed dictionary object to the /// target string /// </summary> /// <param name="bot">The bot 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(AIMLbot.Bot bot, AIMLbot.Utils.SettingsDictionary dictionary, string target) { string result = target;//MakeCaseInsensitive.TransformInput(target); foreach (string pattern in dictionary.SettingNames) { string p2 = ApplySubstitutions.makeRegexSafe(pattern); //string match = "\\b" + @p2.Trim() + "\\b"; string match = @p2; string replacement = dictionary.grabSetting(pattern); if (replacement.StartsWith(" ")) { replacement = " ||" + replacement.TrimStart(); } else { replacement = "||" + replacement; } if (replacement.EndsWith(" ")) { replacement = replacement.TrimEnd() + "|| "; } else { replacement = replacement + "||"; } result = Regex.Replace(result, match, replacement, RegexOptions.IgnoreCase); } return(result.Replace("||", "")); }
public TalkToAvatar(RadegastInstance inst, AIMLBot bot) : base(inst) { ContextType = typeof(Avatar); Label = "Talk to"; aimlBot = bot; }
public void setupMockBot() { this.mockBot = new AIMLbot.Bot(); string subs = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><root><item name=\" this \" value=\" the \" /><item name=\" is \" value=\" test \" /><item name=\" a \" value=\" works \" /><item name=\" test \" value=\" great \" /><item name=\" fav \" value=\"favourite\" /><item name=\" a \" value=\" works \" /><item name=\" R U \" value=\" are you \" /><item name=\" a \" value=\" works \" /><item name=\" you r \" value=\" you are \" /></root>"; this.substitutions = new XmlDocument(); this.substitutions.LoadXml(subs); }
/// <summary> /// Ctor /// </summary> /// <param name="bot">The bot 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="result">The result to be passed to the user</param> /// <param name="templateNode">The node to be processed</param> public system(AIMLbot.Bot bot, AIMLbot.User user, AIMLbot.Utils.SubQuery query, AIMLbot.Request request, AIMLbot.Result result, XmlNode templateNode) : base(bot, user, query, request, result, templateNode) { }
/// <summary> /// Ctor /// </summary> /// <param name="bot">The bot 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="result">The result to be passed to the user</param> /// <param name="templateNode">The node to be processed</param> public condition(AIMLbot.Bot bot, AIMLbot.User user, AIMLbot.Utils.SubQuery query, AIMLbot.Request request, AIMLbot.Result result, XmlNode templateNode) : base(bot, user, query, request, result, templateNode) { this.isRecursive = false; }
/// <summary> /// Ctor /// </summary> /// <param name="bot">The bot 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="result">The result to be passed to the user</param> /// <param name="templateNode">The node to be processed</param> public javascript(AIMLbot.Bot bot, AIMLbot.User user, AIMLbot.Utils.SubQuery query, AIMLbot.Request request, AIMLbot.Result result, XmlNode templateNode) : base(bot, user, query, request, result, templateNode) { // Preprocess javascript, return result and then process result this.isRecursive = false; }
//public AIMLbot.Request mockRequest; //public AIMLbot.Result mockResult; //public AIMLbot.Utils.SubQuery mockQuery; public TagTester() { this.mockBot = new Bot(); this.mockBot.loadSettings(); this.mockBot.loadAIMLFromFiles(); this.mockUser = new User("1", this.mockBot); //mockRequest = new Request("This is a test", this.mockUser, this.mockBot); //this.mockQuery = new AIMLbot.Utils.SubQuery("This is a test <that> * <topic> *"); //this.mockQuery.InputStar.Insert(0, "first star"); //this.mockQuery.InputStar.Insert(0, "second star"); //mockResult = new Result(this.mockUser, this.mockBot, mockRequest); }
/// <summary> /// Ctor /// </summary> /// <param name="bot">The bot 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 itself</param> /// <param name="result">The result to be passed back to the user</param> /// <param name="templateNode">The node to be processed</param> public AIMLTagHandler(AIMLbot.Bot bot, AIMLbot.User user, AIMLbot.Utils.SubQuery query, AIMLbot.Request request, AIMLbot.Result result, XmlNode templateNode) : base(bot, templateNode.OuterXml) { this.user = user; this.query = query; this.request = request; this.result = result; this.templateNode = templateNode; }
private void ucConfigurationButton1_Click(object sender, EventArgs e) { using (FormOptions form = new FormOptions()) { form.SetConfiguration(_cf, this); if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { _bot = null; _user = null; SetConfiguration(form.GetConfiguration()); } } }
/// <summary> /// Ctor /// </summary> /// <param name="UserID">The GUID of the user</param> /// <param name="bot">the bot the user is connected to</param> public User(string UserID, AIMLbot.Bot bot) { if (UserID.Length > 0 && bot != null) { this.id = UserID; this.bot = bot; this.Predicates = new AIMLbot.Utils.SettingsDictionary(this.bot); this.bot.DefaultPredicates.Clone(this.Predicates); this.Predicates.addSetting("topic", "*"); } else { Debug.LogWarning("The UserID is empty or no bot was passed."); } }
/// <summary> /// Ctor /// </summary> /// <param name="UserID">The GUID of the user</param> /// <param name="bot">the bot the user is connected to</param> public User(string UserID, AIMLbot.Bot bot) { if (UserID.Length > 0) { this.id = UserID; this.bot = bot; this.Predicates = new AIMLbot.Utils.SettingsDictionary(this.bot); this.bot.DefaultPredicates.Clone(this.Predicates); this.Predicates.addSetting("topic", "*"); } else { throw new Exception("The UserID cannot be empty"); } }
/// <summary> /// Static helper that applies replacements from the passed dictionary object to the /// target string /// </summary> /// <param name="bot">The bot 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(AIMLbot.Bot bot, AIMLbot.Utils.SettingsDictionary dictionary, string target) { string marker = ApplySubstitutions.getMarker(5); string result = target; foreach (string pattern in dictionary.SettingNames) { string p2 = ApplySubstitutions.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, "")); }
public override void SetConfiguration(PluginV1 cf) { cf.STORAGE.AddIfNotExist(ConfigTitles.RESPONSE_VARIABLE, "$BotResponse"); cf.STORAGE.AddIfNotExist(ConfigTitles.RESPONSE_SCRIPT, string.Empty); cf.STORAGE.AddIfNotExist(ConfigTitles.RESPONSE_XML, string.Empty); cf.STORAGE.AddIfNotExist(ConfigTitles.CONFIG_ROOT_FOLDER, EZ_Builder.Common.CombinePath(EZ_Builder.Constants.PLUGINS_FOLDER, cf._pluginGUID)); EZ_Builder.Scripting.VariableManager.SetVariable(cf.STORAGE[ConfigTitles.RESPONSE_VARIABLE].ToString(), string.Empty); if (_bot == null) { try { string configRootFolder = cf.STORAGE[ConfigTitles.CONFIG_ROOT_FOLDER].ToString(); string aimlFolder = EZ_Builder.Common.CombinePath(configRootFolder, "aiml"); string configFolder = EZ_Builder.Common.CombinePath(configRootFolder, "config"); string settingsFile = EZ_Builder.Common.CombinePath(configRootFolder, "config", "Settings.xml"); EZ_Builder.Invokers.SetAppendText(tbLog, false, "Loading AIM configuration... "); _bot = new AIMLbot.Bot(); _bot.PathToAIML = aimlFolder; _bot.PathToConfigFiles = configFolder; _bot.loadSettings(settingsFile); _bot.loadAIMLFromFiles(); _bot.isAcceptingUserInput = true; _bot.WrittenToLog += _bot_WrittenToLog; _user = new AIMLbot.User("DJ", _bot); EZ_Builder.Invokers.SetAppendText(tbLog, true, "Success!"); } catch (Exception ex) { EZ_Builder.Invokers.SetAppendText(tbLog, true, ex.ToString()); } } base.SetConfiguration(cf); }
/// <summary> /// ctor /// </summary> /// <param name="bot">The bot this transformer is a part of</param> /// <param name="inputString">The input string to be transformed</param> public TextTransformer(AIMLbot.Bot bot, string inputString) { this.bot = bot; this.inputString = inputString; }
public mockTextTransformer(AIMLbot.Bot bot, string inputString) : base(bot, inputString) { }
/// <summary> /// ctor /// </summary> /// <param name="bot">The bot this transformer is a part of</param> public TextTransformer(AIMLbot.Bot bot) { this.bot = bot; this.inputString = string.Empty; }
public void setupMockBot() { this.mockBot = new AIMLbot.Bot(); this.mockBot.loadSettings(); }
static void Main(string[] args) { //powtarzamy czynnosci az nam się uda while (true) { agentVLuke_Jones = new AgentAPI(Listen); //tworzymy nowe AgentAPI, //podając w parametrze naszą metodę nasłuchującą // pobieramy parametry połączenia i agenta z klawiatury Console.Write("Wczytano IP serwera.\n"); String ip = "atlantyda.vm.wmi.amu.edu.pl"; Console.Write("Wczytano nazwe druzyny.\n"); groupname = "VLuke_Jones"; Console.Write("Wprowadzono haslo.\n"); String grouppass = "******"; Console.Write("Podaj nazwe swiata: "); String worldname = Console.ReadLine(); Console.Write("Podaj imie: "); imie = Console.ReadLine(); try { //łączymy się z serwerem. Odbieramy parametry świata i wyświetlamy je cennikSwiata = agentVLuke_Jones.Connect(ip, 6008, groupname, grouppass, worldname, imie); Console.WriteLine(cennikSwiata.initialEnergy + " - Maksymalna energia"); Console.WriteLine(cennikSwiata.maxRecharge + " - Maksymalne doładowanie"); Console.WriteLine(cennikSwiata.sightScope + " - Zasięg widzenia"); Console.WriteLine(cennikSwiata.hearScope + " - Zasięg słyszenia"); Console.WriteLine(cennikSwiata.moveCost + " - Koszt chodzenia"); Console.WriteLine(cennikSwiata.rotateCost + " - Koszt obrotu"); Console.WriteLine(cennikSwiata.speakCost + " - Koszt mówienia"); smallestCost = cennikSwiata.moveCost; if (smallestCost > cennikSwiata.rotateCost) smallestCost = cennikSwiata.rotateCost; if (smallestCost > cennikSwiata.speakCost) smallestCost = cennikSwiata.speakCost; kosztDoZrodla = -1; Console.Write("Wybierz tryb:\n(0)Random\n(1)SmartBot\n(2)Klawiatura\n"); String tryb = Console.ReadLine(); pozycjaRozmowcy = new int[2]; pozycjaRozmowcy[0] = -1000; pozycjaRozmowcy[1] = -1000; kierunekRozmowcy = 0; czyRozmawiam = false; gracz = false; myBot = new AIMLbot.Bot(); myBot.loadSettings(); myBot.loadAIMLFromFiles(); //ustawiamy nasza energie na poczatkowa energie kazdego agenta w danym swiecie myEnergy = cennikSwiata.initialEnergy; if (tryb == "0") Zachowanie("Random"); if (tryb == "1") Zachowanie("SmartBot"); if (tryb == "2") { gracz = true; KeyReader(); } //na koncu rozlaczamy naszego agenta try { agentVLuke_Jones.Disconnect(); } catch (Exception e) { Console.WriteLine("Disconnected with problems! " + e.Message); } Console.ReadKey(); break; } //w przypadku mało poważnego błędu, jak podanie złego hasła, //rzucany jest wyjątek NonCriticalException; zaczynamy od nowa catch (NonCriticalException ex) { Console.WriteLine(ex.Message); } // w przypadku każdego innego wyjątku niż NonCriticalException //powinniśmy zakończyć program; taki wyjątek nie powinien się zdarzyć catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.ReadKey(); } } }
/// <summary> /// Ctor /// </summary> /// <param name="bot">The bot whose brain is being processed</param> public AIMLLoader(AIMLbot.Bot bot) { this.bot = bot; }
/// <summary> /// Ctor /// </summary> /// <param name="bot">The bot this sentence splitter is associated with</param> public SplitIntoSentences(AIMLbot.Bot bot) { this.bot = bot; }
/// <summary> /// Ctor /// </summary> /// <param name="bot">The bot this sentence splitter is associated with</param> /// <param name="inputString">The raw input string to be processed</param> public SplitIntoSentences(AIMLbot.Bot bot, string inputString) { this.bot = bot; this.inputString = inputString; }
public ApplySubstitutions(AIMLbot.Bot bot) : base(bot) { }
/// <summary> /// Default ctor for used as part of late binding mechanism /// </summary> public TextTransformer() { this.bot = null; this.inputString = string.Empty; }
public void setupMockBot() { this.mockBot = new AIMLbot.Bot(); }
/// <summary> /// Ctor /// </summary> /// <param name="bot">The bot for whom this is a settings dictionary</param> public SettingsDictionary(AIMLbot.Bot bot) { this.bot = bot; }
public StripIllegalCharacters(AIMLbot.Bot bot) : base(bot) { }
public MakeCaseInsensitive(AIMLbot.Bot bot, string inputString) : base(bot, inputString) { }
public MakeCaseInsensitive(AIMLbot.Bot bot) : base(bot) { }
public mockTextTransformer(AIMLbot.Bot bot) : base(bot) { }
public ApplySubstitutions(AIMLbot.Bot bot, string inputString) : base(bot, inputString) { }
public StripIllegalCharacters(AIMLbot.Bot bot, string inputString) : base(bot, inputString) { }