Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/onrik/micha

Client lib for Telegram bot api
https://github.com/onrik/micha

go golang telegram telegram-bot

Last synced: 10 days ago
JSON representation

Client lib for Telegram bot api

Awesome Lists containing this project

README

        

# Micha

[![Tests](https://github.com/onrik/micha/workflows/Tests/badge.svg)](https://github.com/onrik/micha/actions)
[![Coverage Status](https://coveralls.io/repos/github/onrik/micha/badge.svg?branch=master)](https://coveralls.io/github/onrik/micha?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/onrik/micha)](https://goreportcard.com/report/github.com/onrik/micha)
[![PkgGoDev](https://pkg.go.dev/badge/github.com/onrik/micha)](https://pkg.go.dev/github.com/onrik/micha)

Client lib for [Telegram bot api](https://core.telegram.org/bots/api).

### Simple echo bot
```go
package main

import (
"log"

"github.com/onrik/micha"
)

func main() {
bot, err := micha.NewBot("")
if err != nil {
log.Println(err)
return
}

go bot.Start()

for update := range bot.Updates() {
if update.Message != nil {
bot.SendMessage(update.Message.Chat.ID, update.Message.Text, nil)
}
}
}

```

### Custom [Telegram Bot API](https://github.com/tdlib/telegram-bot-api)
```go
package main

import (
"log"

"github.com/onrik/micha"
)

func main() {
bot, err := micha.NewBot(
"",
micha.WithAPIServer("http://127.0.0.1:8081"),
)
if err != nil {
log.Println(err)
return
}

err = bot.Logout()
if err != nil {
log.Println(err)
return
}

go bot.Start()

for update := range bot.Updates() {
if update.Message != nil {
bot.SendMessage(update.Message.Chat.ID, update.Message.Text, nil)
}
}
}

```