Skip to content

Syfaro/finch

Repository files navigation

finch

A Golang Telegram Bot framework

Unlike the Telegram Bot API, this is a framework for writing commands, not just low level dealings with the API directly.

You can see how to write some commands from the example commands provided in the commands folder.

Example

It's fairly easy to get this bot running, it requires few lines of code.

package main

import (
	"github.com/Syfaro/finch"
	_ "github.com/Syfaro/finch/commands/help"
	_ "github.com/Syfaro/finch/commands/info"
	_ "github.com/Syfaro/finch/commands/stats"
)

func main() {
	f := finch.NewFinch("MyAwesomeBotToken")

	f.Start()
}

The webhook listener code is currently untested, and requires running a net/http server.

package main

import (
	"github.com/Syfaro/finch"
	_ "github.com/Syfaro/finch/commands/help"
	_ "github.com/Syfaro/finch/commands/info"
	_ "github.com/Syfaro/finch/commands/stats"
	"net/http"
)

func main() {
	f := finch.NewFinchWithClient("MyAwesomeBotToken", &http.Client{})

	f.StartWebhook("/" + f.API.Token)

	http.ListenAndServeTLS("0.0.0.0:8443", "cert.pem", "key.pem", nil)
}

A full bot example may be found at selectionsbot.

Packages

No packages published

Languages