!7 set flag DynModule. // for evals cmodule Gazelle2 > DynDiscordHopper { S myName = "Gazelle"; transient new ThreadLocal msgMap; // while answering @Override S answer(S s, Map map) { new Matches m; temp tempSetTL(msgMap, map); long ch = getLong channelID(map); long userID = getLong userID(map); s = simpleSpaces_javaTok(s); if "what's your name" ret myName; if (swic_trim(s, myName + ", show me ", m)) { iAmTyping(map); S query = m.rest(); BufferedImage img = quickVisualize(query); if (img == null) ret "No image found, sorry!"; postImage(map, uploadToImageServer(img, query)); null; } if (swic_trim(s, myName + ", look up ", m)) { if (isSingleWord($1)) try answer wordNet_pretty($1); ret ":cry: I don't know"; } if (ellipsisToDotStarRegexpFindIC("days...year", collapse(s))) ret nDays(daysUntilEndOfYear()) + " till end of year"; S content = s; try { if (swicOneOf(content, "!eval ", "!fresh ", "!real-eval", "!safe-eval ") || eqic(content, "!fresh")) { O safetyCheck = null; bool authed = dm_discord_userCanEval(userID); print("Authed " + userID + " => " + authed); if (swic_trim(content, "!safe-eval ", m)) { content = "!eval " + m.rest(); authed = false; } /*if (regexpMatches("![a-z\\-]+\\s+again", content)) { GazelleLine last = dm_discord_nextToLastEvalByUser(userID); if (last == null) ret "No last eval found"; content = replaceSuffix("again", afterSpace(last.text), content); }*/ if (!authed) safetyCheck = botEval_strictSafetyCheck(); iAmTyping(map); dm_bot_execEvalCmd(voidfunc(S s) { if (s != null) postInChannel(ch, shorten(ifEmpty(s, [[""]]), 1000)) }, content, +safetyCheck); null; } } catch print error { postInChannel(ch, exceptionToStringShort(error)); } ret super.answer(s, map); } // for evals with gazelle_msg() Message respondingTo() { ret (Message) get msg(msgMap!); } MessageChannel currentChannel() { ret (MessageChannel) get channel(msgMap!); } }