!7 cmodule GreeterBot > DynTalkBot { S msg = "Welcome ! Rules and regulations apply. And stuff."; long channelToGreetIn; start { useAGIBlueForDropPunctuation = false; preprocessAtSelfToMyName = false; dropPunctuation = false; } void onUserJoin(long userID, O... _) { S msg = replace(this.msg, "", discordAt(userID)); if (channelToGreetIn == 0) setField(channelToGreetIn := preferredChannelID); if (channelToGreetIn == 0) fail("Have no greeting channel"); postInChannel(channelToGreetIn, msg); } S processSimplifiedLine(S s, O... _) { try answer super.processSimplifiedLine(s, _); // adding authorized users etc. new Matches m; S sOld = s; s = dropPrefixOrNull(myPrefix(), s); if (s == null) { print("no got prefix: " + quote(myPrefix()) + " / " + quote(sOld)); null; } if (eqic(s, "prefer this channel")) { try answer checkAuth(_); long channelID = longPar channelID(_); if (channelID == 0) ret "No channel"; setField(channelToGreetIn := channelID); ret "OK, will greet here from now on."; } if (eqic(s, "simulate greeting")) { onUserJoin(longPar userID(_), _); ret "Greeting simulated"; } if (eqic(s, "get message")) ret msg; if (swic_trim(s, "set message:", m)) { try answer checkAuth(_); setField(msg := m.rest(); ret "Message changed to: " + msg; } if (eqic(s, "enable")) { try answer checkAuth(_); setField(enabled := true); ret "Enabled. Will greet every new arrival!"; } if (eqic(s, "disable")) { try answer checkAuth(_); setField(enabled := true); ret "Disabled. Will not greet anyone."; } if (eqic(s, "help")) ret trim([[ I am a simple greeter bot. Status: ]] + enabledDisabled(enabled) + [[. Commands: @me **simulate greeting** -- greet you to test the bot @me **get message** -- show current greeting message @me **set message: Hello ! Bla bla...** - change greeting. is replaced with user name @me **prefer this channel** -- posts greetings in the channel you write this in @me **enable/disable** -- enable/disable the auto-greeting @me **masters**/**add master**/**delete master** -- change bot ownership @me **source**/**support channel** -- see sources or join the support discord [Bot made by https://BotCompany.de] ]]).replace("@me", atSelf()); null; } }