diff options
| author | Xe Iaso <me@xeiaso.net> | 2024-10-18 12:47:08 -0400 |
|---|---|---|
| committer | Xe Iaso <me@xeiaso.net> | 2024-10-18 12:47:08 -0400 |
| commit | c758d20777cfbccfe02115c78dc9c24c836ea17d (patch) | |
| tree | 52133bfe4072b2cc017f3c540b2afc70d6b04ae5 /cmd/mimi/modules | |
| parent | dcc841e8eb84fb4e098a69c685dcf491124a6954 (diff) | |
| download | x-c758d20777cfbccfe02115c78dc9c24c836ea17d.tar.xz x-c758d20777cfbccfe02115c78dc9c24c836ea17d.zip | |
cmd/mimi/modules/irc: implement Post service
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'cmd/mimi/modules')
| -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 +} |
