Echo Bot

This simple echo bot replies to every private text message.

It uses the OnNewMessage handler and the FilterPrivate filter to only reply to private messages.

main.go
package main
 
import (
    "github.com/amarnathcjd/gogram/telegram"
)
 
func main() {
    client, _ := telegram.NewClient(telegram.ClientConfig{ // Create a new client
        AppID:   6,
        AppHash: "app_hash",
    })
 
    client.Start() // start the client
 
    client.AddMessageHandler(telegram.OnNewMessage, func(m *telegram.NewMessage) error {
        m.Reply(m)
        return nil
    }, telegram.FilterPrivate)
 
    client.Idle() // block the main goroutine, waiting for updates
}