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