Skip to content

onrik/micha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

2129b9f · Aug 15, 2024
Aug 12, 2024
Nov 27, 2016
Aug 12, 2024
Apr 14, 2016
Aug 15, 2024
Aug 12, 2024
Aug 12, 2024
Aug 12, 2024
Aug 12, 2024
Jun 3, 2017
Dec 11, 2016
Aug 12, 2024
Aug 12, 2024
Aug 12, 2024
Jun 16, 2023
Aug 12, 2024
Oct 18, 2019
Oct 18, 2019
Oct 18, 2019
Nov 26, 2016
Oct 18, 2019
Oct 18, 2019
Nov 26, 2016
Aug 15, 2024
Aug 15, 2024

Repository files navigation

Micha

Tests Coverage Status Go Report Card PkgGoDev

Client lib for Telegram bot api.

Simple echo bot

package main

import (
    "log"
	
    "github.com/onrik/micha"
)

func main() {
    bot, err := micha.NewBot("<token>")
    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)
        }
    }
}
package main

import (
    "log"
	
    "github.com/onrik/micha"
)

func main() {
    bot, err := micha.NewBot(
        "<token>",
        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)
        }
    }
}