This commit is contained in:
glitch 2025-07-13 16:37:05 +05:00
parent 2c094876c8
commit 9d890ea675
8 changed files with 92 additions and 0 deletions

1
.gitignore vendored
View file

@ -189,3 +189,4 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
config.toml

7
config.example.toml Normal file
View file

@ -0,0 +1,7 @@
[telegram]
api_key = "example"
admin_id = "000000"
[storage]
type = "local" #local, s3
path = "data/storage"

29
config/config.go Normal file
View file

@ -0,0 +1,29 @@
package config
import (
toml "github.com/BurntSushi/toml"
)
type TelegramConfig struct {
APIKey string `toml:"api_key"`
AdminID string `toml:"admin_id"`
}
type StorageConfig struct {
Type string `toml:"type"`
Path string `toml:"path"`
}
type Config struct {
Telegram TelegramConfig
Storage StorageConfig
}
func LoadConfig(path string) (*Config, error) {
var cfg Config
_, err := toml.DecodeFile(path, &cfg)
if err != nil {
return nil, err
}
return &cfg, nil
}

5
go.mod Normal file
View file

@ -0,0 +1,5 @@
module git.iamglitch.cc/glitch/bookmate
go 1.24.4
require github.com/BurntSushi/toml v1.5.0

2
go.sum Normal file
View file

@ -0,0 +1,2 @@
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=

44
internal/bot/handler.go Normal file
View file

@ -0,0 +1,44 @@
package bot
import (
"context"
"git.iamglitch.cc/glitch/bookmate/internal/service"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
)
type Handler struct {
bot *tgbotapi.BotAPI
service *service.Service
}
func newHandler(bot *tgbotapi.BotAPI, svc *service.Service) *Handler {
return &Handler{
bot: bot,
service: svc,
}
}
func (h *Handler) HandleUpdate(ctx context.Context, update tgbotapi.Update) {
if update.Message != nil {
h.handleMessage(ctx, update.Message)
}
if update.CallbackQuery != nil {
h.handleCallback(ctx, update.CallbackQuery)
}
}
func (h *Handler) handleMessage(ctx context.Context, msg *tgbotapi.Message) {
if msg.IsCommand() {
h.handleCommand(ctx, msg)
}
}
func (h *Handler) handleCommand(ctx context.Context, msg *tgbotapi.Message) {
panic("unimplemented")
}
func (h *Handler) handleCallback(ctx context.Context, cb *tgbotapi.CallbackQuery) {
panic("unimplemented")
}

0
internal/bot/router.go Normal file
View file

View file

@ -0,0 +1,4 @@
package service
type Service struct {
}