Skip to content

Sagleft/tgbot-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tgbot-handler

Telebot wrapper

Getting started

go get github.com/Sagleft/tgbot-handler

usage:

package main

import (
    tb "gopkg.in/telebot.v3"
    tgbothandler "github.com/Sagleft/tgbot-handler"
)

func main() {
    botToken := "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"
    h, err := tgbothandler.New(botToken)
	if err != nil {
		log.Fatalln(err)
	}

    callbacks := []tgbothandler.Callback{
        {
            Endpoint: "/start",
            CallbackFunc: func(c tb.Context) error {
                return c.Reply("Hello!")
            },
        },
        {
            Endpoint: tb.OnText,
            CallbackFunc: func(c tb.Context) error {
                return c.Reply(fmt.Sprintf(
                    "Hello, %s! You said %q",
                    c.Sender().Username,
                    c.Text(),
                ))
            },
        },
    }

    h.SetupCallbacks(callbacks).Start()
}

About

Telebot wrapper

Resources

License

Stars

Watchers

Forks

Languages