29 Commits

Author SHA1 Message Date
nightnoryu 9c142cf6c2 Remove lint for now
Check Go code / Build and test (push) Successful in 31s
2026-05-24 00:17:35 +03:00
nightnoryu 0126d0272a Update the action
Check Go code / Build, test and lint (push) Has been cancelled
2026-05-24 00:12:23 +03:00
nightnoryu 9807b624ba Add lint action
Check Go code / Lint (push) Has been cancelled
Check Go code / Build and test (push) Has been cancelled
2026-05-24 00:05:32 +03:00
nightnoryu ec4e1e93cb Fix version again
Check Go code / Build and test (push) Has been cancelled
2026-05-24 00:00:23 +03:00
nightnoryu 9a12fd063e Fix versions
Check Go code / Build and test (push) Has been cancelled
2026-05-23 23:58:38 +03:00
nightnoryu 6774c2f631 Update README
Check Go code / Build and test (push) Has been cancelled
2026-05-23 23:55:39 +03:00
nightnoryu eccef756a0 Remove dokku settings 2026-05-23 23:55:32 +03:00
nightnoryu 00d33aa41d Update workflows 2026-05-23 23:55:26 +03:00
nightnoryu 60746f8824 Fix linter warnings
Check Go code / Build and test (push) Has been cancelled
Check Go code / Lint (push) Has been cancelled
Release / Automatic release (push) Has been cancelled
2025-10-24 13:31:04 +03:00
nightnoryu dd358d2c13 Update linter config 2025-10-24 13:27:38 +03:00
nightnoryu e4e3859277 Update workflow config 2025-10-24 13:24:50 +03:00
nightnoryu 8509ec9d33 Fix linter config 2025-10-24 13:22:55 +03:00
nightnoryu 3c98b8b9b7 Update to Go 1.25 2025-10-24 13:19:24 +03:00
nightnoryu 8c5698f993 Update .gitignore 2025-10-23 12:37:46 +03:00
nightnoryu 85a8ccb57d Change to brewkit 2025-10-23 12:32:21 +03:00
nightnoryu a74a4d46ee Add dockerfile for dokku 2025-09-20 20:01:18 +03:00
nightnoryu e0a3d165e1 Move dockerfile for local development 2025-09-20 20:00:13 +03:00
nightnoryu 7ff184720d Remove dockerfile for amvera 2025-09-20 20:00:01 +03:00
nightnoryu 858fbb73c1 Bump go-telegram-bot version
Release / Automatic release (push) Has been cancelled
2025-06-02 21:33:09 +03:00
nightnoryu 02ec38e5ef Rename amvera config for .yml consistency 2025-06-02 21:26:45 +03:00
nightnoryu 09047de28e Auto-generate release notes in the action 2025-06-02 21:23:05 +03:00
nightnoryu 72ece0d100 Add automation actions 2025-06-02 21:13:28 +03:00
nightnoryu fc20b80d7b Update README 2025-06-02 21:03:52 +03:00
nightnoryu 984b5bbee9 Migrate to bkit, add linting 2025-06-02 21:01:01 +03:00
nightnoryu b1c34f77ce Change project structure a bit 2025-06-02 21:00:50 +03:00
nightnoryu 035045ce90 Update README.md 2025-05-31 09:29:17 +03:00
nightnoryu 3ad9a6274d Update README.md 2025-05-21 12:00:00 +03:00
nightnoryu d453ab3d64 Update README.md 2025-05-16 08:04:20 +03:00
nightnoryu 33d11fc849 Update README.md 2025-05-16 08:04:04 +03:00
20 changed files with 173 additions and 66 deletions
+33
View File
@@ -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 ./...
+3 -4
View File
@@ -1,4 +1,3 @@
.idea /.idea/
vendor /vendor/
bin /docker-compose.override.yml
docker-compose.override.yml
+70
View File
@@ -0,0 +1,70 @@
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$
+11 -21
View File
@@ -1,29 +1,19 @@
# anon3anon # :performing_arts: anon3anon
Telegram bot for anonymous messages 🎭✨ Telegram bot for anonymous messages.
Currently deployed and working at https://t.me/meme_me_a_meme_bot for my channel. ## Local development
---
[![Go Report Card](https://goreportcard.com/badge/github.com/nightnoryu/anon3anon)](https://goreportcard.com/report/github.com/nightnoryu/anon3anon)
[![GitHub License](https://img.shields.io/github/license/nightnoryu/anon3anon)](https://opensource.org/license/MIT)
## Building for local development
Prerequisites: Prerequisites:
1. Linux 1. Git
2. Git 2. Docker
3. Docker 3. [brewkit](https://github.com/ispringtech/brewkit)
4. (optional) [BrewKit](https://github.com/ispringtech/brewkit)
Firstly, clone the repository into your `$GOPATH`: Clone the repository:
```shell ```shell
mkdir -p $GOPATH/src/github.com/nightnoryu git clone ssh://git@gitea.nightnoryu.com:2222/nightnoryu/anon3anon.git
cd $GOPATH/src/github.com/nightnoryu
git clone git@github.com:nightnoryu/anon3anon.git
cd anon3anon cd anon3anon
``` ```
@@ -31,9 +21,6 @@ Then build the project:
```shell ```shell
brewkit build brewkit build
# Alternatively, if you don't want to use BrewKit, you can do it the old-fashioned way:
# go build -o ./bin/anon3anon ./cmd/anon3anon
``` ```
After that, copy the `docker-compose.override.example.yml` to `docker-compose.override.yml` and set the environment variables: After that, copy the `docker-compose.override.example.yml` to `docker-compose.override.yml` and set the environment variables:
@@ -46,6 +33,9 @@ services:
ANON3ANON_OWNER_CHAT_ID: 123 # ID of your chat with your bot ANON3ANON_OWNER_CHAT_ID: 123 # ID of your chat with your bot
``` ```
> [!NOTE]
> When launching the bot for the first time, leave `ANON3ANON_OWNER_CHAT_ID` empty and write a message to the bot. It will print the chat ID in the logs and after that you can set it up.
And you're set! Use `docker compose` to manage the application: And you're set! Use `docker compose` to manage the application:
```shell ```shell
-2
View File
@@ -1,2 +0,0 @@
build:
dockerfile: docker/Dockerfile-amvera
+1
View File
@@ -0,0 +1 @@
/anon3anon
+2 -1
View File
@@ -1,3 +1,4 @@
{ {
gobuilder: "golang:1.24.2" gobuilder: "golang:1.25-alpine",
golangcilint: "golangci/golangci-lint:v2.4-alpine",
} }
+25 -1
View File
@@ -21,7 +21,7 @@ local gocache = [
apiVersion: "brewkit/v1", apiVersion: "brewkit/v1",
targets: { targets: {
all: ["modules", "build"], all: ["modules", "build", "check"],
} + { } + {
modules: ["gotidy", "modulesvendor"], modules: ["gotidy", "modulesvendor"],
@@ -62,6 +62,30 @@ local gocache = [
} }
} }
for appID in appIDs for appID in appIDs
} + {
check: ["test", "lint"],
test: {
from: "gobase",
workdir: "/app",
cache: gocache,
command: "go test ./..."
},
lint: {
from: images.golangcilint,
workdir: "/app",
cache: gocache,
copy: [
copyFrom("gosources", "/app", "/app"),
copy(".golangci.yml", ".golangci.yml"),
],
env: {
GOCACHE: "/app/cache/go-build",
GOLANGCI_LINT_CACHE: "/app/cache/go-build",
},
command: "golangci-lint run"
},
} + { } + {
gobase: { gobase: {
from: images.gobuilder, from: images.gobuilder,
+4 -4
View File
@@ -5,9 +5,9 @@ import (
"os" "os"
"os/signal" "os/signal"
"github.com/nightnoryu/anon3anon/pkg/anon3anon/infrastructure/jsonlog" "github.com/nightnoryu/anon3anon/pkg/infrastructure/jsonlog"
"github.com/nightnoryu/anon3anon/pkg/anon3anon/infrastructure/telegram/handler" "github.com/nightnoryu/anon3anon/pkg/infrastructure/telegram/handler"
"github.com/nightnoryu/anon3anon/pkg/anon3anon/infrastructure/telegram/middleware" "github.com/nightnoryu/anon3anon/pkg/infrastructure/telegram/middleware"
"github.com/go-telegram/bot" "github.com/go-telegram/bot"
) )
@@ -48,7 +48,7 @@ func initBotOptions(conf *config, logger jsonlog.Logger) []bot.Option {
return []bot.Option{ return []bot.Option{
bot.WithMiddlewares(middleware.NewLoggingMiddleware(logger)), bot.WithMiddlewares(middleware.NewLoggingMiddleware(logger)),
bot.WithMessageTextHandler("/start", bot.MatchTypeExact, startCommandHandler), bot.WithMessageTextHandler("start", bot.MatchTypeCommand, startCommandHandler),
bot.WithDefaultHandler(anonymousMessagesHandler), bot.WithDefaultHandler(anonymousMessagesHandler),
} }
} }
-1
View File
@@ -3,6 +3,5 @@ services:
container_name: anon3anon container_name: anon3anon
build: build:
context: . context: .
dockerfile: docker/Dockerfile-local
volumes: volumes:
- "./bin:/app/bin" - "./bin:/app/bin"
-14
View File
@@ -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"]
+2 -2
View File
@@ -1,9 +1,9 @@
module github.com/nightnoryu/anon3anon module github.com/nightnoryu/anon3anon
go 1.24 go 1.25
require ( require (
github.com/go-telegram/bot v1.13.3 github.com/go-telegram/bot v1.15.0
github.com/kelseyhightower/envconfig v1.4.0 github.com/kelseyhightower/envconfig v1.4.0
github.com/sirupsen/logrus v1.9.3 github.com/sirupsen/logrus v1.9.3
) )
+2 -2
View File
@@ -1,8 +1,8 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-telegram/bot v1.13.3 h1:r2erpHI5rMQsR5TFWJ/XVqWHq9R228fcaejLFvXJsmM= github.com/go-telegram/bot v1.15.0 h1:/ba5pp084MUhjR5sQDymQ7JNZ001CQa7QjtxLWcuGpg=
github.com/go-telegram/bot v1.13.3/go.mod h1:i2TRs7fXWIeaceF3z7KzsMt/he0TwkVC680mvdTFYeM= github.com/go-telegram/bot v1.15.0/go.mod h1:i2TRs7fXWIeaceF3z7KzsMt/he0TwkVC680mvdTFYeM=
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8= github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -14,11 +14,11 @@ var fieldMap = logrus.FieldMap{
} }
type Logger interface { type Logger interface {
WithField(key string, value interface{}) Logger WithField(key string, value any) Logger
Info(...interface{}) Info(...any)
Error(error, ...interface{}) Error(error, ...any)
FatalError(error, ...interface{}) FatalError(error, ...any)
} }
type Config struct { type Config struct {
@@ -42,14 +42,14 @@ type logger struct {
logrus.FieldLogger logrus.FieldLogger
} }
func (l *logger) WithField(key string, value interface{}) Logger { func (l *logger) WithField(key string, value any) Logger {
return &logger{l.FieldLogger.WithField(key, value)} return &logger{l.FieldLogger.WithField(key, value)}
} }
func (l *logger) Error(err error, args ...interface{}) { func (l *logger) Error(err error, args ...any) {
l.FieldLogger.WithError(err).Error(args) l.FieldLogger.WithError(err).Error(args...)
} }
func (l *logger) FatalError(err error, args ...interface{}) { func (l *logger) FatalError(err error, args ...any) {
l.FieldLogger.WithError(err).Fatal(args...) l.FieldLogger.WithError(err).Fatal(args...)
} }
@@ -2,21 +2,27 @@ package handler
import ( import (
"context" "context"
"fmt"
"github.com/nightnoryu/anon3anon/pkg/anon3anon/infrastructure/jsonlog" "github.com/nightnoryu/anon3anon/pkg/infrastructure/jsonlog"
"github.com/go-telegram/bot" "github.com/go-telegram/bot"
"github.com/go-telegram/bot/models" "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) { return func(ctx context.Context, b *bot.Bot, update *models.Update) {
if update.Message == nil { if update.Message == nil {
return return
} }
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{ params := &bot.CopyMessageParams{
ChatID: ownerChatId, ChatID: ownerChatID,
FromChatID: update.Message.Chat.ID, FromChatID: update.Message.Chat.ID,
MessageID: update.Message.ID, MessageID: update.Message.ID,
} }
@@ -3,7 +3,7 @@ package handler
import ( import (
"context" "context"
"github.com/nightnoryu/anon3anon/pkg/anon3anon/infrastructure/jsonlog" "github.com/nightnoryu/anon3anon/pkg/infrastructure/jsonlog"
"github.com/go-telegram/bot" "github.com/go-telegram/bot"
"github.com/go-telegram/bot/models" "github.com/go-telegram/bot/models"
@@ -4,7 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
"github.com/nightnoryu/anon3anon/pkg/anon3anon/infrastructure/jsonlog" "github.com/nightnoryu/anon3anon/pkg/infrastructure/jsonlog"
"github.com/go-telegram/bot" "github.com/go-telegram/bot"
"github.com/go-telegram/bot/models" "github.com/go-telegram/bot/models"
@@ -27,7 +27,7 @@ func NewLoggingMiddleware(logger jsonlog.Logger) bot.Middleware {
WithField(usernameField, update.Message.From.Username) WithField(usernameField, update.Message.From.Username)
text := update.Message.Text text := update.Message.Text
if len(update.Message.Caption) > 0 { if update.Message.Caption != "" {
text = update.Message.Caption text = update.Message.Caption
} }