Libraryless. Click here for Pure Java version (2221L/14K/48K).
!752 static Map<S, S> definitions = new HashMap<S, S>(); p{ makeBot("Definition bot"); load("definitions"); } answer{ if(matchStart("define * : *", s, m)){ if(definitions.get(m.unq(0)) == null){ S def = s.replace("define " + m.unq(0) + " : ","" ); definitions.put(m.unq(0), def); save("definitions"); ret "Defined " + m.unq(0) + ". Definition: " + def; }else{ ret m.unq(0) + " is already defined. Definition: \"" + definitions.get(m.unq(0)) + "\""; } } if(matchStart("meaning of * is *", s, m)){ if(definitions.get(m.unq(0)) == null){ S def = s.replace("meaning of " + m.unq(0) + " is ","" ); definitions.put(m.unq(0), def); save("definitions"); ret "Defined " + m.unq(0) + ". Definition: " + def; }else{ ret m.unq(0) + " is already defined. Definition: \"" + definitions.get(m.unq(0)) + "\""; } } if(matchStart("get def *", s, m) || matchStart("what is the definition of *", s, m)){ if(definitions.get(m.unq(0)) == null){ ret "There is no such thing defined. Define it yourself with ```define * : *```"; }else{ ret "Definition of " + m.unq(0) + " is \"" + definitions.get(m.unq(0)) + "\""; } } if(matchStart("remove def *", s, m) || matchStart("undefine *", s, m)){ if(definitions.get(m.unq(0)) == null){ ret "The word " + m.unq(0) + " isn't defined."; }else{ definitions.remove(m.unq(0)); save("definitions"); ret "Removed " + m.unq(0) + " from definitions list."; } } if(matchStart("edit def * : *", s, m)){ if(definitions.get(m.unq(0)) == null){ ret "The word " + m.unq(0) + " isn't defined."; }else{ S def = s.replace("edit def " + m.unq(0) + " : ","" ); definitions.put(m.unq(0),def); save("definitions"); ret "Edited " + m.unq(0) + ". New definition: \"" + def + "\""; } } if(match("all defs", s) || match("list definitions", s) || match("list all definitions", s)){ if(definitions == null){ ret "There is nothing defined right now."; }else{ ret "Here is a list of definitions: ```"+definitions+"```"; } } if(match("list all defined words", s) || match("list defined words", s) || match("defkeys", s)){ if(definitions == null){ ret "There is nothing defined right now."; }else{ ret "These are all the defined words: ``` " + definitions.keySet() + " ```"; } } }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment