1+ /*
2+ * Copyright 2025 Lambda
3+ *
4+ * This program is free software: you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation, either version 3 of the License, or
7+ * (at your option) any later version.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+ package com.lambda.module.modules.chat
19+
20+ import com.google.common.collect.Comparators.min
21+ import com.lambda.event.events.ChatEvent
22+ import com.lambda.event.listener.SafeListener.Companion.listen
23+ import com.lambda.module.Module
24+ import com.lambda.module.tag.ModuleTag
25+ import com.lambda.util.NamedEnum
26+
27+ object CustomChat : Module(
28+ name = " CustomChat" ,
29+ description = " Adds a custom ending to your message" ,
30+ tag = ModuleTag .CHAT ,
31+ ) {
32+ private val decoration by setting(" Decoration" , Decoration .Separator )
33+ private val text by setting(" Text" , Text .Lambda )
34+
35+ private val customText by setting(" Custom Text" , " " ) { text == Text .Custom }
36+
37+ init {
38+ listen<ChatEvent .Send > {
39+ val message = " ${it.message} ${decoration.block(text.block())} "
40+ it.message = message.take(min(256 , message.length))
41+ }
42+ }
43+
44+ enum class Decoration (val block : (String ) -> String ) {
45+ Separator ({ " | $it " }),
46+ Classic ({ " \u00ab $it \u00bb " }),
47+ None ({ it })
48+ }
49+
50+ private enum class Text (override val displayName : String , val block : () -> String ) : NamedEnum {
51+ Lambda (" Lambda" , { " ʟᴀᴍʙᴅᴀ" }),
52+ LambdaOnTop (" Lambda On Top" , { " ʟᴀᴍʙᴅᴀ ᴏɴ ᴛᴏᴘ" }),
53+ KamiBlue (" Kami Blue" , { " ᴋᴀᴍɪ ʙʟᴜᴇ" }),
54+ LambdaWebsite (" Lambda Website" , { " lambda-client.org" }),
55+ Custom (" Custom" , { customText })
56+ }
57+ }
0 commit comments