diff options
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/mimi/modules/irc/announcer.go | 3 | ||||
| -rw-r--r-- | cmd/mimi/modules/irc/post.go | 23 |
2 files changed, 26 insertions, 0 deletions
diff --git a/cmd/mimi/modules/irc/announcer.go b/cmd/mimi/modules/irc/announcer.go index 9eb83a5..d3979cf 100644 --- a/cmd/mimi/modules/irc/announcer.go +++ b/cmd/mimi/modules/irc/announcer.go @@ -22,8 +22,11 @@ var ( func (m *Module) RegisterHTTP(mux *http.ServeMux) { var h http.Handler = announce.NewAnnounceServer(&AnnounceService{Module: m}) h = xinternal.PasswordMiddleware(*ircAnnouncerUsername, *ircAnnouncerPassword, h) + var postH http.Handler = announce.NewPostServer(&PostService{Module: m}) + postH = xinternal.PasswordMiddleware(*ircAnnouncerUsername, *ircAnnouncerPassword, postH) mux.Handle(announce.AnnouncePathPrefix, h) + mux.Handle(announce.PostPathPrefix, postH) } type AnnounceService struct { diff --git a/cmd/mimi/modules/irc/post.go b/cmd/mimi/modules/irc/post.go new file mode 100644 index 0000000..e80bd34 --- /dev/null +++ b/cmd/mimi/modules/irc/post.go @@ -0,0 +1,23 @@ +package irc + +import ( + "context" + + "github.com/twitchtv/twirp" + "google.golang.org/protobuf/types/known/emptypb" + "within.website/x/proto/mimi/announce" +) + +type PostService struct { + *Module +} + +func (a *PostService) Post(ctx context.Context, su *announce.StatusUpdate) (*emptypb.Empty, error) { + a.conn.Privmsgf(*ircChannel, "%s", su.Body) + + if _, err := a.dg.ChannelMessageSend(*discordPOSSEAnnounceChannel, su.Body); err != nil { + return nil, twirp.InternalErrorWith(err).WithMeta("step", "discord") + } + + return &emptypb.Empty{}, nil +} |
