Skip to content
forked from onrik/micha

Client lib for Telegram bot api

License

Notifications You must be signed in to change notification settings

standardgalactic/micha

 
 

Repository files navigation

Micha

Tests Coverage Status Go Report Card PkgGoDev Gitter

Client lib for Telegram bot api. Supports Bot API v2.3.1 (of 4th Dec 2016).

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)
        }
    }
}

About

Client lib for Telegram bot api

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%