Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
feat(plugins): add owncast.server.emotes() for custom chat emotes
Gabe Kangas21f74914790b
diff --git a/pluginhost/pluginhost.go b/pluginhost/pluginhost.goindex 577ff3fe62..885cd457a3 100644--- a/pluginhost/pluginhost.go+++ b/pluginhost/pluginhost.go@@ -996,6 +996,25 @@ func wireServerReadHostFns(env *plugins.HostEnv, deps Deps) {return out}+ // Emotes exposes the server's custom chat emotes (the same set the public+ // /api/emoji endpoint serves) so plugins can render or filter `:code:`+ // emotes server-side. URLs are server-relative, matching /api/emoji.+ env.Emotes = func() []plugins.Emote {+ list := datastore.GetEmojiList()+ out := make([]plugins.Emote, 0, len(list))+ for _, e := range list {+ emote := plugins.Emote{}+ if e.Name != nil {+ emote.Name = *e.Name+ }+ if e.Url != nil {+ emote.URL = *e.Url+ }+ out = append(out, emote)+ }+ return out+ }+env.Federation = func() plugins.FederationInfo {return plugins.FederationInfo{Enabled: cfg.GetFederationEnabled(),diff --git a/services/plugins/hostfns.go b/services/plugins/hostfns.goindex b6f6337abd..ef2d706315 100644--- a/services/plugins/hostfns.go+++ b/services/plugins/hostfns.go@@ -156,6 +156,13 @@ type SocialHandle struct {Icon string `json:"icon,omitempty"`}+// Emote is one custom chat emote returned by owncast.server.emotes(): the+// `:code:` chat clients substitute and the URL of the image it renders to.+type Emote struct {+ Name string `json:"name"`+ URL string `json:"url"`+}+// FederationInfo is what owncast.server.federation() returns.type FederationInfo struct {Enabled bool `json:"enabled"`@@ -278,6 +285,7 @@ type HostEnv struct {FSDelete func(pluginName, path string) errorFSExists func(pluginName, path string) (bool, error)Socials func() []SocialHandle // server.read+ Emotes func() []Emote // server.readFederation func() FederationInfo // server.read// WriteVideoConfig applies a partial video/transcoding configuration// change. Returns an error the plugin can see if the host rejects the@@ -344,6 +352,7 @@ func BuildHostFunctions(env *HostEnv, manifest *Manifest) []extism.HostFunctionhostStreamCurrent(env),hostServerInfo(env),hostServerSocials(env),+ hostServerEmotes(env),hostServerFederation(env),hostStreamBroadcaster(env),hostServerTags(env),@@ -725,6 +734,36 @@ func hostServerSocials(env *HostEnv) extism.HostFunction {return fn}+func hostServerEmotes(env *HostEnv) extism.HostFunction {+ fn := extism.NewHostFunctionWithStack(+ "owncast_server_emotes",+ func(ctx context.Context, p *extism.CurrentPlugin, stack []uint64) {+ var emotes []Emote+ if env.Emotes != nil {+ emotes = env.Emotes()+ }+ if emotes == nil {+ emotes = []Emote{}+ }+ data, err := json.Marshal(emotes)+ if err != nil {+ stack[0] = 0+ return+ }+ offset, err := p.WriteBytes(data)+ if err != nil {+ stack[0] = 0+ return+ }+ stack[0] = offset+ },+ []extism.ValueType{},+ []extism.ValueType{extism.ValueTypePTR},+ )+ fn.SetNamespace("extism:host/user")+ return fn+}+func hostServerFederation(env *HostEnv) extism.HostFunction {fn := extism.NewHostFunctionWithStack("owncast_server_federation",diff --git a/services/plugins/plugin-contract.json b/services/plugins/plugin-contract.jsonindex c42386a20d..4800363fc6 100644--- a/services/plugins/plugin-contract.json+++ b/services/plugins/plugin-contract.json@@ -44,6 +44,7 @@"owncast_send_chat_action","owncast_send_chat_system","owncast_send_chat_to",+ "owncast_server_emotes","owncast_server_federation","owncast_server_info","owncast_server_socials",@@ -66,6 +67,10 @@"title": "string","url": "string"},+ "Emote": {+ "name": "string",+ "url": "string"+ },"FederationInfo": {"enabled": "bool","isPrivate": "bool",