abstract sclass AbstractTelegramThinkBot > DynPrintLog { abstract void thinkAbout(S input); transient int lookback = 3; // old lines to grab transient int maxCharsPerMessage = 2000; transient int maxLinesPerMessage = 20; transient Set<S> toSend; transient LatestList<Map> recentHistory; // only called when not in test mode start { loadFunctions_preferCached(); dm_useLocallyCopiedMechLists(); recentHistory = new LatestList(lookback); recentHistory.addAll(map_pcall unstructureUnquote(dropLast(lastNLines(lookback, telegramLogFile())))); watchStructureLog_plusLastLine(500, telegramLogFile(), voidfunc(final Map map) { temp tempAfterwards(r { recentHistory.add(map) }); if (!eqGet(map, 'type, 'heard)) ret; printStruct(map); try { setThreadLocal((ThreadLocal) getOptMC('makeAndCall_initChild), voidfunc(Class c) { copyFields(mc(), c, 'telegram_msg_tl, 'telegram_recentHistory_tl) }); temp tempSetThreadLocal(telegram_msg_tl(), map); temp tempSetThreadLocal(telegram_recentHistory_tl(), recentHistory); S s = getString(map, 'text); toSend = new LinkedHashSet; thinkAbout(s); for (S out : takeFirst(3, getAndClearList(toSend))) { Long chatID = (Long) _get(map, 'where); S globalID = isTrue(_get(map, 'fromVoice)) ? telegram_postVoiceMessageToSendLog(out, "Andy", chatID) : telegram_postToSendLog(out, chatID); if (globalID != null) recentHistory.add(litmap(text := out, globalID)); } } catch e { printStackTrace(e); postMessage(exceptionToStringShort(e)); } }); } void postMessage(S s) { s = shortenToMaxLinesAndChars(rtrim(s), maxLinesPerMessage, maxCharsPerMessage); print("Sending: " + s); toSend.add(s); } }
Began life as a copy of #1017568
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1017582 |
| Snippet name: | AbstractTelegramThinkBot |
| Eternal ID of this version: | #1017582/30 |
| Text MD5: | 486e5f7042620b6031dc79fa7bb96af1 |
| Author: | stefan |
| Category: | javax / telegram |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-08-29 12:44:08 |
| Source code size: | 1949 bytes / 53 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 735 / 1376 |
| Version history: | 29 change(s) |
| Referenced in: | [show references] |