Fixing things to be 80-chars wide

This commit is contained in:
Chris Sexton 2013-01-24 10:20:15 -05:00
parent 130e471c8e
commit 544ed0e092
1 changed files with 16 additions and 11 deletions

View File

@ -1,7 +1,5 @@
package plugins package plugins
import "bitbucket.org/phlyingpenguin/godeepintir/bot"
import ( import (
"fmt" "fmt"
"labix.org/v2/mgo" "labix.org/v2/mgo"
@ -9,6 +7,8 @@ import (
"strings" "strings"
) )
import "bitbucket.org/phlyingpenguin/godeepintir/bot"
// This is a counter plugin to count arbitrary things. // This is a counter plugin to count arbitrary things.
type CounterPlugin struct { type CounterPlugin struct {
@ -31,8 +31,9 @@ func NewCounterPlugin(bot *bot.Bot) *CounterPlugin {
} }
// Message responds to the bot hook on recieving messages. // Message responds to the bot hook on recieving messages.
// This function returns true if the plugin responds in a meaningful way to the users message. // This function returns true if the plugin responds in a meaningful way to the
// Otherwise, the function returns false and the bot continues execution of other plugins. // users message. Otherwise, the function returns false and the bot continues
// execution of other plugins.
func (p *CounterPlugin) Message(message bot.Message) bool { func (p *CounterPlugin) Message(message bot.Message) bool {
// This bot does not reply to anything // This bot does not reply to anything
nick := message.User.Name nick := message.User.Name
@ -82,7 +83,8 @@ func (p *CounterPlugin) Message(message bot.Message) bool {
p.Coll.Remove(bson.M{"nick": subject, "item": itemName}) p.Coll.Remove(bson.M{"nick": subject, "item": itemName})
p.Bot.SendAction(channel, fmt.Sprintf("chops a few %s out of his brain", itemName)) p.Bot.SendAction(channel, fmt.Sprintf("chops a few %s out of his brain",
itemName))
return true return true
@ -109,7 +111,8 @@ func (p *CounterPlugin) Message(message bot.Message) bool {
return true return true
} }
p.Bot.SendMessage(channel, fmt.Sprintf("%s has %d %s.", subject, item.Count, itemName)) p.Bot.SendMessage(channel, fmt.Sprintf("%s has %d %s.", subject, item.Count,
itemName))
return true return true
} else if len(parts) == 1 { } else if len(parts) == 1 {
@ -119,12 +122,14 @@ func (p *CounterPlugin) Message(message bot.Message) bool {
if strings.HasSuffix(parts[0], "++") { if strings.HasSuffix(parts[0], "++") {
// ++ those fuckers // ++ those fuckers
item := p.update(subject, itemName, 1) item := p.update(subject, itemName, 1)
p.Bot.SendMessage(channel, fmt.Sprintf("You have %d %s, %s.", item.Count, item.Item, nick)) p.Bot.SendMessage(channel, fmt.Sprintf("You have %d %s, %s.", item.Count,
item.Item, nick))
return true return true
} else if strings.HasSuffix(parts[0], "--") { } else if strings.HasSuffix(parts[0], "--") {
// -- those fuckers // -- those fuckers
item := p.update(subject, itemName, -1) item := p.update(subject, itemName, -1)
p.Bot.SendMessage(channel, fmt.Sprintf("You have %d %s, %s.", item.Count, item.Item, nick)) p.Bot.SendMessage(channel, fmt.Sprintf("You have %d %s, %s.", item.Count,
item.Item, nick))
return true return true
} }
} }
@ -151,9 +156,9 @@ func (p *CounterPlugin) update(subject, itemName string, delta int) Item {
return item return item
} }
// LoadData imports any configuration data into the plugin. This is not strictly necessary other // LoadData imports any configuration data into the plugin. This is not
// than the fact that the Plugin interface demands it exist. This may be deprecated at a later // strictly necessary other than the fact that the Plugin interface demands it
// date. // exist. This may be deprecated at a later date.
func (p *CounterPlugin) LoadData() { func (p *CounterPlugin) LoadData() {
// This bot has no data to load // This bot has no data to load
} }