Skip to content

yanzay/tbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Oct 20, 2023
cf1da89 · Oct 20, 2023
Dec 3, 2019
Oct 19, 2023
Mar 30, 2019
Mar 30, 2019
Mar 30, 2019
May 15, 2020
Mar 30, 2019
Aug 13, 2020
May 5, 2020
May 15, 2020
May 3, 2019
Apr 13, 2019
Oct 19, 2023
Mar 30, 2019
Dec 6, 2019
Oct 19, 2023
Oct 19, 2023
May 15, 2020

Repository files navigation

tbot - Telegram Bot Server GoDoc Go Report Card GitHub Actions

logo

Features

  • Full Telegram Bot API 4.7 support
  • Zero dependency
  • Type-safe API client with functional options
  • Capture messages by regexp
  • Middlewares support
  • Can be used with go modules
  • Support for external logger
  • MIT licensed

Installation

With go modules:

go get github.com/yanzay/tbot/v2

Without go modules:

go get github.com/yanzay/tbot

Support

Join telegram group to get support or just to say thank you.

Documentation

Documentation: https://yanzay.github.io/tbot-doc/.

Full specification: godoc.

Usage

Simple usage example:

package main

import (
	"log"
	"os"
	"time"

	"github.com/yanzay/tbot/v2"
)

func main() {
	bot := tbot.New(os.Getenv("TELEGRAM_TOKEN"))
	c := bot.Client()
	bot.HandleMessage(".*yo.*", func(m *tbot.Message) {
		c.SendChatAction(m.Chat.ID, tbot.ActionTyping)
		time.Sleep(1 * time.Second)
		c.SendMessage(m.Chat.ID, "hello!")
	})
	err := bot.Start()
	if err != nil {
		log.Fatal(err)
	}
}

Examples

Please take a look inside examples folder.