~xenrox/twitch-bot

7b52156268ac18bb1493a99dddac4f1e4b53469b — Thorben Günther 1 year, 6 months ago b6898b6
commands list: Add built-in commands
2 files changed, 6 insertions(+), 1 deletions(-)

M faceit.go
M static_commands.go
M faceit.go => faceit.go +4 -0
@@ 155,3 155,7 @@ func (client *faceitClient) getPlayerInfo(url string) (*playerInfo, error) {

	return &player, nil
}

func faceitCommands() []string {
	return []string{"elo"}
}

M static_commands.go => static_commands.go +2 -1
@@ 15,7 15,6 @@ var errTooShort = errors.New("input too short")
func (b *bot) handleCommands(parsed []string, msg *twitch.PrivateMessage) error {
	if len(parsed) == 1 || parsed[1] == "list" {
		var commands []string
		// TODO: Add preconfigured commands like elo
		query := `
			SELECT name
			FROM static_commands


@@ 40,6 39,8 @@ func (b *bot) handleCommands(parsed []string, msg *twitch.PrivateMessage) error 
			return err
		}

		commands = append(commands, faceitCommands()...)

		var text string
		for i, command := range commands {
			text += fmt.Sprintf("!%s", command)