예제 #1
0
        public string ExpandFormat(string subj, string relation, object value, bool isQuery, SettingsDictionary dictionary, Unifiable formatter, XmlNode templateNode)
        {
            string pred = Entify(relation);

            string botName = !IsBotRobot(subj) ? Entify(TheBot.BotUserID) : Entify(TheBot.LastUser.UserID);
            {
                var whword = GetDictValue(dictionary, relation, "format-whword");

                if (!Unifiable.IsNullOrEmpty(whword) && isQuery)
                {
                    value = whword;
                }
                var formatterUpper = Unifiable.ToUpper(formatter);
                if (Unifiable.IsFalseOrNo(formatterUpper))
                {
                    return("false");
                }

                formatter = ReplaceWord(formatter, "$subject", "{0}");
                formatter = ReplaceWord(formatter, "$verb", "{1}");
                formatter = ReplaceWord(formatter, "$object", "{2}");

                formatter = ReplaceWord(formatter, "$user", "{0}");
                formatter = ReplaceWord(formatter, "$relation", "{1}");
                formatter = ReplaceWord(formatter, "$value", "{2}");

                formatter = ReplaceWord(formatter, "$predicate", pred);

                formatter = ReplaceWord(formatter, "$set-return",
                                        TheBot.RelationMetaProps.grabSetting(relation + "." + "set-return"));
                formatter = ReplaceWord(formatter, "$default", TheBot.DefaultPredicates.grabSetting(relation));

                formatter = ReplaceWord(formatter, "$botname", botName);
                formatter = ReplaceWord(formatter, "$bot", botName);
            }

            string english = " " + String.Format(formatter, subj, pred, Entify(value)).Trim() + " ";

            english = ReplaceWord(english, "I", subj);
            english = ReplaceWord(english, "you", botName);
            english = english.Trim();
            User user = TheBot.FindUser(subj);

            english = FixPronouns(english, user.grabSettingNoDebug);
            return(english);
        }