11 Commits

Author SHA1 Message Date
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
18 changed files with 145 additions and 41 deletions
+50
View File
@@ -0,0 +1,50 @@
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'
+24
View File
@@ -0,0 +1,24 @@
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
+4
View File
@@ -0,0 +1,4 @@
version: "2"
run:
timeout: 5m
+12 -17
View File
@@ -1,28 +1,23 @@
# anon3anon
# :performing_arts: anon3anon [![Github release](https://img.shields.io/github/release/nightnoryu/anon3anon.svg)](https://github.com/nightnoryu/anon3anon/releases) [![Build Status](https://github.com/nightnoryu/anon3anon/actions/workflows/check-go.yml/badge.svg)](https://github.com/nightnoryu/anon3anon/actions/workflows/check-go.yml) [![Go Report Card](https://goreportcard.com/badge/github.com/nightnoryu/anon3anon)](https://goreportcard.com/report/github.com/nightnoryu/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.
Currently running at https://t.me/meme_me_a_meme_bot for my channel.
---
[![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
## Local development
Prerequisites:
1. Linux
2. Git
3. Docker
4. (optional) [BrewKit](https://github.com/ispringtech/brewkit)
1. Git
2. Docker
3. [bkit](https://github.com/nightnoryu/bkit)
Firstly, clone the repository into your `$GOPATH`:
```shell
mkdir -p $GOPATH/src/github.com/nightnoryu
cd $GOPATH/src/github.com/nightnoryu
git clone git@github.com:nightnoryu/anon3anon.git
cd anon3anon
```
@@ -30,10 +25,7 @@ cd anon3anon
Then build the project:
```shell
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
bkit build
```
After that, copy the `docker-compose.override.example.yml` to `docker-compose.override.yml` and set the environment variables:
@@ -46,6 +38,9 @@ services:
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:
```shell
View File
+1 -1
View File
@@ -1,4 +1,4 @@
local project = import 'brewkit/project.libsonnet';
local project = import 'bkit/project.libsonnet';
local appIDs = [
"anon3anon",
+4
View File
@@ -0,0 +1,4 @@
{
gobuilder: "golang:1.24-alpine",
golangcilint: "golangci/golangci-lint:v2.1-alpine",
}
@@ -18,10 +18,10 @@ local gocache = [
{
project(appIDs):: {
apiVersion: "brewkit/v1",
apiVersion: "bkit/v1",
targets: {
all: ["modules", "build"],
all: ["modules", "build", "check"],
} + {
modules: ["gotidy", "modulesvendor"],
@@ -62,6 +62,30 @@ local gocache = [
}
}
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: {
from: images.gobuilder,
-3
View File
@@ -1,3 +0,0 @@
{
gobuilder: "golang:1.24.2"
}
+4 -4
View File
@@ -5,9 +5,9 @@ import (
"os"
"os/signal"
"github.com/nightnoryu/anon3anon/pkg/anon3anon/infrastructure/jsonlog"
"github.com/nightnoryu/anon3anon/pkg/anon3anon/infrastructure/telegram/handler"
"github.com/nightnoryu/anon3anon/pkg/anon3anon/infrastructure/telegram/middleware"
"github.com/nightnoryu/anon3anon/pkg/infrastructure/jsonlog"
"github.com/nightnoryu/anon3anon/pkg/infrastructure/telegram/handler"
"github.com/nightnoryu/anon3anon/pkg/infrastructure/telegram/middleware"
"github.com/go-telegram/bot"
)
@@ -48,7 +48,7 @@ func initBotOptions(conf *config, logger jsonlog.Logger) []bot.Option {
return []bot.Option{
bot.WithMiddlewares(middleware.NewLoggingMiddleware(logger)),
bot.WithMessageTextHandler("/start", bot.MatchTypeExact, startCommandHandler),
bot.WithMessageTextHandler("start", bot.MatchTypeCommand, startCommandHandler),
bot.WithDefaultHandler(anonymousMessagesHandler),
}
}
+1 -1
View File
@@ -3,7 +3,7 @@ module github.com/nightnoryu/anon3anon
go 1.24
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/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.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
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.13.3/go.mod h1:i2TRs7fXWIeaceF3z7KzsMt/he0TwkVC680mvdTFYeM=
github.com/go-telegram/bot v1.15.0 h1:/ba5pp084MUhjR5sQDymQ7JNZ001CQa7QjtxLWcuGpg=
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/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -14,11 +14,11 @@ var fieldMap = logrus.FieldMap{
}
type Logger interface {
WithField(key string, value interface{}) Logger
WithField(key string, value any) Logger
Info(...interface{})
Error(error, ...interface{})
FatalError(error, ...interface{})
Info(...any)
Error(error, ...any)
FatalError(error, ...any)
}
type Config struct {
@@ -42,14 +42,14 @@ type logger struct {
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)}
}
func (l *logger) Error(err error, args ...interface{}) {
l.FieldLogger.WithError(err).Error(args)
func (l *logger) Error(err error, args ...any) {
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...)
}
@@ -2,8 +2,9 @@ package handler
import (
"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/models"
@@ -15,6 +16,11 @@ func NewAnonymousMessagesHandler(logger jsonlog.Logger, ownerChatId int) bot.Han
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{
ChatID: ownerChatId,
FromChatID: update.Message.Chat.ID,
@@ -3,7 +3,7 @@ package handler
import (
"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/models"
@@ -4,7 +4,7 @@ import (
"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/models"