Welcome Bot

This example demonstrates how to create a simple welcome bot that greets new users when they join a group.

main.go
package main
 
import (
    "github.com/amarnathcjd/gogram/telegram"
)
 
var chatId int64 = -1001234567890
 
func main() {
    client, _ := telegram.NewClient(telegram.ClientConfig{ // Create a new client
        AppID:   6,
        AppHash: "app_hash",
    })
    client.Start()
 
    client.AddParticipantHandler(func(p *telegram.ParticipantUpdate) error {
        if p.Added() || p.Joined() {
            client.SendMessage(chatId, fmt.Sprintf("Welcome to the group %s!", p.User.FirstName))
        }
        return nil
    })
 
    client.Idle() // block the main goroutine, waiting for updates
}