mirror of https://github.com/velour/catbase.git
go fmt
This commit is contained in:
parent
f164530359
commit
c639d460ac
|
@ -77,7 +77,7 @@ func (b *bot) ReplyToMessageIdentifier(channel, message, identifier string) (str
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *bot) ReplyToMessage(channel, message string, replyTo msg.Message) (string, bool) {
|
func (b *bot) ReplyToMessage(channel, message string, replyTo msg.Message) (string, bool) {
|
||||||
return b.conn.ReplyToMessage(channel, message, replyTo)
|
return b.conn.ReplyToMessage(channel, message, replyTo)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *bot) React(channel, reaction string, message msg.Message) bool {
|
func (b *bot) React(channel, reaction string, message msg.Message) bool {
|
||||||
|
|
|
@ -12,12 +12,12 @@ type Log Messages
|
||||||
type Messages []Message
|
type Messages []Message
|
||||||
|
|
||||||
type Message struct {
|
type Message struct {
|
||||||
User *user.User
|
User *user.User
|
||||||
Channel, Body string
|
Channel, Body string
|
||||||
Raw string
|
Raw string
|
||||||
Command bool
|
Command bool
|
||||||
Action bool
|
Action bool
|
||||||
Time time.Time
|
Time time.Time
|
||||||
Host string
|
Host string
|
||||||
AdditionalData map[string]string
|
AdditionalData map[string]string
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ type Config struct {
|
||||||
Sightings []string
|
Sightings []string
|
||||||
}
|
}
|
||||||
Emojify struct {
|
Emojify struct {
|
||||||
Chance float64
|
Chance float64
|
||||||
Scoreless []string
|
Scoreless []string
|
||||||
}
|
}
|
||||||
Reaction struct {
|
Reaction struct {
|
||||||
|
|
|
@ -42,9 +42,9 @@ type Irc struct {
|
||||||
config *config.Config
|
config *config.Config
|
||||||
quit chan bool
|
quit chan bool
|
||||||
|
|
||||||
eventReceived func(msg.Message)
|
eventReceived func(msg.Message)
|
||||||
messageReceived func(msg.Message)
|
messageReceived func(msg.Message)
|
||||||
replyMessageReceived func(msg.Message, string)
|
replyMessageReceived func(msg.Message, string)
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(c *config.Config) *Irc {
|
func New(c *config.Config) *Irc {
|
||||||
|
|
|
@ -265,7 +265,6 @@ func TestBabblerBadMiddleOutSeed(t *testing.T) {
|
||||||
assert.Equal(t, mb.Messages[0], "seabass never said 'anything true'")
|
assert.Equal(t, mb.Messages[0], "seabass never said 'anything true'")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func TestBabblerBatch(t *testing.T) {
|
func TestBabblerBatch(t *testing.T) {
|
||||||
mb := bot.NewMockBot()
|
mb := bot.NewMockBot()
|
||||||
c := New(mb)
|
c := New(mb)
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
package reaction
|
package reaction
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/velour/catbase/bot"
|
"github.com/velour/catbase/bot"
|
||||||
"github.com/velour/catbase/bot/msg"
|
"github.com/velour/catbase/bot/msg"
|
||||||
|
@ -12,7 +12,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type ReactionPlugin struct {
|
type ReactionPlugin struct {
|
||||||
Bot bot.Bot
|
Bot bot.Bot
|
||||||
Config *config.Config
|
Config *config.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ func New(bot bot.Bot) *ReactionPlugin {
|
||||||
rand.Seed(time.Now().Unix())
|
rand.Seed(time.Now().Unix())
|
||||||
|
|
||||||
return &ReactionPlugin{
|
return &ReactionPlugin{
|
||||||
Bot: bot,
|
Bot: bot,
|
||||||
Config: bot.Config(),
|
Config: bot.Config(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ func (p *ReactionPlugin) Message(message msg.Message) bool {
|
||||||
numPositiveReactions := len(p.Config.Reaction.PositiveReactions)
|
numPositiveReactions := len(p.Config.Reaction.PositiveReactions)
|
||||||
numNegativeReactions := len(p.Config.Reaction.NegativeReactions)
|
numNegativeReactions := len(p.Config.Reaction.NegativeReactions)
|
||||||
|
|
||||||
maxIndex := numPositiveReactions + numNegativeReactions * negativeWeight
|
maxIndex := numPositiveReactions + numNegativeReactions*negativeWeight
|
||||||
|
|
||||||
index := rand.Intn(maxIndex)
|
index := rand.Intn(maxIndex)
|
||||||
|
|
||||||
|
|
|
@ -38,10 +38,10 @@ func (c *cacheItem) getCurrentPage(maxLines int) string {
|
||||||
|
|
||||||
page := strings.Join(c.data[start:end], "\n")
|
page := strings.Join(c.data[start:end], "\n")
|
||||||
|
|
||||||
if end - start == maxLines {
|
if end-start == maxLines {
|
||||||
c.currentLine = end
|
c.currentLine = end
|
||||||
} else {
|
} else {
|
||||||
c.currentLine = maxLines-(end-start)
|
c.currentLine = maxLines - (end - start)
|
||||||
page += "\n"
|
page += "\n"
|
||||||
page += strings.Join(c.data[0:c.currentLine], "\n")
|
page += strings.Join(c.data[0:c.currentLine], "\n")
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type YourPlugin struct {
|
type YourPlugin struct {
|
||||||
bot bot.Bot
|
bot bot.Bot
|
||||||
config *config.Config
|
config *config.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ type YourPlugin struct {
|
||||||
func New(bot bot.Bot) *YourPlugin {
|
func New(bot bot.Bot) *YourPlugin {
|
||||||
rand.Seed(time.Now().Unix())
|
rand.Seed(time.Now().Unix())
|
||||||
return &YourPlugin{
|
return &YourPlugin{
|
||||||
bot: bot,
|
bot: bot,
|
||||||
config: bot.Config(),
|
config: bot.Config(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,8 +230,8 @@ func (s *Slack) SendMessageType(channel, message string, meMessage bool) (string
|
||||||
type MessageResponse struct {
|
type MessageResponse struct {
|
||||||
OK bool `json:"ok"`
|
OK bool `json:"ok"`
|
||||||
Timestamp string `json:"ts"`
|
Timestamp string `json:"ts"`
|
||||||
Message struct {
|
Message struct {
|
||||||
BotID string `json:"bot_id"`
|
BotID string `json:"bot_id"`
|
||||||
} `json:"message"`
|
} `json:"message"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue