From 3e7f8d42485fb5ba052dace9a6b39475cff4b32c Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Sat, 25 Aug 2012 00:49:48 -0400 Subject: [PATCH] Reduced the messages on the console --- bot/bot.go | 4 ++-- bot/handlers.go | 10 +++++----- config/config.go | 3 +++ main.go | 2 +- plugins/beers.go | 6 +++--- plugins/plugins.go | 5 ++--- plugins/remember.go | 4 ++-- plugins/skeleton.go | 2 +- plugins/talker.go | 4 ++-- 9 files changed, 21 insertions(+), 19 deletions(-) diff --git a/bot/bot.go b/bot/bot.go index 8651a3b..e8b0c76 100644 --- a/bot/bot.go +++ b/bot/bot.go @@ -44,9 +44,9 @@ type User struct { type Message struct { User *User Channel, Body string - Raw string + Raw string Command bool - Action bool + Action bool } // NewBot creates a Bot for a given connection and set of handlers. diff --git a/bot/handlers.go b/bot/handlers.go index 3c8d329..c5752ce 100644 --- a/bot/handlers.go +++ b/bot/handlers.go @@ -87,7 +87,7 @@ func (b *Bot) isCmd(message string) (bool, string) { } // Builds our internal message type out of a Conn & Line from irc -func (b *Bot)buildMessage(conn *irc.Conn, line *irc.Line) Message { +func (b *Bot) buildMessage(conn *irc.Conn, line *irc.Line) Message { // Check for the user user := b.checkuser(line.Nick) @@ -114,9 +114,9 @@ func (b *Bot)buildMessage(conn *irc.Conn, line *irc.Line) Message { User: user, Channel: channel, Body: filteredMessage, - Raw: message, + Raw: message, Command: iscmd, - Action: isaction, + Action: isaction, } return msg } @@ -125,7 +125,7 @@ func (b *Bot)buildMessage(conn *irc.Conn, line *irc.Line) Message { func (b *Bot) MsgRecieved(conn *irc.Conn, line *irc.Line) { msg := b.buildMessage(conn, line) - if strings.HasPrefix(msg.Body, "help") && msg.Command{ + if strings.HasPrefix(msg.Body, "help") && msg.Command { parts := strings.Fields(strings.ToLower(msg.Body)) b.checkHelp(msg.Channel, parts) return @@ -169,4 +169,4 @@ func (b *Bot) UserJoined(conn *irc.Conn, line *irc.Line) { break } } -} \ No newline at end of file +} diff --git a/config/config.go b/config/config.go index 7b70454..3ff39a7 100644 --- a/config/config.go +++ b/config/config.go @@ -34,5 +34,8 @@ func Readconfig(version, cfile string) *Config { panic(err) } c.Version = version + + fmt.Printf("godeepintir version %s running.\n") + return &c } diff --git a/main.go b/main.go index 20f4481..9838db6 100644 --- a/main.go +++ b/main.go @@ -21,7 +21,6 @@ func main() { flag.Parse() // parses the logging flags. config := config.Readconfig(Version, *cfile) - fmt.Println(config) c := irc.SimpleClient(config.Nick) // Optionally, enable SSL @@ -33,6 +32,7 @@ func main() { func(conn *irc.Conn, line *irc.Line) { for _, channel := range config.Channels { conn.Join(channel) + fmt.Printf("Now talking in %s.\n", channel) } }) // And a signal on disconnect diff --git a/plugins/beers.go b/plugins/beers.go index abf08ff..a798577 100644 --- a/plugins/beers.go +++ b/plugins/beers.go @@ -5,10 +5,10 @@ import ( "fmt" "labix.org/v2/mgo" "labix.org/v2/mgo/bson" + "math/rand" "strconv" "strings" "time" - "math/rand" ) // This is a skeleton plugin to serve as an example and quick copy/paste for new plugins. @@ -130,7 +130,7 @@ func (p *BeersPlugin) Message(message bot.Message) bool { } // Empty event handler because this plugin does not do anything on event recv -func (p *BeersPlugin) Event(kind string, message bot.Message) bool { +func (p *BeersPlugin) Event(kind string, message bot.Message) bool { return false } @@ -199,4 +199,4 @@ func (p *BeersPlugin) doIKnow(nick string) bool { func (p *BeersPlugin) randomReply(channel string) { replies := []string{"ZIGGY! ZAGGY!", "HIC!", "Stay thirsty, my friend!"} p.Bot.SendMessage(channel, replies[rand.Intn(len(replies))]) -} \ No newline at end of file +} diff --git a/plugins/plugins.go b/plugins/plugins.go index 0be6647..9e74538 100644 --- a/plugins/plugins.go +++ b/plugins/plugins.go @@ -57,7 +57,7 @@ func (p *TestPlugin) Help(message bot.Message) { } // Empty event handler because this plugin does not do anything on event recv -func (p *TestPlugin) Event(kind string, message bot.Message) bool { +func (p *TestPlugin) Event(kind string, message bot.Message) bool { return false } @@ -91,7 +91,6 @@ func (fp FalsePlugin) LoadData() { } // Empty event handler because this plugin does not do anything on event recv -func (p *FalsePlugin) Event(kind string, message bot.Message) bool { +func (p *FalsePlugin) Event(kind string, message bot.Message) bool { return false } - diff --git a/plugins/remember.go b/plugins/remember.go index 62861ff..a24e58f 100644 --- a/plugins/remember.go +++ b/plugins/remember.go @@ -64,7 +64,7 @@ func (p *RememberPlugin) Message(message bot.Message) bool { return true } - for i := len(p.Log[message.Channel])-1; i >= 0; i-- { + for i := len(p.Log[message.Channel]) - 1; i >= 0; i-- { entry := p.Log[message.Channel][i] // find the entry we want fmt.Printf("Comparing '%s' to '%s'\n", entry.Raw, snip) @@ -159,6 +159,6 @@ func (p *RememberPlugin) quoteTimer(channel string) { } // Empty event handler because this plugin does not do anything on event recv -func (p *RememberPlugin) Event(kind string, message bot.Message) bool { +func (p *RememberPlugin) Event(kind string, message bot.Message) bool { return false } diff --git a/plugins/skeleton.go b/plugins/skeleton.go index c61a41a..32f6bbf 100644 --- a/plugins/skeleton.go +++ b/plugins/skeleton.go @@ -36,6 +36,6 @@ func (p *SkeletonPlugin) Help(channel string, parts []string) { } // Empty event handler because this plugin does not do anything on event recv -func (p *SkeletonPlugin) Event(kind string, message bot.Message) bool { +func (p *SkeletonPlugin) Event(kind string, message bot.Message) bool { return false } diff --git a/plugins/talker.go b/plugins/talker.go index 902315b..8fe1664 100644 --- a/plugins/talker.go +++ b/plugins/talker.go @@ -2,8 +2,8 @@ package plugins import ( "bitbucket.org/phlyingpenguin/godeepintir/bot" - "strings" "fmt" + "strings" ) type TalkerPlugin struct { @@ -44,7 +44,7 @@ func (p *TalkerPlugin) Help(channel string, parts []string) { } // Empty event handler because this plugin does not do anything on event recv -func (p *TalkerPlugin) Event(kind string, message bot.Message) bool { +func (p *TalkerPlugin) Event(kind string, message bot.Message) bool { if kind == "JOIN" && message.User.Name != p.Bot.Config.Nick { msg := fmt.Sprintf("Joins upset the hivemind's OCD, %s.", message.User.Name) p.Bot.SendMessage(message.Channel, msg)