diff --git a/commands/commands.go b/commands/commands.go index d59d7e2b..23376817 100755 --- a/commands/commands.go +++ b/commands/commands.go @@ -227,62 +227,6 @@ var cmds = []Command{ }, Command: admin.GConfigServer, AdminOnly: true, PrimaryOnly: true}, /* MODERATOR COMMANDS ---------------- */ - {AppCmd: &discordgo.ApplicationCommand{ - Name: "change-mods", - Description: "MOD ONLY: Change game mods", - Type: discordgo.ChatApplicationCommand, - Options: []*discordgo.ApplicationCommandOption{ - { - Name: "add-mod", - Description: "attempt to add a mod by name", - Type: discordgo.ApplicationCommandOptionString, - Required: false, - }, - { - Name: "del-mod", - Description: "delete a mod by number from list-all", - Type: discordgo.ApplicationCommandOptionString, - Required: false, - }, - { - Name: "enable-mod", - Description: "enable a mod by number from list-all", - Type: discordgo.ApplicationCommandOptionString, - Required: false, - }, - { - Name: "disable-mod", - Description: "disable a mod by number from list-all", - Type: discordgo.ApplicationCommandOptionString, - Required: false, - }, - { - Name: "action", - Description: "List of possible actions.", - Type: discordgo.ApplicationCommandOptionString, - Required: false, - Choices: []*discordgo.ApplicationCommandOptionChoice{ - { - Name: "enable-all", - Value: "enable-all", - }, - { - Name: "disable-all", - Value: "disable-all", - }, - { - Name: "delete-all", - Value: "delete-all", - }, - { - Name: "show-list", - Value: "show-list", - }, - }, - }, - }, - }, - Command: moderator.ModManager, ModeratorOnly: true}, {AppCmd: &discordgo.ApplicationCommand{ Name: "rcon", Description: "MOD ONLY: remote console (remotely run a factorio command)", @@ -392,7 +336,7 @@ var cmds = []Command{ Options: []*discordgo.ApplicationCommandOption{ { Name: "options", - Description: "verbose shows all settings/info, list-mods shows all installed game mods.", + Description: "verbose shows all settings/info.", Type: discordgo.ApplicationCommandOptionString, Required: false, Choices: []*discordgo.ApplicationCommandOptionChoice{ @@ -400,14 +344,6 @@ var cmds = []Command{ Name: "verbose", Value: "verbose", }, - { - Name: "list-mods", - Value: "list-mods", - }, - { - Name: "debug", - Value: "debug", - }, }, }, }, diff --git a/commands/moderator/modManager.go b/commands/moderator/modManager.go deleted file mode 100644 index ca68d281..00000000 --- a/commands/moderator/modManager.go +++ /dev/null @@ -1,33 +0,0 @@ -package moderator - -import ( - "ChatWire/disc" - "ChatWire/fact" - "strings" - - "github.com/bwmarrin/discordgo" -) - -func ModManager(s *discordgo.Session, i *discordgo.InteractionCreate) { - a := i.ApplicationCommandData() - - options := 0 - for _, o := range a.Options { - options++ - if o.Type == discordgo.ApplicationCommandOptionString { - arg := o.StringValue() - if strings.EqualFold(arg, "delete-all") { - disc.EphemeralResponse(s, i, "Info:", "All mods deleted.") - return - } else if strings.EqualFold(arg, "show-list") { - options = -1 - } - } - } - if options == 0 || options == -1 { - buf, _ := fact.MakeModList() - disc.EphemeralResponse(s, i, "Mods available:", "```\n"+buf+"\n```") - } else { - disc.EphemeralResponse(s, i, "ERROR:", "Not implemented.") - } -} diff --git a/commands/user/newInfo.go b/commands/user/newInfo.go index 6b615995..5cb35405 100755 --- a/commands/user/newInfo.go +++ b/commands/user/newInfo.go @@ -36,19 +36,6 @@ func Info(s *discordgo.Session, i *discordgo.InteractionCreate) { str := arg.StringValue() if strings.EqualFold(str, "verbose") { verbose = true - } else if strings.EqualFold(str, "debug") { - if disc.CheckAdmin(i) { - debug = true - } else { - buf = buf + "Sorry, the debug option is admin-only.\n\n" - } - } else if strings.EqualFold(str, "list-mods") { - mList, err := fact.MakeModList() - if err != nil { - disc.EphemeralResponse(s, i, "Server Mods: (basic list)", strings.Join(fact.ModList, ", ")) - } else { - disc.EphemeralResponse(s, i, "Server Mods:", "```\n"+mList+"\n```") - } } } } diff --git a/fact/factUtils.go b/fact/factUtils.go index 1ece1fb5..bfa1e6c7 100755 --- a/fact/factUtils.go +++ b/fact/factUtils.go @@ -2,7 +2,6 @@ package fact import ( "archive/zip" - "encoding/json" "fmt" "io" "io/fs" @@ -24,173 +23,6 @@ import ( "ChatWire/sclean" ) -type infoJSONData struct { - Name string - Version string - Title string - Dependencies []string - Description string - Factorio_version string - Homepage string -} - -type modData struct { - Name string - Enabled bool -} - -type modListData struct { - Mods []modData -} - -func readInfoJson(content []byte) (*infoJSONData, bool) { - - info := &infoJSONData{} - err := json.Unmarshal(content, &info) - if err != nil { - cwlog.DoLogCW("readInfoJson: Unmarshal failure") - return nil, false - } - return info, true -} - -func readMod(filename string) (*infoJSONData, bool) { - read, err := zip.OpenReader(filename) - if err != nil { - cwlog.DoLogCW(err.Error()) - return nil, false - } - - for _, file := range read.File { - fc, err := file.Open() - if err != nil { - cwlog.DoLogCW(err.Error()) - return nil, false - } - fileName := filepath.Base(file.Name) - if fileName == "info.json" { - content, err := io.ReadAll(fc) - if err != nil { - cwlog.DoLogCW(err.Error()) - return nil, false - } - if len(content) > 0 { - return readInfoJson(content) - } else { - return nil, false - } - } - } - - return nil, false -} - -func readModList(path string) (*modListData, bool) { - - content, err := os.ReadFile(path + "mod-list.json") - if err != nil { - cwlog.DoLogCW(err.Error()) - return nil, false - } - - modList := &modListData{} - err = json.Unmarshal(content, &modList) - if err != nil { - cwlog.DoLogCW("readModList: Unmarshal failure") - return nil, false - } - - return modList, true -} - -func searchModlist(modList *modListData, modName string) (bool, bool) { - if modList != nil && modList.Mods != nil && modName != "" { - for _, mod := range modList.Mods { - if mod.Name == modName { - return true, true - } - } - return false, true - } - - return false, false -} - -func checkModLoaded(modName string) bool { - for _, mod := range ModList { - if mod == modName { - return true - } - } - return false -} -func MakeModList() (string, error) { - - path := cfg.Global.Paths.Folders.ServersRoot + - cfg.Global.Paths.ChatWirePrefix + - cfg.Local.Callsign + "/" + - cfg.Global.Paths.Folders.FactorioDir + "/" + - cfg.Global.Paths.Folders.Mods + "/" - - files, err := os.ReadDir(path) - /* We can't read saves dir */ - if err != nil { - cwlog.DoLogCW(err.Error()) - return "Error", err - } - - /* Loop all files */ - var tempf []fs.DirEntry - for _, f := range files { - //Hide non-zip files, temp files - if strings.HasSuffix(f.Name(), ".zip") { - tempf = append(tempf, f) - } - } - - modList, _ := readModList(path) - numFiles := len(tempf) - - buf := "" - count := 1 - for x := 0; x < numFiles; x++ { - file := tempf[x] - - number := fmt.Sprintf("#%3v ", count) - info, found := readMod(path + file.Name()) - if found { - buf = buf + number - foundMod, foundList := searchModlist(modList, info.Name) - - if foundList { - if foundMod { - buf = buf + "( ON) " - } else { - buf = buf + "(OFF) " - } - } else { - buf = buf + "( ? ) " - } - - if checkModLoaded(info.Name) { - buf = buf + "@" - } else { - buf = buf + " " - } - buf = buf + info.Name + " v" + info.Version - - } else { - buf = buf + number + "Filename: " + strings.TrimSuffix(file.Name(), ".zip") + " (corrupt mod file?)" - } - buf = buf + "\n" - count++ - } - if count == 0 { - buf = buf + "None." - } - return buf, err -} - func CheckSave(path, name string, showError bool) (good bool, folder string) { zip, err := zip.OpenReader(path + "/" + name) if err != nil || zip == nil { diff --git a/support/pipeHandle.go b/support/pipeHandle.go index 9974dd43..b0e905e1 100755 --- a/support/pipeHandle.go +++ b/support/pipeHandle.go @@ -558,39 +558,6 @@ func handleMapLoad(NoTC string, NoDSlist []string, NoTClist []string, NoTClistle return false } -func handleModLoad(NoTC string) bool { - /****************** - * LOADING MOD - ******************/ - if strings.HasPrefix(NoTC, "Loading mod") { - - if !strings.Contains(NoTC, "base") && - !strings.Contains(NoTC, "core") && - !strings.Contains(NoTC, "settings") { - - parts := strings.Split(NoTC, " ") - numParts := len(parts) - 1 - if numParts >= 4 { - - modName := strings.Join(parts[2:numParts-1], " ") - - found := false - for _, m := range fact.ModList { - if strings.EqualFold(m, modName) { - found = true - } - } - if !found { - fact.ModList = append(fact.ModList, modName) - cwlog.DoLogCW(NoTC) - } - } - } - } - /* Dont eat, factorio version handle uses this too */ - return false -} - func handleBan(NoDS string, NoDSlist []string, NoDSlistlen int) bool { /****************** * BAN diff --git a/support/pipeParse.go b/support/pipeParse.go index 3136ed00..644cba44 100755 --- a/support/pipeParse.go +++ b/support/pipeParse.go @@ -127,10 +127,6 @@ func HandleChat() { continue } - if handleModLoad(NoTC) { - continue - } - go handleBan(NoDS, NoDSlist, NoDSlistlen) if handleSVersion(line, lineList, lineListlen) {