!759 static class PerUser { S dialogID; S name; } static new Map perUserMap; // key = dialogID static new ThreadLocal puCurrent; p { load("perUserMap"); makeBot("User Name Bot"); } synchronized answer { if (!attn ()) null; // init per-user stuff S dialogID = getDialogID(); if (dialogID == null) ret null; // need a dialog id to proceed PerUser pu = perUserMap.get(dialogID); if (pu == null) { pu = new PerUser; pu.dialogID = dialogID; printFormat("Created new dialog: *", dialogID); perUserMap.put(dialogID, pu); } puCurrent.set(pu); if (matchStart("my name is", s, m) || matchStart("i am", s, m) || matchStart("you can call me", s, m) || matchStart("call me", s, m) || matchStart("they call me", s, m) || matchStart("my friends call me", s, m)) { pu.name = unquote(m.rest().trim()); save("perUserMap"); ret "Hello " + pu.name + "!"; } if (match("who am i?", s) || match("eleu what's my name", s)) { if (nempty(pu.name)) ret "You are " + pu.name + "."; ret "I don't know, stranger. Who are you?"; } } static synchronized S getUserName() { PerUser pu = perUserMap.get(getDialogID()); ret pu == null ? null : pu.name; }