Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0c4db76
Update dependencies
PPTide Jan 13, 2025
116d065
These are only local keys :p
PPTide Jan 13, 2025
9fa87a7
regenerate from proto file and use in devzat
PPTide Jan 28, 2025
6a361bb
update go devzatapi
PPTide Jan 28, 2025
d16be88
Update dependencies
PPTide Jan 13, 2025
e607636
These are only local keys :p
PPTide Jan 13, 2025
db4b0e9
regenerate from proto file and use in devzat
PPTide Jan 28, 2025
c865efb
update go devzatapi
PPTide Jan 28, 2025
edaf240
Merge remote-tracking branch 'mine/rpc-add-options-for-bridge' into r…
PPTide Jan 28, 2025
edabe3c
foo (trigger deploy)
quackduck Feb 26, 2025
a7ac1a0
don't send plugin messages to plugins so they don't go into an infini…
PPTide Mar 1, 2025
4adb355
update the go devzatapi to not break active uses
PPTide Mar 1, 2025
6898e2b
middleware messages should be changed before being sent to discord/slack
PPTide Mar 1, 2025
f820f5c
add better description to "plugin message loops"
PPTide Mar 10, 2025
b59df40
Merge pull request #249 from PPTide/update-dependencies
Arkaeriit Mar 11, 2025
5b7c752
Update dependencies
PPTide Jan 13, 2025
d744243
These are only local keys :p
PPTide Jan 13, 2025
82b20a5
regenerate from proto file and use in devzat
PPTide Jan 28, 2025
541814d
update go devzatapi
PPTide Jan 28, 2025
2871df8
don't send plugin messages to plugins so they don't go into an infini…
PPTide Mar 1, 2025
96b339d
update the go devzatapi to not break active uses
PPTide Mar 1, 2025
7e3913f
middleware messages should be changed before being sent to discord/slack
PPTide Mar 1, 2025
886a1c8
add better description to "plugin message loops"
PPTide Mar 10, 2025
096e2bb
Merge remote-tracking branch 'mine/rpc-add-options-for-bridge' into r…
PPTide Mar 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@ func runCommands(line string, u *User) {
return
}

// Now we know it is not a DM, so this is a safe place to add the hook for sending the event to plugins
line = getMiddlewareResult(u, line)
sendMessageToPlugins(line, u)

switch currCmd {
case "hang":
hangCMD(strings.TrimSpace(strings.TrimPrefix(line, "hang")), u)
Expand Down
3 changes: 1 addition & 2 deletions devzatapi/example/main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package main

import (
"os"

api "github.com/quackduck/devzat/devzatapi"
"os"
)

func main() {
Expand Down
15 changes: 8 additions & 7 deletions devzatapi/go.mod
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
module github.com/quackduck/devzat/devzatapi

go 1.20
go 1.22

toolchain go1.23.1

require (
github.com/quackduck/devzat/plugin v0.0.0-20230715201334-cc16f25360de
google.golang.org/grpc v1.56.1
google.golang.org/grpc v1.69.4
)

require (
github.com/golang/protobuf v1.5.3 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/protobuf v1.36.2 // indirect
)

replace github.com/quackduck/devzat/plugin => ../plugin
50 changes: 30 additions & 20 deletions devzatapi/go.sum
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/quackduck/devzat/plugin v0.0.0-20230715201334-cc16f25360de h1:bMwgdxyujwtJZjoD0aCaOoUj6w1Anr6jAVbmozP2L3M=
github.com/quackduck/devzat/plugin v0.0.0-20230715201334-cc16f25360de/go.mod h1:tH/2XdRK6ZGBp3Be8017NyL53C8IEYkMCu9mS/HVFF0=
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY=
go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE=
go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE=
go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY=
go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk=
go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0=
go.opentelemetry.io/otel/sdk/metric v1.31.0 h1:i9hxxLJF/9kkvfHppyLL55aW7iIJz4JjxTeYusH7zMc=
go.opentelemetry.io/otel/sdk/metric v1.31.0/go.mod h1:CRInTMVvNhUKgSAMbKyTMxqOBC0zgyxzW55lZzX43Y8=
go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys=
go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A=
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU=
google.golang.org/grpc v1.56.1 h1:z0dNfjIl0VpaZ9iSVjA6daGatAYwPGstTjt5vkRMFkQ=
google.golang.org/grpc v1.56.1/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/grpc v1.69.4 h1:MF5TftSMkd8GLw/m0KM6V8CMOCY6NZ1NQDPGFgbTt4A=
google.golang.org/grpc v1.69.4/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4=
google.golang.org/protobuf v1.36.2 h1:R8FeyR1/eLmkutZOM5CWghmo5itiG9z0ktFlTVLuTmU=
google.golang.org/protobuf v1.36.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
32 changes: 29 additions & 3 deletions devzatapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,38 @@ func (s *Session) Close() error {
return s.conn.Close()
}

// ListenerOption is run on the listener before it is registered
type ListenerOption func(listener *plugin.Listener)

// WithColorNames lets the plugin receive names with the ANSI color codes still attached
//
// (when used in combination with WithSystemMessages other uses of ANSI colors will also not be hidden)
func WithColorNames() ListenerOption {
return func(listener *plugin.Listener) {
var val = true
listener.ColorNames = &val
}
}

// WithSystemMessages lets the plugin receive and change all messages not just ones sent by users
func WithSystemMessages() ListenerOption {
return func(listener *plugin.Listener) {
var val = true
listener.SystemMessages = &val
}
}

// RegisterListener allows for message monitoring and intercepting/editing.
// Set middleware to true to intercept and edit messages.
// Set once to true to unregister the listener after the first message is received.
// Set regex to a valid regex string to only receive messages that match the regex.
// Set any number of options to activate their effects.
//
// messageChan will receive messages that match the regex.
// middlewareResponseChan is used to send back the edited message. You must send a response if middleware is true
// even if you don't edit the message.
// See example/main.go for correct usage of this function.
func (s *Session) RegisterListener(middleware, once bool, regex string) (messageChan chan Message, middlewareResponseChan chan string, err error) {
func (s *Session) RegisterListener(middleware, once bool, regex string, options ...ListenerOption) (messageChan chan Message, middlewareResponseChan chan string, err error) {
var client plugin.Plugin_RegisterListenerClient
setup := func() error {
client, err = s.pluginClient.RegisterListener(context.Background())
Expand All @@ -82,11 +104,15 @@ func (s *Session) RegisterListener(middleware, once bool, regex string) (message
if regex == "" {
pointerRegex = nil
}
err = client.Send(&plugin.ListenerClientData{Data: &plugin.ListenerClientData_Listener{Listener: &plugin.Listener{
listener := &plugin.Listener{
Middleware: &middleware,
Once: &once,
Regex: pointerRegex,
}}})
}
for _, option := range options {
option(listener)
}
err = client.Send(&plugin.ListenerClientData{Data: &plugin.ListenerClientData_Listener{Listener: listener}})
if err != nil {
return err
}
Expand Down
20 changes: 9 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
module devzat

go 1.20
go 1.22

require (
devzat/plugin v0.0.0-00010101000000-000000000000
github.com/TwiN/go-away v1.6.11
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
github.com/alecthomas/chroma v0.10.0
github.com/bwmarrin/discordgo v0.27.1
github.com/caarlos0/sshmarshal v0.1.0
github.com/charmbracelet/glamour v0.6.0
github.com/dghubble/go-twitter v0.0.0-20221104224141-912508c3888b
github.com/dghubble/oauth1 v0.7.2
Expand All @@ -20,9 +19,9 @@ require (
github.com/quackduck/term v0.0.0-20230512153006-5935fcd4d5e9
github.com/shurcooL/tictactoe v0.0.0-20210613024444-e573ff1376a3
github.com/slack-go/slack v0.12.3
golang.org/x/crypto v0.13.0
golang.org/x/crypto v0.32.0
golang.org/x/image v0.12.0
google.golang.org/grpc v1.58.2
google.golang.org/grpc v1.69.4
gopkg.in/yaml.v2 v2.4.0
)

Expand All @@ -33,7 +32,6 @@ require (
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/dghubble/sling v1.4.1 // indirect
github.com/dlclark/regexp2 v1.10.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
Expand All @@ -49,12 +47,12 @@ require (
github.com/rivo/uniseg v0.4.4 // indirect
github.com/yuin/goldmark v1.5.6 // indirect
github.com/yuin/goldmark-emoji v1.0.2 // indirect
golang.org/x/net v0.15.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/term v0.12.0 // indirect
golang.org/x/text v0.13.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect
google.golang.org/protobuf v1.31.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/term v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
google.golang.org/protobuf v1.36.2 // indirect
)

replace devzat/plugin => ./plugin
Loading