mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2025-01-03 10:16:01 +00:00
Compare commits
8 commits
01390583b2
...
9e2510ec09
Author | SHA1 | Date | |
---|---|---|---|
9e2510ec09 | |||
552e7c9f10 | |||
d8cd131edd | |||
24aa1b5d67 | |||
2772286b71 | |||
8b3d3bdc98 | |||
12f16db1ac | |||
7da8b9ffa4 |
7 changed files with 102 additions and 17 deletions
15
.github/workflows/test-and-build.yml
vendored
15
.github/workflows/test-and-build.yml
vendored
|
@ -36,6 +36,7 @@ jobs:
|
||||||
curl \
|
curl \
|
||||||
diffutils \
|
diffutils \
|
||||||
git \
|
git \
|
||||||
|
git-lfs \
|
||||||
go \
|
go \
|
||||||
golangci-lint-bin \
|
golangci-lint-bin \
|
||||||
make \
|
make \
|
||||||
|
@ -47,22 +48,20 @@ jobs:
|
||||||
which \
|
which \
|
||||||
zip
|
zip
|
||||||
|
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
lfs: true
|
||||||
|
show-progress: false
|
||||||
|
|
||||||
- name: Marking workdir safe
|
- name: Marking workdir safe
|
||||||
run: git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
run: |
|
||||||
|
git config --global --add safe.directory /__w/twitch-bot/twitch-bot
|
||||||
|
|
||||||
- name: Lint and test code
|
- name: Lint and test code
|
||||||
run: make lint test frontend_lint
|
run: make lint test frontend_lint
|
||||||
|
|
||||||
- name: Build release
|
- name: Build release
|
||||||
run: make publish
|
run: make publish
|
||||||
env:
|
|
||||||
FORCE_SKIP_UPLOAD: 'true'
|
|
||||||
MOD_MODE: readonly
|
|
||||||
NODE_ENV: production
|
|
||||||
NO_TESTS: 'true'
|
|
||||||
PACKAGES: '.'
|
|
||||||
|
|
||||||
- name: Execute Trivy scan
|
- name: Execute Trivy scan
|
||||||
run: make trivy
|
run: make trivy
|
||||||
|
|
17
History.md
17
History.md
|
@ -1,3 +1,20 @@
|
||||||
|
# 3.23.1 / 2023-12-20
|
||||||
|
|
||||||
|
* Bugfixes
|
||||||
|
* [CI] Fix: Prevent tag collision in CI
|
||||||
|
|
||||||
|
# 3.23.0 / 2023-12-20
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> This release slightly changes the way release binaries are packaged: The binary is now named `twitch-bot` instead of i.e. `twitch-bot_linux_amd64` within the archives.
|
||||||
|
|
||||||
|
* Improvements
|
||||||
|
* [editor] Improve wording and visibility for bot connection
|
||||||
|
|
||||||
|
* Bugfixes
|
||||||
|
* [quote] Fix: Add primary key to quote table
|
||||||
|
* [eventsub] Fix: Stop subscription-retries when client is closed
|
||||||
|
|
||||||
# 3.22.0 / 2023-12-14
|
# 3.22.0 / 2023-12-14
|
||||||
|
|
||||||
* Improvements
|
* Improvements
|
||||||
|
|
3
Makefile
3
Makefile
|
@ -13,8 +13,7 @@ lint:
|
||||||
golangci-lint run
|
golangci-lint run
|
||||||
|
|
||||||
publish: frontend_prod
|
publish: frontend_prod
|
||||||
curl -sSLo golang.sh https://raw.githubusercontent.com/Luzifer/github-publish/master/golang.sh
|
bash ./ci/build.sh
|
||||||
bash golang.sh
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
go test -cover -v ./...
|
go test -cover -v ./...
|
||||||
|
|
63
ci/build.sh
Normal file
63
ci/build.sh
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
osarch=(
|
||||||
|
darwin/amd64
|
||||||
|
darwin/arm64
|
||||||
|
linux/amd64
|
||||||
|
linux/arm
|
||||||
|
linux/arm64
|
||||||
|
windows/amd64
|
||||||
|
)
|
||||||
|
|
||||||
|
function go_package() {
|
||||||
|
cd "${4}"
|
||||||
|
|
||||||
|
local outname="${3}"
|
||||||
|
[[ $1 == windows ]] && outname="${3}.exe"
|
||||||
|
|
||||||
|
log "=> Building ${3} for ${1}/${2}..."
|
||||||
|
CGO_ENABLED=0 GOARCH=$2 GOOS=$1 go build \
|
||||||
|
-ldflags "-s -w -X main.version=${version}" \
|
||||||
|
-mod=readonly \
|
||||||
|
-trimpath \
|
||||||
|
-o "${outname}"
|
||||||
|
|
||||||
|
if [[ $1 == linux ]]; then
|
||||||
|
log "=> Packging ${3} as ${3}_${1}_${2}.tgz..."
|
||||||
|
tar -czf "${builddir}/${3}_${1}_${2}.tgz" "${outname}"
|
||||||
|
else
|
||||||
|
log "=> Packging ${3} as ${3}_${1}_${2}.zip..."
|
||||||
|
zip "${builddir}/${3}_${1}_${2}.zip" "${outname}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm "${outname}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function go_package_all() {
|
||||||
|
for oa in "${osarch[@]}"; do
|
||||||
|
local os=$(cut -d / -f 1 <<<"${oa}")
|
||||||
|
local arch=$(cut -d / -f 2 <<<"${oa}")
|
||||||
|
(go_package "${os}" "${arch}" "${1}" "${2}")
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function log() {
|
||||||
|
echo "[$(date +%H:%M:%S)] $@" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
root=$(pwd)
|
||||||
|
builddir="${root}/.build"
|
||||||
|
version="$(git describe --tags --always || echo dev)"
|
||||||
|
|
||||||
|
log "Building version ${version}..."
|
||||||
|
|
||||||
|
log "Resetting output directory..."
|
||||||
|
rm -rf "${builddir}"
|
||||||
|
mkdir -p "${builddir}"
|
||||||
|
|
||||||
|
log "Building Bot..."
|
||||||
|
go_package_all "twitch-bot" "."
|
||||||
|
|
||||||
|
log "Generating SHA256SUMS file..."
|
||||||
|
(cd "${builddir}" && sha256sum * | tee SHA256SUMS)
|
|
@ -13,6 +13,7 @@ import (
|
||||||
|
|
||||||
type (
|
type (
|
||||||
quote struct {
|
quote struct {
|
||||||
|
ID uint64 `gorm:"primaryKey"`
|
||||||
Channel string `gorm:"not null;uniqueIndex:ensure_sort_idx;size:32"`
|
Channel string `gorm:"not null;uniqueIndex:ensure_sort_idx;size:32"`
|
||||||
CreatedAt int64 `gorm:"uniqueIndex:ensure_sort_idx"`
|
CreatedAt int64 `gorm:"uniqueIndex:ensure_sort_idx"`
|
||||||
Quote string
|
Quote string
|
||||||
|
@ -22,7 +23,7 @@ type (
|
||||||
func AddQuote(db database.Connector, channel, quoteStr string) error {
|
func AddQuote(db database.Connector, channel, quoteStr string) error {
|
||||||
return errors.Wrap(
|
return errors.Wrap(
|
||||||
helpers.RetryTransaction(db.DB(), func(tx *gorm.DB) error {
|
helpers.RetryTransaction(db.DB(), func(tx *gorm.DB) error {
|
||||||
return tx.Create(quote{
|
return tx.Create("e{
|
||||||
Channel: channel,
|
Channel: channel,
|
||||||
CreatedAt: time.Now().UnixNano(),
|
CreatedAt: time.Now().UnixNano(),
|
||||||
Quote: quoteStr,
|
Quote: quoteStr,
|
||||||
|
@ -121,7 +122,7 @@ func SetQuotes(db database.Connector, channel string, quotes []string) error {
|
||||||
|
|
||||||
t := time.Now()
|
t := time.Now()
|
||||||
for _, quoteStr := range quotes {
|
for _, quoteStr := range quotes {
|
||||||
if err := tx.Create(quote{
|
if err := tx.Create("e{
|
||||||
Channel: channel,
|
Channel: channel,
|
||||||
CreatedAt: t.UnixNano(),
|
CreatedAt: t.UnixNano(),
|
||||||
Quote: quoteStr,
|
Quote: quoteStr,
|
||||||
|
|
|
@ -421,6 +421,12 @@ func (e *EventSubSocketClient) retryBackgroundSubscribe(st eventSubSocketSubscri
|
||||||
WithMaxTotalTime(retrySubscribeMaxTotal).
|
WithMaxTotalTime(retrySubscribeMaxTotal).
|
||||||
WithMinIterationTime(retrySubscribeMinWait).
|
WithMinIterationTime(retrySubscribeMinWait).
|
||||||
Retry(func() error {
|
Retry(func() error {
|
||||||
|
if err := e.runCtx.Err(); err != nil {
|
||||||
|
// Our run-context was cancelled, stop retrying to subscribe
|
||||||
|
// to topics as this client was closed
|
||||||
|
return backoff.NewErrCannotRetry(err)
|
||||||
|
}
|
||||||
|
|
||||||
return e.subscribe(st)
|
return e.subscribe(st)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -273,24 +273,24 @@
|
||||||
|
|
||||||
<b-card-body>
|
<b-card-body>
|
||||||
<p>
|
<p>
|
||||||
Here you can manage your bots auth-token: it's required to communicate with Twitch Chat and APIs. This will override the token you might have provided when starting the bot and will be automatically renewed as long as you don't change your password or revoke the apps permission on your bot account.
|
Here you can manage your bots auth-token: it's required to communicate with Twitch Chat and APIs. The access will be valid as long as you don't change the password or revoke the apps permission in your bot account.
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Copy the URL provided below</li>
|
<li>Copy the URL provided below</li>
|
||||||
<li>Open an inkognito tab or different browser you are not logged into Twitch or are logged in with your bot account</li>
|
<li><strong>Open an inkognito tab or different browser you are not logged into Twitch or are logged in with your bot account</strong></li>
|
||||||
<li>Open the copied URL, sign in with the bot account and accept the permissions</li>
|
<li>Open the copied URL, sign in with the bot account and accept the permissions</li>
|
||||||
<li>The bot will display a message containing the authorized account. If this account is wrong, just start over, the token will be overwritten.</li>
|
<li>You will see a message containing the authorized account. If this account is wrong, just start over, the token will be overwritten.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p
|
<p
|
||||||
v-if="botMissingScopes > 0"
|
v-if="botMissingScopes > 0"
|
||||||
class="text-warning"
|
class="alert alert-warning"
|
||||||
>
|
>
|
||||||
<font-awesome-icon
|
<font-awesome-icon
|
||||||
fixed-width
|
fixed-width
|
||||||
class="mr-1"
|
class="mr-1"
|
||||||
:icon="['fas', 'exclamation-triangle']"
|
:icon="['fas', 'exclamation-triangle']"
|
||||||
/>
|
/>
|
||||||
Bot is missing {{ botMissingScopes }} of its default scopes, please re-authorize the bot.
|
Bot is missing {{ botMissingScopes }} of its required scopes which will cause features not to work properly. Please re-authorize the bot using the URL below.
|
||||||
</p>
|
</p>
|
||||||
<b-input-group>
|
<b-input-group>
|
||||||
<b-form-input
|
<b-form-input
|
||||||
|
|
Loading…
Reference in a new issue