package main
import (
"github.com/amarnathcjd/gogram/telegram"
)
func main() {
// Create and authenticate the client
client, _ := telegram.NewClient(telegram.ClientConfig{
AppID: 6,
AppHash: "YOUR_APP_HASH",
})
client.LoginBot("YOUR_BOT_TOKEN")
// Handle all private messages - echo them back
client.On(telegram.OnMessage, func(message *telegram.NewMessage) error {
// Respond with the same message (echo)
message.Respond(message)
return nil
}, telegram.FilterPrivate) // Only respond to private messages
// Handle /start command specifically
client.On("cmd:start", func(message *telegram.NewMessage) error {
// Reply with a greeting
message.Reply("Hello, I am a bot!")
return nil
})
// Keep the bot running
client.Idle()
}