Skip to content

Commit 9456064

Browse files
committed
Add Discord messaging.
Signed-off-by: elModo7 <elmodo7yt@gmail.com>
1 parent 412844f commit 9456064

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
;~ ; The idea is to have a list of webhooks name => wh to select from in the config
2+
#NoEnv
3+
#SingleInstance Force
4+
SetBatchLines -1
5+
global buttonName = %0%
6+
global buttonPath := buttonName ".ahk"
7+
SkinForm(Apply, A_ScriptDir . "\lib\them.dll", A_ScriptDir . "\lib\tm")
8+
OnExit, GetOut
9+
Gui Add, Text, x32 y10 w80 h23 +0x200, Webhook URL:
10+
Gui Add, Edit, x112 y10 w220 h21 vsource
11+
Gui Add, Text, x32 y43 w72 h23 +0x200, Message:
12+
Gui Add, Edit, x32 y65 w300 h200 vmsg
13+
Gui, Font, Bold
14+
Gui Add, Button, x230 y270 w100 h23, Create Button
15+
Gui Show, w339 h300, New Discord MSG
16+
wh_url := "https://discord.com/api/webhooks/<your-webhook-api-here>"
17+
return
18+
19+
20+
GetOut:
21+
GuiEscape:
22+
GuiClose:
23+
SkinForm(0)
24+
ExitApp
25+
26+
#If WinActive("Hide / Show Source")
27+
Enter::
28+
GuiControlGet, source,, source
29+
GuiControlGet, show,, show
30+
if(source = "")
31+
{
32+
MsgBox 0x10, Error, No source selected!
33+
return
34+
}
35+
else if(workingDir = "")
36+
{
37+
workingDir := A_Desktop
38+
}
39+
visibility := "false"
40+
if(show){
41+
visibility := "true"
42+
}
43+
if FileExist(buttonPath)
44+
{
45+
OnMessage(0x44, "OnMsgBox")
46+
MsgBox 0x34, Overwrite?, This button already has a macro file`, do you want to overwrite it?`n`nPrevious function will be lost!
47+
OnMessage(0x44, "")
48+
49+
IfMsgBox Yes, {
50+
Generar(source, visibility)
51+
}
52+
}
53+
else
54+
{
55+
Generar(source, wh_url)
56+
}
57+
return
58+
#If
59+
60+
Generar(msg, wh_url)
61+
{
62+
src :=
63+
(
64+
"#NoEnv
65+
#NoTrayIcon
66+
#SingleInstance, Force
67+
SetBatchLines, -1
68+
SendDiscordMessage(""" msg """, """ wh_url """)
69+
70+
SendDiscordMessage(msg, wh_url)
71+
{
72+
json_str = {""content"": """ msg """}
73+
WebClient := ComObjCreate(""WinHttp.WinHttpRequest.5.1"")
74+
WebClient.Open(""POST"", wh_url, false)
75+
WebClient.SetRequestHeader(""Content-Type"", ""application/json"")
76+
WebClient.SetProxy(false)
77+
WebClient.Send(json_str)
78+
}"
79+
)
80+
FileDelete, % buttonPath
81+
FileAppend, %src%, % buttonPath
82+
ExitApp
83+
}
84+
85+
SkinForm(Param1 = "Apply", DLL = "", SkinName = ""){
86+
if(Param1 = Apply){
87+
DllCall("LoadLibrary", str, DLL)
88+
DllCall(DLL . "\USkinInit", Int,0, Int,0, AStr, SkinName)
89+
}else if(Param1 = 0){
90+
DllCall(DLL . "\USkinExit")
91+
}
92+
}

0 commit comments

Comments
 (0)