Working with Go's Style Guide
This commit is contained in:
parent
216cb5d62d
commit
3266cc0f7e
26
bot.go
26
bot.go
@ -1,10 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/thoj/go-ircevent"
|
||||
"strings"
|
||||
"fmt"
|
||||
"github.com/thoj/go-ircevent"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Bot struct {
|
||||
@ -51,16 +51,22 @@ var argmap = map[string]int{
|
||||
}
|
||||
|
||||
func fillCharmap(nick string, cat string, item string, val string) {
|
||||
charmap = map[string]map[string]map[string]string { nick: map[string]map[string]string{ cat: map[string]string{ item: val, }, }, }
|
||||
charmap = map[string]map[string]map[string]string{
|
||||
nick: map[string]map[string]string{
|
||||
cat: map[string]string{
|
||||
item: val,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Bot) Command(nick string, msg string) {
|
||||
var args = make([]string, len(strings.Split(msg, " ")) - 1)
|
||||
var args = make([]string, len(strings.Split(msg, " "))-1)
|
||||
var command = ""
|
||||
|
||||
for i, j := range strings.Split(msg, " ") {
|
||||
if j != " " && i !=0 {
|
||||
args[i - 1] = strings.Split(msg, " ")[i]
|
||||
if j != " " && i != 0 {
|
||||
args[i-1] = strings.Split(msg, " ")[i]
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,7 +77,9 @@ func (b *Bot) Command(nick string, msg string) {
|
||||
}
|
||||
}
|
||||
|
||||
if argmap[strings.Split(msg, " ")[0]] != len(args) { return }
|
||||
if argmap[strings.Split(msg, " ")[0]] != len(args) {
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: Check if mode is enabled and if command can be applied.
|
||||
|
||||
@ -145,7 +153,9 @@ func (b *Bot) Say(msg string) {
|
||||
func (b *Bot) Listen() {
|
||||
err := b.Conn.Connect(b.Server)
|
||||
|
||||
if err != nil { panic(err) }
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
b.Conn.AddCallback("001", func(e *irc.Event) {
|
||||
b.Conn.Join(b.Channel)
|
||||
|
Loading…
Reference in New Issue
Block a user