!7 concept Msg { long msgID, channelID, userID; long date, edited; // epochSeconds S text; } standardBot1 EAMBot { init { dbIndexing(Msg, 'msgID); } sync S processSimplifiedLine(S s, O... _) { try answer super.processSimplifiedLine(s, _); if ((s = dropMyPrefixOrNull(s)) == null) null; optPar MessageChannel channel; if "retrieve history" { MessageHistory history = channel.getHistory(); retrieveHistory(channel, history); ret "Retrieving..."; } null; } /*void postMsgs(MessageChannel channel, L msgs) { postInChannel(channel, linesLL( "Got " + nMessages(msgs) + ".", first(msgs), "...", last(msgs) )); }*/ void retrieveHistory(MessageChannel channel, MessageHistory history) { history.retrievePast(100).queue(msgs -> { if (empty(msgs)) ret with postInChannel(channel, "Done"); storeMsgs(msgs); retrieveHistory(channel, history); }, onQueueError); } void storeMsgs(L l) { for (Message msg : l) uniq(Msg, msgID := msg.getIdLong(), channelID := msg.getTextChannel().getIdLong(), userID := msg.getAuthor().getIdLong(), date := msg.getCreationTime().toEpochSecond(), edited := msg.isEdited() ? msg.getEditedTime().toEpochSecond() : 0, text := msg.getContentRaw()); } }