luxAHKfor/flag.ahk

183 lines
2.8 KiB
AutoHotkey
Raw Normal View History

2021-01-22 22:30:17 -06:00
#SingleInstance force ; Only one instance at a time
FileEncoding, UTF-8 ; Makes sure special characters dont break stuff
global userID := "userID from the desktop software webhook page"
If (A_Args[1] = "off")
{
off()
ExitApp
}
if A_Args[3] is number
{
length := A_Args[3]
} else
{
length := 0
}
Switch A_Args[1]
{
Case "s":
solid(A_Args[2], length)
Case "b":
blink(A_Args[2], length)
Case "p":
patt(A_Args[2], length)
}
2021-01-26 11:07:46 -06:00
solid(input, length := 0)
2021-01-22 22:30:17 -06:00
{
Switch input
{
Case "red", "green", "yellow", "blue", "white", "cyan", "magenta":
json_str =
(
{
"userId": "%userID%",
"actionFields":{
"color": "%input%"
}
}
)
Default:
json_str =
(
{
"userId": "%userID%",
"actionFields":{
"color": "custom",
"custom_color": "%input%"
}
}
)
}
translate("https://api.luxafor.com/webhook/v1/actions/solid_color", json_str, length)
2021-01-26 11:07:46 -06:00
ExitApp
2021-01-22 22:30:17 -06:00
}
2021-01-26 11:07:46 -06:00
blink(input, length := 0)
2021-01-22 22:30:17 -06:00
{
If (length = 0)
{
length := 1000000
}
Switch input
{
Case "red", "green", "yellow", "blue", "white", "cyan", "magenta":
color := input
Default:
MsgBox % input " is not an accepted input"
ExitApp
}
json_str =
(
{
"userId": "%userID%",
"actionFields":{
"color": "%color%"
}
}
)
translate("https://api.luxafor.com/webhook/v1/actions/blink", json_str, length)
2021-01-26 11:07:46 -06:00
ExitApp
2021-01-22 22:30:17 -06:00
}
2021-01-26 11:07:46 -06:00
patt(input, length := 0)
2021-01-22 22:30:17 -06:00
{
If (length = 0)
{
length := 1000000
}
Switch input
{
Case "police", "rainbow", "sea", "synthetic":
pattern := input
Case "traffic_lights":
pattern := "traffic lights"
Case "white_wave":
pattern := "white wave"
Case "random":
Random, rando, 1, 5
pattern := "random " rando
Case "random1":
pattern := "random 1"
Case "random2":
pattern := "random 2"
Case "random3":
pattern := "random 3"
Case "random4":
pattern := "random 4"
Case "random5":
pattern := "random 5"
Default:
MsgBox % input " is not an accepted input"
ExitApp
}
json_str =
(
{
"userId": "%userID%",
"actionFields":{
"pattern": "%pattern%"
}
}
)
translate("https://api.luxafor.com/webhook/v1/actions/pattern", json_str, length)
2021-01-26 11:07:46 -06:00
ExitApp
2021-01-22 22:30:17 -06:00
}
translate(url, data, length)
{
If (length = 0)
{
req(url, data)
2021-01-26 11:07:46 -06:00
Goto, tEnd
2021-01-22 22:30:17 -06:00
} Else {
time_to_run := length * 1000
start_time := A_TickCount
end_time := start_time + time_to_run
while (A_tickcount < end_time) {
req(url, data)
}
}
If (InStr(url, "solid"))
{
Sleep, (length * 1000)
off()
}
2021-01-26 11:07:46 -06:00
tEnd:
2021-01-22 22:30:17 -06:00
}
off()
{
data =
(
{
"userId": "%userID%",
"actionFields":{
"color": "custom",
"custom_color": "000000"
}
}
)
url := "https://api.luxafor.com/webhook/v1/actions/solid_color"
req(url, data)
}
req(url, data)
{
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("POST", url, false)
whr.SetRequestHeader("Content-Type", "application/json")
whr.Send(data)
whr.WaitForResponse()
}