Skip to content

Commit

Permalink
Add support for custom messages in Discord sender
Browse files Browse the repository at this point in the history
  • Loading branch information
augyteo committed Feb 1, 2025
1 parent 00361fd commit 7d1cfc9
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions discord/discord-sender.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ messages := Map(
"CNY", "Happy Lunar New Year! 🧧",
"Xmas", "Merry Christmas! 🎄",
"Morning", "Good Morning! ☀️",
"Test", "Test Message 🧪"
"Test", "Test Message 🧪",
"Custom", "" ; Empty value for custom message
)

; Create instructions.txt
Expand Down Expand Up @@ -46,16 +47,34 @@ ddl := myGui.Add("DropDownList", "vMsgChoice w150", keys)
myGui.Add("Button", "Default w80", "OK").OnEvent("Click", ProcessInput)
myGui.Show()

ProcessInput(*)
{
ProcessInput(*) {
global
myGui.Submit()
selectedMsg := ddl.Text
myGui.Destroy()

; Handle Custom Message input
if (selectedMsg = "Custom") {
customGui := Gui()
customGui.Title := "Custom Message"
customGui.Add("Text",, "Enter your custom message:")
customEdit := customGui.Add("Edit", "w300 r5")
customGui.Add("Button", "Default w80", "OK").OnEvent("Click", (*) => customGui.Submit())
customGui.Show()

WinWaitClose(customGui)
msgText := Trim(customEdit.Value)

if (msgText = "") {
MsgBox("Custom message cannot be empty!", "Error", "Iconx")
ExitApp
}
} else {
msgText := messages[selectedMsg]
}

; Use selected message file
selectedFile := selectedMsg "-people.txt"
msgText := messages[selectedMsg]

; Read from selected file
content := FileRead(selectedFile)
Expand Down

0 comments on commit 7d1cfc9

Please sign in to comment.