!7
sS mainBotID = #1026248;
static int maxTypos = 1;
sS adminTitle = "Chat Bot Admin";
sS shortLink = null; // catchy link to admin if available
sS embedderLink = "http://imager.site/"; // where chat bot will go
sS goDaddyEmbedCode = [["]];
static Cache> consistencyCheckResult = new(lambda0 consistencyCheck);
concept Category {
int index;
S name;
}
concept Language {
int index;
S code;
}
concept QA {
int index;
S language;
S questions; // line by line
S patterns; // to be determined
S answers; // one answer, or "random { answers separated by empty lines }"
S category; // "business", "smalltalk"
sS _fieldOrder = "language category index questions patterns answers";
}
concept Defaults {
S lastLanguage;
}
concept Settings {
S contactFormViberID;
bool botOn, botAutoOpen;
}
p {
print("fieldOrder", getFieldOrder(QA));
dbIndexing(Language, 'index, Category, 'index);
indexSingletonConcept(Defaults);
indexSingletonConcept(Settings);
// languages, default language
cset(conceptsWhere QA(language := null), language := 'en);
uniq(Language, code := 'en);
removeConceptsWhere(Language, code := 'de);
// categories, default category
int i = 0;
for (S category : ll("business", "smalltalk"))
cset(uniq(Category, name := category), index := i++);
cset(conceptsWhere QA(category := null), category := "business");
onConceptsChange(r { consistencyCheckResult.clear(); });
reindexQAs();
}
html {
// force auth
try answer callHtmlMethod(getBot(mainBotID), "/auth-only", mapPlus(
params, uri := rawLink(uri)));
if (eq(uri, "/demo"))
ret hrefresh("https://smart-iptv-solutions.co.uk/?bot=1");
if (eq(uri, "/download"))
ret subBot_serveText(conceptsStructure());
if (eq(uri, "/embedCode"))
ret htitle_h2("Chat bot embed code")
+ (empty(goDaddyEmbedCode) ? "" :
h3("GoDaddy Site Builder")
+ p("Add a HTML box with this code:")
+ pre(htmlEncode2(goDaddyEmbedCode))
+ h3("Other"))
+ p("Add this code in front of your " + tt(htmlEncode2("