2017-10-31 10:22:36 +00:00
|
|
|
package rpgORdie
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/velour/catbase/bot"
|
|
|
|
"github.com/velour/catbase/bot/msg"
|
|
|
|
)
|
|
|
|
|
|
|
|
type RPGPlugin struct {
|
2017-10-31 13:40:03 +00:00
|
|
|
Bot bot.Bot
|
2017-10-31 18:14:45 +00:00
|
|
|
listenFor map[string]bool
|
2017-10-31 10:22:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func New(b bot.Bot) *RPGPlugin {
|
|
|
|
return &RPGPlugin{
|
2017-10-31 13:40:03 +00:00
|
|
|
Bot: b,
|
2017-10-31 18:14:45 +00:00
|
|
|
listenFor: map[string]bool{},
|
2017-10-31 10:22:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *RPGPlugin) Message(message msg.Message) bool {
|
|
|
|
if strings.ToLower(message.Body) == "start rpg" {
|
2017-10-31 13:40:03 +00:00
|
|
|
ts := p.Bot.SendMessage(message.Channel, "I'll edit this.")
|
2017-10-31 10:22:36 +00:00
|
|
|
|
2017-10-31 18:14:45 +00:00
|
|
|
p.listenFor[ts] = true
|
|
|
|
|
2017-10-31 10:22:36 +00:00
|
|
|
time.Sleep(2 * time.Second)
|
|
|
|
|
|
|
|
edited := ""
|
|
|
|
for i := 0; i <= 5; i++ {
|
|
|
|
p.Bot.Edit(message.Channel, edited, ts)
|
|
|
|
edited += ":fire:"
|
2017-10-31 18:14:45 +00:00
|
|
|
time.Sleep(500 * time.Millisecond)
|
2017-10-31 10:22:36 +00:00
|
|
|
}
|
|
|
|
p.Bot.Edit(message.Channel, "HECK YES", ts)
|
2017-10-31 14:07:20 +00:00
|
|
|
|
2017-10-31 14:16:41 +00:00
|
|
|
p.Bot.ReplyToMessageIdentifier(message.Channel, "How's this reply?", ts)
|
2017-10-31 18:14:45 +00:00
|
|
|
return true
|
2017-10-31 10:22:36 +00:00
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *RPGPlugin) LoadData() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *RPGPlugin) Help(channel string, parts []string) {
|
|
|
|
p.Bot.SendMessage(channel, "Go find a walkthrough or something.")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *RPGPlugin) Event(kind string, message msg.Message) bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *RPGPlugin) BotMessage(message msg.Message) bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *RPGPlugin) RegisterWeb() *string {
|
|
|
|
return nil
|
|
|
|
}
|
2017-10-31 18:14:45 +00:00
|
|
|
|
|
|
|
func (p *RPGPlugin) ReplyMessage(message msg.Message, identifier string) bool {
|
|
|
|
if strings.ToLower(message.User.Name) != strings.ToLower(p.Bot.Config().Nick) {
|
|
|
|
if _, ok := p.listenFor[identifier]; ok {
|
|
|
|
p.Bot.ReplyToMessageIdentifier(message.Channel, "Pong", identifier)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|