Telego
Template for creating Telegram Bots with clean architecture.
Install / Use
/learn @mitinarseny/TelegoREADME
Table of Contents
Usage
Create Bot
Create new bot with @BotFather.
Copy Token
Create file ./docker-compose.secret.yaml with the following structure and paste the token from @BotFather:
# ./docker-compose.secret.yaml
version: '3.7'
services:
bot:
environment:
TELEGO_BOT_TOKEN: "12345689:ABCdEFgHi1JKLMNO23P45rSTU6vw78xyz-a"
Notifier
You can enable Telegram notifications on your bot's status (UP or DOWN) by creating another bot and a group chat with this bot. Then edit ./docker-compose.secret.yaml:
# ...
environment:
TELEGO_NOTIFIER_BOT_TOKEN: "<token>"
TELEGO_NOTIFIER_CHAT_ID: "<chat_id>"
Code
Logic
Main logic of the bot should be implemented inside Configure function in bot/bot.go:
func Configure(b *tb.Bot) (*tb.Bot, error) {
h := handlers.Handler{Bot: b}
b.Handle("/hello", withLogMsg(h.HandleHello))
return b, nil
}
func withLogMsg(handler func(*tb.Message) error) func(message *tb.Message) {
return func(m *tb.Message) {
if err := handler(m); err != nil {
log.WithFields(log.Fields{
"context": "BOT",
"handler": handler,
}).Error(err)
}
}
}
Handlers
All hanlders should be placed in bot/handlers/. Here is an example from hello.go:
func (b *Handler) HandleHello(m *tb.Message) error {
_, err := b.Bot.Send(m.Sender, "Hello, world!")
return err
}
Run
docker-compose \
-f docker-compose.yaml \
-f docker-compose.secret.yaml \
up --build -d
Debug
You can debug your code with Delve debugger.
Build & Run
To enable dlv debugger inside the container run:
docker-compose \
-f docker-compose.yaml \
-f docker-compose.dev.yaml \
-f docker-compose.secret.yaml \
up --build -d
Attach
${GOPATH}/bin/dlv connect localhost:40000
Related Skills
node-connect
348.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
prose
348.0kOpenProse VM skill pack. Activate on any `prose` command, .prose files, or OpenProse mentions; orchestrates multi-agent workflows.
frontend-design
108.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
348.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
