Compare commits
3 commits
8c400ac564
...
da9a0bca3d
Author | SHA1 | Date | |
---|---|---|---|
da9a0bca3d | |||
15bf56a1e7 | |||
d27348ca0b |
6 changed files with 74 additions and 4 deletions
55
.forgejo/workflows/bake.yml
Normal file
55
.forgejo/workflows/bake.yml
Normal file
|
@ -0,0 +1,55 @@
|
|||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'ci-test'
|
||||
tags:
|
||||
- 'v*'
|
||||
paths:
|
||||
- '**.go'
|
||||
- '**.html'
|
||||
- 'Dockerfile'
|
||||
- 'Dockerfile.*'
|
||||
- 'docker-bake.hcl'
|
||||
- '.forgejo/workflows/*.yml'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
bake:
|
||||
runs-on: docker
|
||||
steps:
|
||||
- name: Prepare Registry FQDN
|
||||
id: registry
|
||||
run: |
|
||||
registry=${{ github.server_url }}
|
||||
registry=${registry##http*://}
|
||||
echo "registry=${registry}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Login to Container Registry
|
||||
uses: https://code.forgejo.org/docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ steps.registry.outputs.registry }}
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.TOKEN }}
|
||||
|
||||
- name: Checkout
|
||||
uses: https://code.forgejo.org/actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: https://code.forgejo.org/docker/setup-buildx-action@v3
|
||||
|
||||
- name: Extract metadata
|
||||
id: meta
|
||||
uses: https://code.forgejo.org/docker/metadata-action@v5
|
||||
with:
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
|
||||
- name: Build and push
|
||||
uses: https://code.forgejo.org/docker/bake-action@v6
|
||||
with:
|
||||
source: .
|
||||
env:
|
||||
TAG: ${{ steps.meta.outputs.tags }}
|
|
@ -3,6 +3,7 @@ package tweeter
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"html"
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
@ -80,7 +81,7 @@ func (app App) SendToWebhook(tweets []*ts.Tweet) {
|
|||
tweetText = strings.ReplaceAll(tweetText, video.URL, "")
|
||||
}
|
||||
|
||||
mainEmbed.SetText(strings.TrimSpace(tweetText))
|
||||
mainEmbed.SetText(html.UnescapeString(strings.TrimSpace(tweetText)))
|
||||
|
||||
for _, data := range webhooksToSend {
|
||||
err := sendRequest(app.config.Webhook, data)
|
||||
|
|
|
@ -1,13 +1,19 @@
|
|||
username = ""
|
||||
password = "asd123"
|
||||
#proxyaddr = "socks5://localhost:5555"
|
||||
hostURL = "https://my.domain.tld"
|
||||
|
||||
#usewebserver = false
|
||||
indextarget = "https://discord.gg/Kw4MFGxYEj" # Optional
|
||||
hostURL = "https://my.domain.tld" # Can be omitted if not using webserver
|
||||
|
||||
webhook = "https://domain.tld/api/webhooks/"
|
||||
|
||||
channels = [
|
||||
"NinEverything",
|
||||
"NintendoEurope",
|
||||
"NintendoAmerica",
|
||||
]
|
||||
|
||||
# Binary representation for efficient filtering
|
||||
# Bit from left to right (most to least significant bit): IsSelfThread, IsRetweet, IsReply, IsPin, IsQuoted
|
||||
filter = [
|
||||
|
|
|
@ -8,8 +8,8 @@ variable "TAG" {
|
|||
function "generate_tags" {
|
||||
params = [images, versions]
|
||||
result = distinct(flatten(
|
||||
[for i in split(",", images) :
|
||||
[for v in split(",", versions) :
|
||||
[for i in split(",", replace(images, "\n", ",")) :
|
||||
[for v in split(",", replace(versions, "\n", ",")) :
|
||||
"${i}:${v}"
|
||||
]
|
||||
]))
|
||||
|
|
|
@ -20,6 +20,7 @@ type Config struct {
|
|||
WebPort uint16
|
||||
UserAgents []string
|
||||
NitterBase string
|
||||
IndexTarget string
|
||||
}
|
||||
|
||||
func ConfigFromFile(filePath string) (*Config, error) {
|
||||
|
|
|
@ -72,12 +72,19 @@ func New(config *config.Config, scraper *ts.Scraper) (*WebServer, error) {
|
|||
WriteTimeout: 30 * time.Second,
|
||||
},
|
||||
}
|
||||
sm.HandleFunc("GET /", ws.handleIndex)
|
||||
sm.HandleFunc("GET /avatar/{username}", ws.handleAvatar)
|
||||
sm.HandleFunc("GET /tweet/{id}", ws.handleTweet)
|
||||
sm.HandleFunc("GET /video/{id}", ws.handleVideo)
|
||||
return ws, nil
|
||||
}
|
||||
|
||||
func (ws WebServer) handleIndex(w http.ResponseWriter, r *http.Request) {
|
||||
if ws.config.IndexTarget != "" {
|
||||
http.Redirect(w, r, ws.config.IndexTarget, http.StatusPermanentRedirect)
|
||||
}
|
||||
}
|
||||
|
||||
func (ws WebServer) handleAvatar(w http.ResponseWriter, r *http.Request) {
|
||||
username := r.PathValue("username")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue