mirror of
https://github.com/valmojr/armatak.git
synced 2026-06-13 13:23:28 +00:00
initial main dll extension using a3go as template
This commit is contained in:
42
extensions/armatak/data.go
Normal file
42
extensions/armatak/data.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package main
|
||||
|
||||
type Mission struct {
|
||||
MissionName string `json:"missionName"`
|
||||
Worldname string `json:"worldname"`
|
||||
MissionAuthor string `json:"missionAuthor"`
|
||||
MissionType string `json:"missionType"`
|
||||
Victory string `json:"victory"`
|
||||
MissionStart string `json:"missionStart"`
|
||||
MissionEnd string `json:"missionEnd"`
|
||||
Date string `json:"date"`
|
||||
ScoreBlue string `json:"scoreBlue"`
|
||||
ScoreRed string `json:"scoreRed"`
|
||||
ScoreGreen string `json:"scoreGreen"`
|
||||
Players []Player `json:"players"`
|
||||
Kills []Kill `json:"kills"`
|
||||
FPS []float64 `json:"fps"`
|
||||
}
|
||||
|
||||
type Player struct {
|
||||
UID string `json:"uid"`
|
||||
Name string `json:"name"`
|
||||
Side string `json:"side"`
|
||||
Shots int `json:"shots"`
|
||||
Hits int `json:"hits"`
|
||||
Squad string `json:"squad"`
|
||||
Role string `json:"role"`
|
||||
Class string `json:"class"`
|
||||
}
|
||||
|
||||
type Kill struct {
|
||||
Time string `json:"time"`
|
||||
Victim string `json:"victim"`
|
||||
Killer string `json:"killer"`
|
||||
Weapon string `json:"weapon"`
|
||||
Distance string `json:"distance"`
|
||||
}
|
||||
|
||||
type DiscordPayload struct {
|
||||
Content string `json:"content"`
|
||||
Username string `json:"username,omitempty"` // Optional field
|
||||
}
|
||||
5
extensions/armatak/go.mod
Normal file
5
extensions/armatak/go.mod
Normal file
@@ -0,0 +1,5 @@
|
||||
module statsLoggerExtension
|
||||
|
||||
go 1.20
|
||||
|
||||
require github.com/indig0fox/a3go v0.2.1
|
||||
2
extensions/armatak/go.sum
Normal file
2
extensions/armatak/go.sum
Normal file
@@ -0,0 +1,2 @@
|
||||
github.com/indig0fox/a3go v0.2.1 h1:Ixr/182pGd5qPbFYgHINWt5YtyKaO7Yo/va/17nF/Vg=
|
||||
github.com/indig0fox/a3go v0.2.1/go.mod h1:8htVwBiIAVKpT1Jyb+5dm7GuLAAevTXgw7UKxSlOawY=
|
||||
79
extensions/armatak/main.go
Normal file
79
extensions/armatak/main.go
Normal file
@@ -0,0 +1,79 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path"
|
||||
|
||||
"github.com/indig0fox/a3go/a3interface"
|
||||
"github.com/indig0fox/a3go/assemblyfinder"
|
||||
)
|
||||
|
||||
// modulePath is the absolute path to the compiled DLL, which should be the addon folder
|
||||
var modulePath string = assemblyfinder.GetModulePath()
|
||||
|
||||
// modulePathDir is the containing folder
|
||||
var modulePathDir string = path.Dir(modulePath)
|
||||
|
||||
var EXTENSION_NAME = "STATS_LOGGER"
|
||||
|
||||
var mission Mission
|
||||
|
||||
var RVExtensionChannels = map[string]chan string{
|
||||
":timeNow:": make(chan string),
|
||||
}
|
||||
|
||||
var RVExtensionArgsChannels = map[string]chan []string{
|
||||
":RESET:": make(chan []string),
|
||||
":MISSION:": make(chan []string),
|
||||
":WIN:": make(chan []string),
|
||||
":PLAYER:": make(chan []string),
|
||||
":KILL:": make(chan []string),
|
||||
":SHOT:": make(chan []string),
|
||||
":HIT:": make(chan []string),
|
||||
":EXPORT:": make(chan []string),
|
||||
":FPS:": make(chan []string),
|
||||
}
|
||||
|
||||
var a3ErrorChan = make(chan error)
|
||||
|
||||
func init() {
|
||||
a3interface.SetVersion("1.0.0")
|
||||
a3interface.RegisterRvExtensionArgsChannels(RVExtensionArgsChannels)
|
||||
|
||||
webhookURL := "YOUR_WEBHOOK_URL"
|
||||
|
||||
// Create the payload with the message
|
||||
payload := DiscordPayload{
|
||||
Content: "Hello World!",
|
||||
}
|
||||
|
||||
// Convert the payload to JSON format
|
||||
jsonData, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
fmt.Println("Error marshalling payload:", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Create a POST request to the Discord webhook URL
|
||||
req, err := http.Post(webhookURL, "application/json", bytes.NewReader(jsonData))
|
||||
if err != nil {
|
||||
fmt.Println("Error creating request:", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Close the request body
|
||||
defer req.Body.Close()
|
||||
|
||||
// Check the response status code
|
||||
if req.StatusCode != http.StatusOK {
|
||||
fmt.Println("Error sending request:", req.Status)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Scanln()
|
||||
}
|
||||
Reference in New Issue
Block a user