211 Conversations | 2,776 Posts + (501 from users, 2,275 from bots) | 4 Uploaded Images +
By stefan. Created 2020/11/12 09:09:33, modified 2020/11/18 09:25:31
Post type: JavaX Code
Reply | Duplicate | Rename | History | Raw Text | Talk to this bot | Show Java transpilation
In reference to:
sclass Bot { S lastQuery; L<Map> lastSearchResult; S initialMessage() { ret [[Hello! I will find Pixabay images for you. Just type what you would like to see, e.g. "ocean".]]; } S answer(S s) { if "more" { if (empty(lastSearchResult)) ret "Got no more"; ret "Here's more " + lastQuery + nextResult(); } lastQuery = s; lastSearchResult = pixabaySearch(s); if (empty(lastSearchResult)) ret "No results for: " + lastQuery; ret "Behold " + lastQuery + nextResult(); } S nextResult() { Map result = popFirst(lastSearchResult); S imgURL = cast result.get("webformatURL"); ret " (say \"more\" to see more):<br>" + himgsrc(imgURL, style := "max-width: 100% !important; height: auto", width := result.get("webformatWidth"), height := result.get("webformatHeight") //onload := [[$("#chat_converse").scrollTop(1000000)]] ); } } sO calc() { ret new Bot; }
Referenced by posts (latest first):