2025-02-23 10:00:15 -04:00
2025-02-23 09:49:57 -04:00
2025-02-23 09:59:40 -04:00
2025-02-23 09:59:40 -04:00
2025-02-23 09:49:10 -04:00
2025-02-23 09:49:31 -04:00

Telegram Bot Repository Template

This README serves as a guide and template for setting up new Telegram bot projects. Follow the instructions below to get your bot up and running.

Introduction

<<Introduction>> This repository contains a basic template for developing Telegram bots. It includes essential scripts, configuration files, and documentation to help you get started quickly.

Prerequisites

<<Prerequisites>>

Before setting up your bot, ensure you have the following installed:

  • go: The go programming for running go code.
  • Telegram Bot Token: Obtain it by creating a new bot via BotFather on Telegram.

Setup Instructions

<<Setup Instructions>>

Clone the Repository

To get started, clone this repository to your local machine:

git clone https://github.com/yourusername/telegram-bot-template.git
cd telegram-bot-template

Install Dependencies

Install all required dependencies using go tools:

go mod tidy

Configure Your Bot

Create a .env file in the root directory and add your Telegram bot token:

#.env file example

BOT_TOKEN=yout_bot_token_goes_here
NATS_SERVICE_URL=natsuri:4222
TGBUSER_SERVICE_URL=localhost:3001 // needed to start svc
ENV=development                    // define log level on start
ADMINS=admin_ids_comma_separated   // id for admins, those will not need auth
RATE_LIMIT_SEC=12                  // amount of time to limit hits in sec
RATE_LIMIT_AMOUNT=2                // amount of hit limits in x times

AI_SERVER_URI=http://10.0.0.164
AI_CHAT_SERVER_PORT=11434
AI_CHAT_MODEL=deepseek-r1:8b
AI_CHAT_MODEL_FAST=llama3.2:latest
AI_CHAT_IMAGE=llava:7b

AI_TRANSCRIBE_SERVER_PORT=8080
AI_TRANSCRIBE_MODEL=whisper-1

Running the Bot

<<Running the Bot>>

To start the bot, execute one of the following commands

If the .env Vars ar e in the environment is dafe to run:

go run cmd/bot/.

Else you can run though Makefile with target run-local

The Makefile populate .env, build and run the source code, on each run the clean target will be called.

  make run-local

Your bot should now be running locally.

Description

<<Description>>

This is a template Telegram bot designed to be shared across various projects. It includes ready-to-use handlers for commands or queries, serving as examples to simplify development. The bot is built using the current version of the go-telegram/bot library, ensuring up-to-date functionality and integration.

In the functions added for the template you can find things like:

  • Message Handlers
  • Command Handlers
  • Callback Query Handlers
  • Interactions Handlers
  • Photos Hanlder
  • Voice Note Handler
  • Location Handler
  • Document Handlers
  • Middlewares

    • Singleflight
    • Loging
    • Rate Limiting
    • Auth Func
  • Helpers

    • Auth
    • File
    • Photo
    • Keyboard
    • Folder creation to handle photos voice or documents

This template heavily relies on the /maximo/telegram-base-bot/src/branch/master/tgbuser microservice for handling user authentication and permissions.

As The current date theres still a TODO on the WebApp part of the bot for serving and templating an example for miniApps

Description
No description provided
Readme 76 KiB
Languages
Go 91.6%
Makefile 4.4%
HTML 2.5%
Dockerfile 1.5%