MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / Server

Function Server

internal/usercommands/admin.server.go:33–312  ·  view source on GitHub ↗

* * Role Permissions: * server (All) */

(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag)

Source from the content-addressed store, hash-verified

31* server (All)
32 */
33func Server(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error) {
34
35 if rest == "" {
36 infoOutput, _ := templates.Process("admincommands/help/command.server", nil, user.UserId)
37 user.SendText(infoOutput)
38 return true, nil
39 }
40
41 args := util.SplitButRespectQuotes(rest)
42 if args[0] == "config" {
43 return server_Config(strings.TrimSpace(rest[6:]), user, room, flags)
44 }
45
46 if args[0] == "set" {
47
48 args = args[1:]
49
50 if len(args) < 1 {
51
52 user.SendText(``)
53
54 cfgData := configs.GetConfig().AllConfigData()
55 cfgKeys := make([]string, 0, len(cfgData))
56 for k := range cfgData {
57 cfgKeys = append(cfgKeys, k)
58 }
59
60 // sort the keys
61 slices.Sort(cfgKeys)
62
63 lastPrefix := ``
64 longestKey := 0
65
66 for _, k := range cfgKeys {
67 if len(k) > longestKey {
68 longestKey = len(k)
69 }
70 }
71
72 lineLength := 158 - longestKey
73
74 for _, k := range cfgKeys {
75 displayName := k
76 nameColorized := ``
77 if strings.Index(k, `.`) != -1 {
78 parts := strings.Split(k, `.`)
79 if len(parts) > 1 {
80 if lastPrefix != parts[0] {
81 lastPrefix = parts[0]
82 user.SendText(``)
83 }
84 nameColorized = `<ansi fg="yellow">` + parts[0] + `.</ansi>`
85 displayName = strings.Join(parts[1:], `.`)
86 }
87 }
88 extraSpace := strings.Repeat(` `, longestKey-len(k))
89
90 user.SendText(`<ansi fg="yellow-bold">` + nameColorized + displayName + `</ansi>: <ansi fg="red-bold">` + extraSpace + util.SplitStringNL(fmt.Sprintf(`%v`, cfgData[k]), lineLength, strings.Repeat(` `, longestKey+2)) + `</ansi>`)

Callers

nothing calls this directly

Calls 15

ProcessFunction · 0.92
SplitButRespectQuotesFunction · 0.92
GetConfigFunction · 0.92
SplitStringNLFunction · 0.92
SetToDayFunction · 0.92
GetDateFunction · 0.92
SetToNightFunction · 0.92
SetValFunction · 0.92
LoadAliasesFunction · 0.92
SetAnsiFlagFunction · 0.92
GetServerAddressFunction · 0.92
GetTimeTrackersFunction · 0.92

Tested by

no test coverage detected