REPOSITORY / ScuroNeko/Laniakea

Compare commits

DIFF REPOSITORY

Compare commits

..
Author SHA1 Message Date
ScuroNeko db31246eeb retract 1.0.0 rc 5 2026-03-23 13:19:39 +03:00
ScuroNeko d04c91342b small close fix; logo in readme 2026-03-23 13:13:47 +03:00
ScuroNeko 2e14d8b5df small close fix; logo in readme 2026-03-23 12:59:18 +03:00
6 changed files with 23 additions and 10 deletions
+2
View File
@@ -1,5 +1,7 @@
# Laniakea
![Laniakea](assets/logo.jpg)
[![Go Version](https://img.shields.io/badge/Go-1.24+-00ADD8?logo=go&style=flat-square)](https://go.dev/)
[![License: GPL-3.0](https://img.shields.io/badge/License-GPL%203.0-blue.svg?style=flat-square)](LICENSE)
![Gitea Release](https://img.shields.io/gitea/v/release/ScuroNeko/Laniakea?gitea_url=https%3A%2F%2Fgit.nix13.pw&sort=semver&display_name=release&style=flat-square&color=purple&link=https%3A%2F%2Fgit.nix13.pw%2FScuroNeko%2FLaniakea%2Freleases)
+3 -1
View File
@@ -1,10 +1,12 @@
# Laniakea
![Laniakea](assets/logo.jpg)
[![Go Version](https://img.shields.io/badge/Go-1.24+-00ADD8?logo=go&style=flat-square)](https://go.dev/)
[![License: GPL-3.0](https://img.shields.io/badge/License-GPL%203.0-blue.svg?style=flat-square)](LICENSE)
![Gitea Release](https://img.shields.io/gitea/v/release/ScuroNeko/Laniakea?gitea_url=https%3A%2F%2Fgit.nix13.pw&sort=semver&display_name=release&style=flat-square&color=purple&link=https%3A%2F%2Fgit.nix13.pw%2FScuroNeko%2FLaniakea%2Freleases)
Легковесная, простая в использовании и производительная обёртка для Telegram Bot API на Go. Она упрощает разработку ботов благодаря чистой системе плагинов, поддержке中间件, автоматической генерации команд и встроенному ограничителю скорости запросов.
Легковесная, простая в использовании и производительная обёртка для Telegram Bot API на Go. Она упрощает разработку ботов благодаря чистой системе плагинов, поддержке Middleware, автоматической генерации команд и встроенному рейтлимитеру.
[English](README.md)
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 297 KiB

+14 -7
View File
@@ -7,6 +7,7 @@ import (
"sort"
"strings"
"sync"
"time"
"git.nix13.pw/scuroneko/extypes"
"git.nix13.pw/scuroneko/laniakea/tgapi"
@@ -162,7 +163,9 @@ func NewBot[T any](opts *BotOpts) *Bot[T] {
// Fetch bot info to validate token and get username
u, err := api.GetMe()
if err != nil {
_ = bot.Close()
closeCtx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
_ = bot.Close(closeCtx)
bot.logger.Fatal(err)
}
bot.username = Val(u.Username, "")
@@ -176,24 +179,28 @@ func NewBot[T any](opts *BotOpts) *Bot[T] {
// Close gracefully shuts down bot-owned resources.
//
// Closes:
// The provided context is used to close the API client's long-polling request.
// Upload shutdown is not context-aware and still waits for pending uploads.
//
// Close shuts down, in order:
// - Uploader (waits for pending uploads)
// - API client
// - API client long-poll request via ctx
// - API client internals
// - RequestLogger (if enabled)
// - Main logger
//
// RunWithContext does not call Close automatically. The caller is responsible
// for invoking Close after RunWithContext returns to release these resources.
//
// Returns a joined error containing all shutdown failures, if any.
func (bot *Bot[T]) Close() error {
// Close returns a joined error containing all shutdown failures, if any.
func (bot *Bot[T]) Close(ctx context.Context) error {
var e []error
if err := bot.uploader.Close(); err != nil {
bot.logger.Errorln(err)
e = append(e, err)
}
if _, err := bot.api.Close(); err != nil {
if _, err := bot.api.CloseWithContext(ctx); err != nil {
bot.logger.Errorln(err)
e = append(e, err)
}
@@ -476,7 +483,7 @@ func (bot *Bot[T]) AddDatabaseLoggerWriter(writer DbLogger[T]) *Bot[T] {
// go bot.RunWithContext(ctx)
// // ... later ...
// cancel() // triggers graceful shutdown
// _ = bot.Close()
// _ = bot.Close(context.Background())
func (bot *Bot[T]) RunWithContext(ctx context.Context) {
if len(bot.prefixes) == 0 {
bot.logger.Fatalln("no prefixes defined")
+2
View File
@@ -2,6 +2,8 @@ module git.nix13.pw/scuroneko/laniakea
go 1.26
retract v1.0.0-rc.5
require (
git.nix13.pw/scuroneko/extypes v1.2.2
git.nix13.pw/scuroneko/slog v1.1.2
+2 -2
View File
@@ -1,9 +1,9 @@
package utils
const (
VersionString = "1.0.0-rc.4"
VersionString = "1.0.0-rc.5"
VersionMajor = 1
VersionMinor = 0
VersionPatch = 0
VersionBeta = 4
VersionBeta = 5
)