From fdbfd92405ea6c87ecdd803cdd384161c76f9106 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Ross Date: Thu, 26 Apr 2018 21:31:22 -0400 Subject: [PATCH] Simple bot response on thread messages. --- threads/plugin.go | 19 +++++++++++++++++++ threads/threads.go | 17 +++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 threads/plugin.go create mode 100644 threads/threads.go diff --git a/threads/plugin.go b/threads/plugin.go new file mode 100644 index 0000000..c7a015a --- /dev/null +++ b/threads/plugin.go @@ -0,0 +1,19 @@ +package threads + +import ( + "github.com/abourget/slick" +) + +type Plugin struct { + bot *slick.Bot +} + +func init() { + slick.RegisterPlugin(&Plugin{}) +} + +func (p *Plugin) InitPlugin(bot *slick.Bot) { + p.bot = bot + + p.listenThreads() +} diff --git a/threads/threads.go b/threads/threads.go new file mode 100644 index 0000000..7574fd9 --- /dev/null +++ b/threads/threads.go @@ -0,0 +1,17 @@ +package threads + +import ( + "github.com/abourget/slick" +) + +func (p *Plugin) listenThreads() { + p.bot.Listen(&slick.Listener{ + MessageHandlerFunc: p.handleThreads, + }) +} + +func (p *Plugin) handleThreads(listen *slick.Listener, msg *slick.Message) { + if msg.ThreadTimestamp != "" { + msg.Reply("Can I haz no threadz plz!") + } +}