Skip to content

Commit

Permalink
Discordbee crosspost (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
LecygneNoir authored Jun 13, 2021
1 parent 2fce343 commit dfc6fd3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
18 changes: 16 additions & 2 deletions bees/discordbee/discordbee.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}
Expand Down
19 changes: 19 additions & 0 deletions bees/discordbee/discordbeefactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down

0 comments on commit dfc6fd3

Please sign in to comment.