You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
Anton Volodin faeff79108 DRY condition fix 9 years ago
.gitignore Initial commit 9 years ago
LICENSE Initial commit 9 years ago
README.md Update README.md 9 years ago
api.go Merge pull request #14 from ejamesc/master 9 years ago
bot.go go fmt 9 years ago
errors.go Fixed a bunch of lint issues 9 years ago
file.go Another code bloat fixes 9 years ago
message.go DRY condition fix 9 years ago
options.go Typo fix in ReplyMarkup structure 9 years ago
telebot.go Chat actions implemented 9 years ago
telebot_test.go Added some API and tests 9 years ago
types.go Another code bloat fixes 9 years ago

README.md

Telebot

Telebot is a convenient wrapper to Telegram Bots API, written in Golang.

GoDoc

Bots are special Telegram accounts designed to handle messages automatically. Users can interact with bots by sending them command messages in private or group chats. These accounts serve as an interface for code running somewhere on your server.

Telebot offers a convenient wrapper to Bots API, so you shouldn't even care about networking at all. Here is an example "helloworld" bot, written with telebot:

import (
    "time"
    "github.com/tucnak/telebot"
)

func main() {
    bot, err := telebot.NewBot("SECRET TOKEN")
    if err != nil {
        return
    }

    messages := make(chan telebot.Message)
    bot.Listen(messages, 1*time.Second)

    for message := range messages {
        if message.Text == "/hi" {
            bot.SendMessage(message.Chat,
                "Hello, "+message.Sender.FirstName+"!", nil)
        }
    }
}

You can also send any kind of resources from file system easily:

boom, err := telebot.NewFile("boom.ogg")
if err != nil {
    return err
}

audio := telebot.Audio{File: boom}

// Next time you send &audio, telebot won't issue
// an upload, but would re-use existing file.
err = bot.SendAudio(recipient, &audio, nil)

Sometimes you might want to send a little bit complicated messages, with some optional parameters:

// Send a selective force reply message.
bot.SendMessage(user, "pong", &telebot.SendOptions{
        ForceReply: telebot.ForceReply{
            Require: true,
            Selective: true,
        },
    },
)