diff --git a/bees/discordbee/discordbee.go b/bees/discordbee/discordbee.go index 75ed3bfe..2a5124fc 100644 --- a/bees/discordbee/discordbee.go +++ b/bees/discordbee/discordbee.go @@ -73,7 +73,7 @@ func (mod *DiscordBee) isReady(s *discordgo.Session, event *discordgo.Ready) { // Default status - once the persistance layer exists: // TODO: Persist status, use it here. mod.LogDebugf("isReady called") - s.UpdateStatus(0, "with bees") + s.UpdateGameStatus(0, "with bees") } func (mod *DiscordBee) onSend(s *discordgo.Session, event *discordgo.MessageCreate) { @@ -130,11 +130,25 @@ func (mod *DiscordBee) Action(action bees.Action) []bees.Placeholder { if err != nil { mod.LogErrorf("Unable to send message: %v", err) } + case "send_news": + var contents string + var channelID string + action.Options.Bind("contents", &contents) + action.Options.Bind("channel_id", &channelID) + + message, err := mod.discord.ChannelMessageSend(channelID, contents) + if err != nil { + mod.LogErrorf("Unable to send message: %v", err) + } + _, err = mod.discord.ChannelMessageCrosspost(channelID, message.ID) + if err != nil { + mod.LogErrorf("Unable to publish message: %v", err) + } case "set_status": var status string action.Options.Bind("status", &status) - err := mod.discord.UpdateStatus(0, status) + err := mod.discord.UpdateGameStatus(0, status) if err != nil { mod.LogErrorf("Unable to update status: %v", err) } diff --git a/bees/discordbee/discordbeefactory.go b/bees/discordbee/discordbeefactory.go index c3f2da30..dc7e8de9 100644 --- a/bees/discordbee/discordbeefactory.go +++ b/bees/discordbee/discordbeefactory.go @@ -135,6 +135,25 @@ func (factory *DiscordBeeFactory) Actions() []bees.ActionDescriptor { }, }, }, + { + Namespace: factory.Name(), + Name: "send_news", + Description: "Sends a message to a news channel and publishes it", + Options: []bees.PlaceholderDescriptor{ + { + Name: "contents", + Description: "Contents of the message", + Type: "string", + Mandatory: true, + }, + { + Name: "channel_id", + Description: "ID of the channel to post in", + Type: "string", + Mandatory: true, + }, + }, + }, { Namespace: factory.Name(), Name: "set_status", diff --git a/go.mod b/go.mod index 9331bac6..8bd1e063 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/asaskevich/EventBus v0.0.0-20180315140547-d46933a94f05 // indirect github.com/azr/backoff v0.0.0-20160115115103-53511d3c7330 // indirect github.com/briandowns/openweathermap v0.0.0-20180804155945-5f41b7c9d92d - github.com/bwmarrin/discordgo v0.19.0 + github.com/bwmarrin/discordgo v0.23.1 github.com/carlosdp/twiliogo v0.0.0-20161027183705-b26045ebb9d1 github.com/cloudflare/cloudflare-go v0.10.6 github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f @@ -50,6 +50,7 @@ require ( github.com/jpillora/backoff v1.0.0 // indirect github.com/json-iterator/go v1.1.6 // indirect github.com/kelvins/sunrisesunset v0.0.0-20170601204625-14f1915ad4b4 + github.com/kevinburke/go-bindata v3.22.0+incompatible // indirect github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect github.com/kr/pretty v0.1.0 github.com/kurrik/oauth1a v0.0.0-20151019171716-cb1b80e32dd4 // indirect diff --git a/go.sum b/go.sum index 847fba22..27947828 100644 --- a/go.sum +++ b/go.sum @@ -29,8 +29,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLM github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/briandowns/openweathermap v0.0.0-20180804155945-5f41b7c9d92d h1:28xWzPQ9bdGxKAAwQpZipZZ9Xz8kQcgMPF9cZnvMeuI= github.com/briandowns/openweathermap v0.0.0-20180804155945-5f41b7c9d92d/go.mod h1:8g1Bgq9PbPpXIA3sdlWmWf2JpiWGJee/O4Q+ddYO6+k= -github.com/bwmarrin/discordgo v0.19.0 h1:kMED/DB0NR1QhRcalb85w0Cu3Ep2OrGAqZH1R5awQiY= -github.com/bwmarrin/discordgo v0.19.0/go.mod h1:O9S4p+ofTFwB02em7jkpkV8M3R0/PUVOwN61zSZ0r4Q= +github.com/bwmarrin/discordgo v0.23.1 h1:xlK4/69bpl/VSoCYaKe3BOc9j1HkNopoRdCppRYu8dk= +github.com/bwmarrin/discordgo v0.23.1/go.mod h1:c1WtWUGN6nREDmzIpyTp/iD3VYt4Fpx+bVyfBG7JE+M= github.com/carlosdp/twiliogo v0.0.0-20161027183705-b26045ebb9d1 h1:hXakhQtPnXH839q1pBl/GqfTSchqE+R5Fqn98Iu7UQM= github.com/carlosdp/twiliogo v0.0.0-20161027183705-b26045ebb9d1/go.mod h1:pAxCBpjl/0JxYZlWGP/Dyi8f/LQSCQD2WAsG/iNzqQ8= github.com/cloudflare/cloudflare-go v0.10.6 h1:mbv0IrcrrLlPLxAzCdW6aQ/CPlqhyXrXTjviU0Tb+34= @@ -126,6 +126,8 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/kelvins/sunrisesunset v0.0.0-20170601204625-14f1915ad4b4 h1:8GEzGYjqXcb1PW2RFrkbsv7Gzq4v9ykbjy6lUc9nbnM= github.com/kelvins/sunrisesunset v0.0.0-20170601204625-14f1915ad4b4/go.mod h1:3oZ7G+fb8Z8KF+KPHxeDO3GWpEjgvk/f+d/yaxmDRT4= +github.com/kevinburke/go-bindata v3.22.0+incompatible h1:/JmqEhIWQ7GRScV0WjX/0tqBrC5D21ALg0H0U/KZ/ts= +github.com/kevinburke/go-bindata v3.22.0+incompatible/go.mod h1:/pEEZ72flUW2p0yi30bslSp9YqD9pysLxunQDdb2CPM= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=