Compare commits
18 Commits
858fbb73c1
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c142cf6c2 | |||
| 0126d0272a | |||
| 9807b624ba | |||
| ec4e1e93cb | |||
| 9a12fd063e | |||
| 6774c2f631 | |||
| eccef756a0 | |||
| 00d33aa41d | |||
| 60746f8824 | |||
| dd358d2c13 | |||
| e4e3859277 | |||
| 8509ec9d33 | |||
| 3c98b8b9b7 | |||
| 8c5698f993 | |||
| 85a8ccb57d | |||
| a74a4d46ee | |||
| e0a3d165e1 | |||
| 7ff184720d |
@@ -0,0 +1,33 @@
|
||||
name: Check Go code
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Build and test
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.25.x'
|
||||
cache: false
|
||||
|
||||
- name: Download dependencies
|
||||
run: go mod download
|
||||
|
||||
- name: Run build
|
||||
run: go build ./cmd/anon3anon/
|
||||
|
||||
- name: Run tests
|
||||
run: go test ./...
|
||||
@@ -1,50 +0,0 @@
|
||||
name: Check Go code
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- '**.go'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
name: Build and test
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.24.x'
|
||||
|
||||
- name: Download dependencies
|
||||
run: go mod download
|
||||
|
||||
- name: Run tests
|
||||
run: go test ./...
|
||||
|
||||
lint:
|
||||
name: Lint
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.24.x'
|
||||
|
||||
- name: Run golangci-lint
|
||||
uses: golangci/golangci-lint-action@v8
|
||||
with:
|
||||
version: 'v2.1'
|
||||
@@ -1,24 +0,0 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
|
||||
release:
|
||||
name: Automatic release
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Create the release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
generate_release_notes: true
|
||||
+3
-4
@@ -1,4 +1,3 @@
|
||||
.idea
|
||||
vendor
|
||||
bin
|
||||
docker-compose.override.yml
|
||||
/.idea/
|
||||
/vendor/
|
||||
/docker-compose.override.yml
|
||||
|
||||
@@ -2,3 +2,69 @@ version: "2"
|
||||
|
||||
run:
|
||||
timeout: 5m
|
||||
issues-exit-code: 1
|
||||
|
||||
linters:
|
||||
enable:
|
||||
- errcheck
|
||||
- govet
|
||||
- ineffassign
|
||||
- staticcheck
|
||||
- unused
|
||||
- bodyclose
|
||||
- importas
|
||||
- dogsled
|
||||
- dupl
|
||||
- gochecknoinits
|
||||
- gocognit
|
||||
- gocritic
|
||||
- gocyclo
|
||||
- revive
|
||||
- gosec
|
||||
- misspell
|
||||
- nakedret
|
||||
- prealloc
|
||||
- unconvert
|
||||
- whitespace
|
||||
- rowserrcheck
|
||||
- goconst
|
||||
- asciicheck
|
||||
- nestif
|
||||
- copyloopvar
|
||||
- sqlclosecheck
|
||||
|
||||
settings:
|
||||
govet:
|
||||
enable:
|
||||
- shadow
|
||||
|
||||
gocritic:
|
||||
disabled-checks:
|
||||
- sloppyReassign
|
||||
- whyNoLint
|
||||
enabled-tags:
|
||||
- experimental
|
||||
- opinionated
|
||||
|
||||
exclusions:
|
||||
generated: lax
|
||||
presets:
|
||||
- comments
|
||||
- common-false-positives
|
||||
- std-error-handling
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
|
||||
formatters:
|
||||
enable:
|
||||
- gofmt
|
||||
- goimports
|
||||
|
||||
exclusions:
|
||||
generated: lax
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
|
||||
@@ -1,31 +1,26 @@
|
||||
# :performing_arts: anon3anon [](https://github.com/nightnoryu/anon3anon/releases) [](https://github.com/nightnoryu/anon3anon/actions/workflows/check-go.yml) [](https://goreportcard.com/report/github.com/nightnoryu/anon3anon)
|
||||
# :performing_arts: anon3anon
|
||||
|
||||
Telegram bot for anonymous messages.
|
||||
|
||||
Currently running at https://t.me/meme_me_a_meme_bot for my channel.
|
||||
|
||||
## Local development
|
||||
|
||||
Prerequisites:
|
||||
|
||||
1. Git
|
||||
2. Docker
|
||||
3. [bkit](https://github.com/nightnoryu/bkit)
|
||||
3. [brewkit](https://github.com/ispringtech/brewkit)
|
||||
|
||||
Firstly, clone the repository into your `$GOPATH`:
|
||||
Clone the repository:
|
||||
|
||||
```shell
|
||||
mkdir -p $GOPATH/src/github.com/nightnoryu
|
||||
cd $GOPATH/src/github.com/nightnoryu
|
||||
|
||||
git clone git@github.com:nightnoryu/anon3anon.git
|
||||
git clone ssh://git@gitea.nightnoryu.com:2222/nightnoryu/anon3anon.git
|
||||
cd anon3anon
|
||||
```
|
||||
|
||||
Then build the project:
|
||||
|
||||
```shell
|
||||
bkit build
|
||||
brewkit build
|
||||
```
|
||||
|
||||
After that, copy the `docker-compose.override.example.yml` to `docker-compose.override.yml` and set the environment variables:
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
build:
|
||||
dockerfile: docker/Dockerfile-amvera
|
||||
@@ -0,0 +1 @@
|
||||
/anon3anon
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
gobuilder: "golang:1.24-alpine",
|
||||
golangcilint: "golangci/golangci-lint:v2.1-alpine",
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
local project = import 'bkit/project.libsonnet';
|
||||
local project = import 'brewkit/project.libsonnet';
|
||||
|
||||
local appIDs = [
|
||||
"anon3anon",
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
gobuilder: "golang:1.25-alpine",
|
||||
golangcilint: "golangci/golangci-lint:v2.4-alpine",
|
||||
}
|
||||
@@ -18,7 +18,7 @@ local gocache = [
|
||||
|
||||
{
|
||||
project(appIDs):: {
|
||||
apiVersion: "bkit/v1",
|
||||
apiVersion: "brewkit/v1",
|
||||
|
||||
targets: {
|
||||
all: ["modules", "build", "check"],
|
||||
@@ -3,6 +3,5 @@ services:
|
||||
container_name: anon3anon
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/Dockerfile-local
|
||||
volumes:
|
||||
- "./bin:/app/bin"
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
FROM golang:1.24.2 AS build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN go mod download
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o /app/bin/anon3anon ./cmd/anon3anon
|
||||
|
||||
FROM alpine:latest AS run
|
||||
|
||||
COPY --from=build /app/bin/anon3anon /app/bin/
|
||||
|
||||
CMD ["/app/bin/anon3anon"]
|
||||
@@ -1,6 +1,6 @@
|
||||
module github.com/nightnoryu/anon3anon
|
||||
|
||||
go 1.24
|
||||
go 1.25
|
||||
|
||||
require (
|
||||
github.com/go-telegram/bot v1.15.0
|
||||
|
||||
@@ -10,19 +10,19 @@ import (
|
||||
"github.com/go-telegram/bot/models"
|
||||
)
|
||||
|
||||
func NewAnonymousMessagesHandler(logger jsonlog.Logger, ownerChatId int) bot.HandlerFunc {
|
||||
func NewAnonymousMessagesHandler(logger jsonlog.Logger, ownerChatID int) bot.HandlerFunc {
|
||||
return func(ctx context.Context, b *bot.Bot, update *models.Update) {
|
||||
if update.Message == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if ownerChatId == 0 {
|
||||
if ownerChatID == 0 {
|
||||
logger.Info(fmt.Sprintf("owner chat ID not set. set to %d to use the last chat", update.Message.Chat.ID))
|
||||
return
|
||||
}
|
||||
|
||||
params := &bot.CopyMessageParams{
|
||||
ChatID: ownerChatId,
|
||||
ChatID: ownerChatID,
|
||||
FromChatID: update.Message.Chat.ID,
|
||||
MessageID: update.Message.ID,
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ func NewLoggingMiddleware(logger jsonlog.Logger) bot.Middleware {
|
||||
WithField(usernameField, update.Message.From.Username)
|
||||
|
||||
text := update.Message.Text
|
||||
if len(update.Message.Caption) > 0 {
|
||||
if update.Message.Caption != "" {
|
||||
text = update.Message.Caption
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user