telegram-gemini-bot

command module
v0.3.94 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 30 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Telegram Gemini Bot

A telegram bot which answers to messages with Gemini API.

screenshot1
  • You can reply to messages for keeping the context of your conversation:
screenshot2 screenshot3
  • You can also upload photos with a caption as a prompt:
screenshot4
  • Generated text will be received part by part with streaming support:

streamed message


Prerequisites

Configurations

Create a configuration file:

$ cp config.json.sample config.json
$ $EDITOR config.json

and set your values:

{
  "google_generative_model": "gemini-3.6-flash",
  "google_generative_model_for_image_generation": "gemini-3.1-flash-lite-image",
  "google_generative_model_for_video_generation": "veo-3.1-lite-generate-preview",
  "google_generative_model_for_speech_generation": "gemini-3.1-flash-tts-preview",

  "allowed_telegram_users": ["user1", "user2"],
  "db_filepath": null,
  "answer_timeout_seconds": 180,
  "verbose": false,

  "telegram_bot_token": "123456:abcdefghijklmnop-QRSTUVWXYZ7890",
  "google_ai_api_key": "ABCDEFGHIJK1234567890"
}

You can get appropriate model names from here.

If db_filepath is given, all prompts and their responses will be logged to the SQLite3 file.

Using Infisical

You can use Infisical for saving & retrieving your bot token and api key:

{
  "google_generative_model": "gemini-3.6-flash",
  "google_generative_model_for_image_generation": "gemini-3.1-flash-lite-image",
  "google_generative_model_for_video_generation": "veo-3.1-lite-generate-preview",
  "google_generative_model_for_speech_generation": "gemini-3.1-flash-tts-preview",

  "allowed_telegram_users": ["user1", "user2"],
  "db_filepath": null,
  "answer_timeout_seconds": 180,
  "verbose": false,

  "infisical": {
    "client_id": "012345-abcdefg-987654321",
    "client_secret": "aAbBcCdDeEfFgG0123456789xyzwXYZW",

    "project_id": "012345abcdefg",
    "environment": "dev",
    "secret_type": "shared",

    "telegram_bot_token_key_path": "/path/to/your/KEY_TO_TELEGRAM_BOT_TOKEN",
    "google_ai_api_key_key_path": "/path/to/your/KEY_TO_GOOGLE_AI_API_KEY"
  }
}

Build

$ go build

Run

Run the built binary with the config file's path:

$ ./telegram-gemini-bot path-to/config.json

Run as a systemd service

Create a systemd service file:

[Unit]
Description=Telegram Gemini Bot
After=syslog.target
After=network.target

[Service]
Type=simple
User=ubuntu
Group=ubuntu
WorkingDirectory=/dir/to/telegram-gemini-bot
ExecStart=/dir/to/telegram-gemini-bot/telegram-gemini-bot /path/to/config.json
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

and systemctl enable|start|restart|stop the service.

Commands

  • /image <PROMPT> for image generation.
  • /video <PROMPT> for video generation.
  • /speech <PROMPT> for speech generation.
  • /google <PROMPT> for generation with grounding (Google Search).
  • /stats for various statistics of this bot.
  • /help for help message.

Todos / Known Issues

  • Handle markdown texts gracefully.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址