Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
152bccf758 | |||
b9d50931ad | |||
b0ad50f907 | |||
c564430dde | |||
1140534496 | |||
0da253025e |
46
.drone.yml
46
.drone.yml
@ -1,37 +1,19 @@
|
||||
kind: pipeline
|
||||
name: default
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: golang
|
||||
- name: submodules
|
||||
image: alpine/git
|
||||
commands:
|
||||
- make
|
||||
|
||||
- name: create release-source tar
|
||||
image: golang
|
||||
commands:
|
||||
- go mod vendor
|
||||
- tar -czf release-source-$DRONE_TAG.tar.gz *
|
||||
- mkdir dist
|
||||
- mv release-source-$DRONE_TAG.tar.gz dist/
|
||||
when:
|
||||
event: tag
|
||||
|
||||
- name: create release-binary tar
|
||||
image: golang
|
||||
commands:
|
||||
- tar -czf dist/release-$DRONE_TAG-$DRONE_STAGE_ARCH.tar.gz init/simpbot.service config.yaml.sample simpbot
|
||||
when:
|
||||
event: tag
|
||||
|
||||
- name: release
|
||||
image: plugins/gitea-release
|
||||
- git submodule update --init --recursive
|
||||
- name: build-container
|
||||
image: plugins/docker
|
||||
settings:
|
||||
api_key:
|
||||
from_secret: gitea_token
|
||||
files:
|
||||
- dist/*
|
||||
base_url: https://git.saintnet.tech
|
||||
when:
|
||||
event: tag
|
||||
|
||||
repo: git.saintnet.tech/stryan/simpbot
|
||||
registry: git.saintnet.tech
|
||||
password:
|
||||
from_secret: build_pass
|
||||
username:
|
||||
from_secret: build_username
|
||||
dockerfile: Containerfile
|
||||
tags: latest
|
||||
layers: true
|
||||
|
20
.woodpecker.yaml
Normal file
20
.woodpecker.yaml
Normal file
@ -0,0 +1,20 @@
|
||||
steps:
|
||||
- name: submodules
|
||||
image: alpine/git
|
||||
commands:
|
||||
- git submodule update --init --recursive
|
||||
- name: build-container
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: git.saintnet.tech/stryan/simpbot
|
||||
registry: git.saintnet.tech
|
||||
password:
|
||||
from_secret: build_pass
|
||||
username:
|
||||
from_secret: build_username
|
||||
dockerfile: Containerfile
|
||||
tags: latest
|
||||
layers: true
|
||||
when:
|
||||
- branch: master
|
||||
event: push
|
26
go.mod
26
go.mod
@ -3,33 +3,35 @@ module git.saintnet.tech/stryan/simpbot
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
git.saintnet.tech/stryan/matrixbotlib v0.1.4-0.20230530225509-54d876a98998
|
||||
github.com/charmbracelet/log v0.2.1
|
||||
git.saintnet.tech/stryan/matrixbotlib v0.1.5
|
||||
github.com/charmbracelet/log v0.2.5
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
maunium.net/go/mautrix v0.15.2
|
||||
maunium.net/go/mautrix v0.16.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
||||
github.com/charmbracelet/lipgloss v0.7.1 // indirect
|
||||
github.com/charmbracelet/lipgloss v0.9.1 // indirect
|
||||
github.com/go-logfmt/logfmt v0.6.0 // indirect
|
||||
github.com/kelseyhightower/envconfig v1.4.0 // indirect
|
||||
github.com/kr/pretty v0.3.0 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.14 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.15 // indirect
|
||||
github.com/muesli/reflow v0.3.0 // indirect
|
||||
github.com/muesli/termenv v0.15.1 // indirect
|
||||
github.com/muesli/termenv v0.15.2 // indirect
|
||||
github.com/rivo/uniseg v0.4.4 // indirect
|
||||
github.com/rs/zerolog v1.29.1 // indirect
|
||||
github.com/tidwall/gjson v1.14.4 // indirect
|
||||
github.com/rs/zerolog v1.31.0 // indirect
|
||||
github.com/tidwall/gjson v1.17.0 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.1 // indirect
|
||||
github.com/tidwall/sjson v1.2.5 // indirect
|
||||
golang.org/x/crypto v0.9.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
|
||||
golang.org/x/net v0.10.0 // indirect
|
||||
golang.org/x/sys v0.8.0 // indirect
|
||||
go.mau.fi/util v0.1.0 // indirect
|
||||
golang.org/x/crypto v0.14.0 // indirect
|
||||
golang.org/x/net v0.17.0 // indirect
|
||||
golang.org/x/sys v0.13.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
|
||||
maunium.net/go/maulogger/v2 v2.4.1 // indirect
|
||||
)
|
||||
|
61
go.sum
61
go.sum
@ -1,17 +1,19 @@
|
||||
git.saintnet.tech/stryan/matrixbotlib v0.1.4-0.20230530225509-54d876a98998 h1:cO9xu1+ljeZKGMlj6NTfj2l/F5smixb39kqvrh1hKVY=
|
||||
git.saintnet.tech/stryan/matrixbotlib v0.1.4-0.20230530225509-54d876a98998/go.mod h1:N/pSAeBeiisb1LWPsQpWJ8JCEepA6clP/ugLW8vDJsI=
|
||||
git.saintnet.tech/stryan/matrixbotlib v0.1.5 h1:/p/1KKSveR57lFWGhU617i9nllW0Hh9dhnTeeIfQgMg=
|
||||
git.saintnet.tech/stryan/matrixbotlib v0.1.5/go.mod h1:scipuBfwVWNzIp46qj+bSLQ+lzZ47luzcOcTSdF7Jo0=
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
|
||||
github.com/charmbracelet/lipgloss v0.7.1 h1:17WMwi7N1b1rVWOjMT+rCh7sQkvDU75B2hbZpc5Kc1E=
|
||||
github.com/charmbracelet/lipgloss v0.7.1/go.mod h1:yG0k3giv8Qj8edTCbbg6AlQ5e8KNWpFujkNawKNhE2c=
|
||||
github.com/charmbracelet/log v0.2.1 h1:1z7jpkk4yKyjwlmKmKMM5qnEDSpV32E7XtWhuv0mTZE=
|
||||
github.com/charmbracelet/log v0.2.1/go.mod h1:GwFfjewhcVDWLrpAbY5A0Hin9YOlEn40eWT4PNaxFT4=
|
||||
github.com/charmbracelet/lipgloss v0.9.1 h1:PNyd3jvaJbg4jRHKWXnCj1akQm4rh8dbEzN1p/u1KWg=
|
||||
github.com/charmbracelet/lipgloss v0.9.1/go.mod h1:1mPmG4cxScwUQALAAnacHaigiiHB9Pmr+v1VEawJl6I=
|
||||
github.com/charmbracelet/log v0.2.5 h1:1yVvyKCKVV639RR4LIq1iy1Cs1AKxuNO+Hx2LJtk7Wc=
|
||||
github.com/charmbracelet/log v0.2.5/go.mod h1:nQGK8tvc4pS9cvVEH/pWJiZ50eUq1aoXUOjGpXvdD0k=
|
||||
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
|
||||
github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
|
||||
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
@ -21,20 +23,18 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
|
||||
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
|
||||
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
|
||||
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
|
||||
github.com/muesli/termenv v0.15.1 h1:UzuTb/+hhlBugQz28rpzey4ZuKcZ03MeKsoG7IJZIxs=
|
||||
github.com/muesli/termenv v0.15.1/go.mod h1:HeAQPTzpfs016yGtA4g00CsdYnVLJvxsS4ANqrZs2sQ=
|
||||
github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo=
|
||||
github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
@ -43,13 +43,13 @@ github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
|
||||
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc=
|
||||
github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU=
|
||||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A=
|
||||
github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM=
|
||||
github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM=
|
||||
github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
@ -57,18 +57,19 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
|
||||
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
|
||||
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
|
||||
golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
|
||||
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
|
||||
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc=
|
||||
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
|
||||
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
go.mau.fi/util v0.1.0 h1:BwIFWIOEeO7lsiI2eWKFkWTfc5yQmoe+0FYyOFVyaoE=
|
||||
go.mau.fi/util v0.1.0/go.mod h1:AxuJUMCxpzgJ5eV9JbPWKRH8aAJJidxetNdUj7qcb84=
|
||||
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
||||
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
|
||||
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
@ -78,5 +79,5 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
maunium.net/go/maulogger/v2 v2.4.1 h1:N7zSdd0mZkB2m2JtFUsiGTQQAdP0YeFWT7YMc80yAL8=
|
||||
maunium.net/go/maulogger/v2 v2.4.1/go.mod h1:omPuYwYBILeVQobz8uO3XC8DIRuEb5rXYlQSuqrbCho=
|
||||
maunium.net/go/mautrix v0.15.2 h1:fUiVajeoOR92uJoSShHbCvh7uG6lDY4ZO4Mvt90LbjU=
|
||||
maunium.net/go/mautrix v0.15.2/go.mod h1:h4NwfKqE4YxGTLSgn/gawKzXAb2sF4qx8agL6QEFtGg=
|
||||
maunium.net/go/mautrix v0.16.1 h1:Wb3CvOCe8A/NLsFeZYxKrgXKiqeZUQEBD1zqm7n/kWk=
|
||||
maunium.net/go/mautrix v0.16.1/go.mod h1:2Jf15tulVtr6LxoiRL4smRXwpkGWUNfBFhwh/aXDBuk=
|
||||
|
2
live.go
2
live.go
@ -3,7 +3,7 @@ package main
|
||||
import "time"
|
||||
|
||||
type StreamList struct {
|
||||
Total string `json:"total"`
|
||||
Total int `json:"total"`
|
||||
Streams []Stream `json:"items"`
|
||||
}
|
||||
type Channel struct {
|
||||
|
8
main.go
8
main.go
@ -19,10 +19,12 @@ var GitCommit string
|
||||
|
||||
func main() {
|
||||
log.Info("loading matrix client")
|
||||
conf, err := mbl.LoadMatrixClientConfig("config.yaml")
|
||||
cnffile := "config.yaml"
|
||||
conf, err := mbl.LoadMatrixClientConfig(cnffile)
|
||||
if err != nil {
|
||||
log.Info("no local config found, checking /etc/simpbot")
|
||||
conf, err = mbl.LoadMatrixClientConfig("/etc/simpbot/config.yaml")
|
||||
cnffile = "/etc/simpbot/config.yaml"
|
||||
conf, err = mbl.LoadMatrixClientConfig(cnffile)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -34,7 +36,7 @@ func main() {
|
||||
}
|
||||
|
||||
log.Info("loading simpbot")
|
||||
simp, err := newSimp("config.yaml", matrixClient)
|
||||
simp, err := newSimp(cnffile, matrixClient)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
179
simp.go
179
simp.go
@ -3,20 +3,21 @@ package main
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
mbl "git.saintnet.tech/stryan/matrixbotlib"
|
||||
"github.com/charmbracelet/log"
|
||||
"golang.org/x/exp/slices"
|
||||
"gopkg.in/yaml.v2"
|
||||
"maunium.net/go/mautrix"
|
||||
"maunium.net/go/mautrix/event"
|
||||
"maunium.net/go/mautrix/id"
|
||||
)
|
||||
|
||||
//SimpConf is the simpbot conf that's not matrix
|
||||
// SimpConf is the simpbot conf that's not matrix
|
||||
type SimpConf struct {
|
||||
DimensionServer string `yaml:"dimension"`
|
||||
HolodexToken string `yaml:"api_token"`
|
||||
@ -50,7 +51,7 @@ func newSimp(filename string, client *mautrix.Client) (*simp, error) {
|
||||
change: make(chan int),
|
||||
client: client,
|
||||
}
|
||||
yamlFile, err := ioutil.ReadFile(filename)
|
||||
yamlFile, err := os.ReadFile(filename)
|
||||
if err == nil {
|
||||
err = yaml.Unmarshal(yamlFile, cnf)
|
||||
} else {
|
||||
@ -105,7 +106,10 @@ func (s *simp) Sync() error {
|
||||
}
|
||||
embed := content.ID != ""
|
||||
if v.IsLive() != embed {
|
||||
s.Update(v)
|
||||
err := s.Update(v)
|
||||
if err != nil {
|
||||
log.Warn("error updating", "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -134,25 +138,97 @@ func (s *simp) Sync() error {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *simp) Update(v *Vtuber) error {
|
||||
for _, room := range s.State.rooms {
|
||||
func (s *simp) PopulateRoom(room id.RoomID) error {
|
||||
log.Info("updating room", "room", room)
|
||||
for _, v := range s.State.vtubers {
|
||||
log.Printf("Updating vtuber %v", v.Name)
|
||||
if v.IsLive() {
|
||||
if v.AnnounceLive {
|
||||
s.State.client.SendText(room, v.LiveMsg)
|
||||
_, err := s.State.client.SendText(room, v.LiveMsg)
|
||||
if err != nil {
|
||||
log.Warn("error sending message to room", "error", err)
|
||||
}
|
||||
} else {
|
||||
if isValidURL(v.LiveMsg) {
|
||||
s.State.client.SendNotice(room, fmt.Sprintf("%v has gone live", v.Name))
|
||||
_, err := s.State.client.SendNotice(room, fmt.Sprintf("%v has gone live", v.Name))
|
||||
if err != nil {
|
||||
log.Warn("error updating state", "error", err)
|
||||
}
|
||||
} else {
|
||||
s.State.client.SendNotice(room, v.LiveMsg)
|
||||
_, err := s.State.client.SendNotice(room, v.LiveMsg)
|
||||
if err != nil {
|
||||
log.Warn("error updating state", "error", err)
|
||||
}
|
||||
}
|
||||
s.State.client.SendNotice(room, fmt.Sprintf("%v's Title: %v", v.Name, v.CurrentStreamTitle))
|
||||
}
|
||||
_, err := s.State.client.SendNotice(room, fmt.Sprintf("%v's Title: %v", v.Name, v.CurrentStreamTitle))
|
||||
if err != nil {
|
||||
log.Warn("error sending notice", "error", err)
|
||||
}
|
||||
var subs string
|
||||
for k := range v.Subs {
|
||||
subs += k.String() + " "
|
||||
}
|
||||
if len(v.Subs) > 0 {
|
||||
s.State.client.SendText(room, fmt.Sprintf("Pinging %v", subs))
|
||||
_, err = s.State.client.SendText(room, fmt.Sprintf("Pinging %v", subs))
|
||||
if err != nil {
|
||||
log.Warn("error sending text", "error", err)
|
||||
}
|
||||
}
|
||||
resp, err := s.State.client.SendStateEvent(
|
||||
room,
|
||||
event.NewEventType("im.vector.modular.widgets"),
|
||||
"dimension-m.video-simp-"+v.Name,
|
||||
s.NewYT(v.Name+"'s stream", v.CurrentStream, string(room)),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v.TotalStreams = v.TotalStreams + 1
|
||||
s.State.currStream++
|
||||
if s.State.currStream > s.State.maxStream {
|
||||
s.State.maxStream = s.State.currStream
|
||||
}
|
||||
log.Info("Embed stream added", "event", resp, "vtuber", v.Name)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *simp) Update(v *Vtuber) error {
|
||||
for _, room := range s.State.rooms {
|
||||
if v.IsLive() {
|
||||
if v.AnnounceLive {
|
||||
_, err := s.State.client.SendText(room, v.LiveMsg)
|
||||
if err != nil {
|
||||
log.Warn("error sending text", "error", err)
|
||||
}
|
||||
} else {
|
||||
if isValidURL(v.LiveMsg) {
|
||||
_, err := s.State.client.SendNotice(room, fmt.Sprintf("%v has gone live", v.Name))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
_, err := s.State.client.SendNotice(room, v.LiveMsg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
_, err := s.State.client.SendNotice(room, fmt.Sprintf("%v's Title: %v", v.Name, v.CurrentStreamTitle))
|
||||
if err != nil {
|
||||
log.Warn("error sending notice", "error", err)
|
||||
}
|
||||
var subs string
|
||||
for k := range v.Subs {
|
||||
subs += k.String() + " "
|
||||
}
|
||||
if len(v.Subs) > 0 {
|
||||
_, err = s.State.client.SendText(room, fmt.Sprintf("Pinging %v", subs))
|
||||
if err != nil {
|
||||
log.Warn("error sending text", "error", err)
|
||||
}
|
||||
}
|
||||
resp, err := s.State.client.SendStateEvent(
|
||||
room,
|
||||
@ -189,21 +265,29 @@ func (s *simp) Run() {
|
||||
log.Info("stopping runner")
|
||||
return
|
||||
case v := <-s.State.change:
|
||||
s.Update(s.State.vtubers[v])
|
||||
err := s.Update(s.State.vtubers[v])
|
||||
if err != nil {
|
||||
log.Warn("error updating vtube memory", "error", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *simp) SetupMatrix() error {
|
||||
mbl.SetupAccountDataStore(s.State.client, "s.batch")
|
||||
err := mbl.SetupAccountDataStore(s.State.client, "s.batch")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
syncer := s.State.client.Syncer.(*mautrix.DefaultSyncer)
|
||||
syncer.OnEventType(event.EventMessage, func(source mautrix.EventSource, evt *event.Event) {
|
||||
uid := s.State.client.UserID.String()
|
||||
syncer.OnEventType(event.EventMessage, func(_ mautrix.EventSource, evt *event.Event) {
|
||||
if evt.Sender == s.State.client.UserID {
|
||||
return // ignore events from self
|
||||
}
|
||||
log.Debugf("<%[1]s> %[4]s (%[2]s/%[3]s)\n", evt.Sender, evt.Type.String(), evt.ID, evt.Content.AsMessage().Body)
|
||||
|
||||
cmd, err := mbl.ParseCommand(evt, "simp")
|
||||
var cmd []string
|
||||
cmd, err = mbl.ParseCommand(evt, "simp")
|
||||
if err != nil {
|
||||
if err != mbl.ErrCmdParseNoPrefix {
|
||||
log.Printf("invalid command: %v", err)
|
||||
@ -223,7 +307,10 @@ func (s *simp) SetupMatrix() error {
|
||||
vlist = append(vlist, fmt.Sprintf("%v%v", vt.Name, ann))
|
||||
}
|
||||
infomsg = fmt.Sprintf("Currently Simping For: \n%v", strings.Join(vlist, "\n"))
|
||||
s.State.client.SendText(evt.RoomID, infomsg)
|
||||
_, err = s.State.client.SendText(evt.RoomID, infomsg)
|
||||
if err != nil {
|
||||
log.Warn("error sending text", "error", err)
|
||||
}
|
||||
case "stats":
|
||||
var statmsg string
|
||||
vlist := []string{}
|
||||
@ -240,44 +327,77 @@ func (s *simp) SetupMatrix() error {
|
||||
s.State.maxStream,
|
||||
len(s.State.vtubers),
|
||||
)
|
||||
s.State.client.SendText(evt.RoomID, statmsg)
|
||||
_, err = s.State.client.SendText(evt.RoomID, statmsg)
|
||||
if err != nil {
|
||||
log.Warn("error sending text", "error", err)
|
||||
}
|
||||
case "version":
|
||||
s.State.client.SendText(evt.RoomID, "not implemented")
|
||||
_, err = s.State.client.SendText(evt.RoomID, "not implemented")
|
||||
if err != nil {
|
||||
log.Warn("error sending text", "error", err)
|
||||
}
|
||||
case "subscribe":
|
||||
if len(cmd) < 3 {
|
||||
s.State.client.SendText(evt.RoomID, "Need a member to subscribe to")
|
||||
_, err = s.State.client.SendText(evt.RoomID, "Need a member to subscribe to")
|
||||
if err != nil {
|
||||
log.Warn("error sending text", "error", err)
|
||||
}
|
||||
}
|
||||
vt := cmd[1]
|
||||
var subbed bool
|
||||
for _, v := range s.State.vtubers {
|
||||
if strings.ToUpper(v.Name) == strings.ToUpper(vt) {
|
||||
if strings.EqualFold(v.Name, vt) {
|
||||
v.Subs[evt.Sender] = true
|
||||
subbed = true
|
||||
}
|
||||
}
|
||||
if subbed {
|
||||
s.State.client.SendText(evt.RoomID, "subbed")
|
||||
_, err = s.State.client.SendText(evt.RoomID, "subbed")
|
||||
if err != nil {
|
||||
log.Warn("error sending text", "error", err)
|
||||
}
|
||||
} else {
|
||||
s.State.client.SendText(evt.RoomID, "could not identify talent to subscribe to")
|
||||
_, err = s.State.client.SendText(evt.RoomID, "could not identify talent to subscribe to")
|
||||
if err != nil {
|
||||
log.Warn("error sending text", "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
case "help":
|
||||
s.State.client.SendText(evt.RoomID, "Supported commands: info,version,stats,subscribe")
|
||||
_, err = s.State.client.SendText(evt.RoomID, "Supported commands: info,version,stats,subscribe")
|
||||
if err != nil {
|
||||
log.Warn("error sending text", "error", err)
|
||||
}
|
||||
default:
|
||||
// command not found
|
||||
s.State.client.SendText(evt.RoomID, "command not recognized")
|
||||
_, err = s.State.client.SendText(evt.RoomID, "command not recognized")
|
||||
if err != nil {
|
||||
log.Warn("error sending text", "error", err)
|
||||
}
|
||||
}
|
||||
})
|
||||
syncer.OnEventType(event.StateMember, func(source mautrix.EventSource, evt *event.Event) {
|
||||
log.Infof("<%[1]s> %[4]s (%[2]s/%[3]s)\n", evt.Sender, evt.Type.String(), evt.ID, evt.Content.AsMessage().Body)
|
||||
if evt.Content.AsMember().Membership.IsInviteOrJoin() {
|
||||
_, err := s.State.client.JoinRoomByID(evt.RoomID)
|
||||
syncer.OnEventType(event.StateMember, func(_ mautrix.EventSource, evt *event.Event) {
|
||||
// log.Infof("<%[1]s> %[4]s (%[2]s/%[3]s)", evt.Sender, evt.Type.String(), evt.ID, evt.Content.AsMessage().Body)
|
||||
mevt := evt.Content.AsMember()
|
||||
log.Printf("FBL %v", mevt.Membership)
|
||||
if mevt.Membership == event.MembershipInvite {
|
||||
_, err = s.State.client.JoinRoomByID(evt.RoomID)
|
||||
if err != nil {
|
||||
log.Errorf("error joining room %v", evt.RoomID)
|
||||
} else {
|
||||
log.Infof("joined room %v", evt.RoomID)
|
||||
s.State.rooms = append(s.State.rooms, evt.RoomID)
|
||||
}
|
||||
} else if evt.Content.AsMember().Membership.IsLeaveOrBan() {
|
||||
if evt.StateKey != nil && *evt.StateKey == uid {
|
||||
log.Infof("leaving room %v", evt.RoomID)
|
||||
index := slices.Index(s.State.rooms, evt.RoomID)
|
||||
if index != -1 {
|
||||
slices.Delete(s.State.rooms, index, index)
|
||||
} else {
|
||||
log.Warn("asked to leave room not in memory: %v", evt.RoomID)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
roomResp, err := s.State.client.JoinedRooms()
|
||||
@ -285,6 +405,7 @@ func (s *simp) SetupMatrix() error {
|
||||
return err
|
||||
}
|
||||
s.State.rooms = roomResp.JoinedRooms
|
||||
log.Infof("initial room count: %v", len(s.State.rooms))
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -311,7 +432,7 @@ func (s *simp) NewYT(videoName, videoID, roomID string) *YoutubeWidget {
|
||||
Category: "widget",
|
||||
Type: "youtube",
|
||||
},
|
||||
LastUpdatedTs: time.Now().UnixNano() / int64(time.Millisecond),
|
||||
LastUpdatedTS: time.Now().UnixNano() / int64(time.Millisecond),
|
||||
},
|
||||
},
|
||||
CreatorUserID: string(s.State.client.UserID),
|
||||
|
@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"maunium.net/go/mautrix/id"
|
||||
@ -61,11 +61,11 @@ func (v *Vtuber) Update(apiKey string) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("error sending request %w", err)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
defer func() { _ = res.Body.Close() }()
|
||||
if res.StatusCode != 200 {
|
||||
return fmt.Errorf("bad status code %v", res.StatusCode)
|
||||
}
|
||||
jsonBody, err := ioutil.ReadAll(res.Body)
|
||||
jsonBody, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error reading response: %w", err)
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ type DimensionAppMetadata struct {
|
||||
WrapperID string `json:"wrapperId"`
|
||||
ScalarWrapperID string `json:"scalarWrapperId"`
|
||||
Integration Integration `json:"integration"`
|
||||
LastUpdatedTs int64 `json:"lastUpdatedTs"`
|
||||
LastUpdatedTS int64 `json:"lastUpdatedTs"`
|
||||
}
|
||||
type VideoData struct {
|
||||
VideoURL string `json:"videoUrl"`
|
||||
@ -27,6 +27,3 @@ type YoutubeWidget struct {
|
||||
RoomID string `json:"roomId"`
|
||||
EventID string `json:"eventId"`
|
||||
}
|
||||
type unsignedAge struct {
|
||||
Age int `json:"age"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user