Skip to content

ejamesc/telebot

This branch is 106 commits behind tucnak/telebot:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

f7c3d4f · Oct 11, 2015

History

35 Commits
Jun 25, 2015
Jun 25, 2015
Jul 6, 2015
Oct 11, 2015
Aug 5, 2015
Jul 3, 2015
Jul 6, 2015
Jul 6, 2015
Aug 24, 2015
Jul 6, 2015
Jul 6, 2015
Jul 6, 2015

Repository files navigation

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
}

// Next time you send &boom, telebot won't issue
// an upload, but would re-use existing file.
err = bot.SendAudio(recipient, &boom, 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,
        },
    },
)

About

Telegram bot framework written in Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%