message parsing
This commit is contained in:
parent
7a69523b09
commit
6b5857d382
6 changed files with 257 additions and 28 deletions
|
@ -4,24 +4,30 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/Cynosphere/comcord/state"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
"github.com/fatih/color"
|
||||
"github.com/mgutz/ansi"
|
||||
)
|
||||
|
||||
const format string = " %s - %s%s"
|
||||
|
||||
func HelpCommand(session *discordgo.Session) {
|
||||
noColor := state.HasNoColor()
|
||||
|
||||
fmt.Println("\r\nCOMcord (c)left 2023\n\r")
|
||||
|
||||
index := 0
|
||||
for key, cmd := range GetAllCommands() {
|
||||
str := fmt.Sprintf(" %s - %s", key, cmd.Description)
|
||||
str := fmt.Sprintf(format, key, cmd.Description, "")
|
||||
length := len(str)
|
||||
padding := strings.Repeat(" ", 25 - length)
|
||||
|
||||
fmt.Print(" ")
|
||||
color.Set(color.FgYellow, color.Bold)
|
||||
fmt.Print(key)
|
||||
color.Unset()
|
||||
fmt.Printf(" - %s", cmd.Description)
|
||||
fmt.Print(strings.Repeat(" ", 25 - length))
|
||||
if noColor {
|
||||
fmt.Printf(format, key, cmd.Description, padding)
|
||||
} else {
|
||||
coloredKey := ansi.Color(key, "yellow+b")
|
||||
fmt.Printf(format, coloredKey, cmd.Description, padding)
|
||||
}
|
||||
|
||||
index++
|
||||
if index % 3 == 0 {
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/Cynosphere/comcord/lib"
|
||||
"github.com/Cynosphere/comcord/state"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
"github.com/ergochat/readline"
|
||||
|
@ -22,7 +23,10 @@ func SendMode(session *discordgo.Session) {
|
|||
length := len(session.State.User.Username) + 2
|
||||
curLength := state.GetNameLength()
|
||||
|
||||
prompt := fmt.Sprintf("%s[%s]%s%s", ansi.ColorCode("cyan+b"), session.State.User.Username, strings.Repeat(" ", (curLength - length) + 1), ansi.ColorCode("reset"))
|
||||
prompt := fmt.Sprintf("[%s]%s", session.State.User.Username, strings.Repeat(" ", (curLength - length) + 1))
|
||||
if !state.HasNoColor() {
|
||||
prompt = ansi.Color(prompt, "cyan+b")
|
||||
}
|
||||
|
||||
input, _ := readline.NewFromConfig(&readline.Config{
|
||||
Prompt: prompt,
|
||||
|
@ -51,4 +55,5 @@ func SendMode(session *discordgo.Session) {
|
|||
// TODO: update afk state
|
||||
}
|
||||
state.SetInPrompt(false)
|
||||
lib.ProcessQueue(session)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue