Libraryless. Click here for Pure Java version (1244L/9K/29K).
!752 static S chatName = "Eleu"; static int maxAnswerLength = 300; p { thread "Web Chat Bot" { toChat(); } } static void toChat() { while (licensed()) { pcall { for (ChatLine l : suckHumans(chatName)) sayInWebChat(chatName, _answer(l)); } sleep(1000); } } static S _answer(ChatLine l) { S s = l.text; s = s.trim(); // if (s.startsWith("!")) ((ThreadLocal) get(getMainBot(), "attn")).set(true); s = dropPrefix("!", s); ((ThreadLocal) get(getMainBot(), "userName")).set(l.auth ? "stefanreich" : null); // hack for authing S a = askSelf(s); if (empty(a)) ret null; S userName = l.who; // post long stuff to tinybrain instead if (l(a) > maxAnswerLength) { S q = s; S title = "Answer for " + userName + " (>> " + q + ")"; S id = ntUpload("eleutheria-for-user", title, unSlackSnippet(a)); int shortenTo = maxAnswerLength; a = shorten(a, shortenTo) + "\nFull answer here: #" + parseSnippetID(id); } ret a = "@" + l.who + " " + a; }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment