func WithLogger(l log.Logger) BotOption {
	return func(b *Bot) error {
		b.logger = l
		return nil
	}
}
WithLogger sets the logger for the Bot as an option.
package telegram
import (
	"context"
	"fmt"
	"net/url"
	"sort"
	"strconv"
	"strings"
	"time"
	"github.com/go-kit/kit/log"
	"github.com/go-kit/kit/log/level"
	"github.com/hako/durafmt"
	"github.com/metalmatze/alertmanager-bot/pkg/alertmanager"
	"github.com/oklog/run"
	"github.com/pkg/errors"
	"github.com/prometheus/alertmanager/api/v2/models"
	"github.com/prometheus/alertmanager/config"
	"github.com/prometheus/alertmanager/template"
	"github.com/prometheus/alertmanager/types"
	"gopkg.in/tucnak/telebot.v2"
)
const (
	CommandStart = "/start"
	CommandStop  = "/stop"
	CommandHelp  = "/help"
	CommandChats = "/chats"
	CommandID    = "/id"
	CommandStatus   = "/status"
	CommandAlerts   = "/alerts"
	CommandSilences = "/silences"
	responseAlertsNotConfigured = "This chat hasn't been setup to receive any alerts yet... 😕\n\n" +
		"Ask an administrator of the Alertmanager to add a webhook with `/webhooks/telegram/%d` as URL."
	responseStartPrivate = "Hey, %s! I will now keep you up to date!\n" + CommandHelp
	responseStartGroup   = "Hey! I will now keep you all up to date!\n" + CommandHelp
	responseStop         = "Alright, %s! I won't talk to you again.\n" + CommandHelp
	ResponseHelp         = `
I'm a Prometheus AlertManager Bot for Telegram. I will notify you about alerts.
You can also ask me about my ` + CommandStatus + `, ` + CommandAlerts + ` & ` + CommandSilences + `
Available commands:
` + CommandStart + ` - Subscribe for alerts.
` + CommandStop + ` - Unsubscribe for alerts.
` + CommandStatus + ` - Print the current status.
` + CommandAlerts + ` - List all alerts.
` + CommandSilences + ` - List all silences.
` + CommandChats + ` - List all users and group chats that subscribed.
` + CommandID + ` - Send the senders Telegram ID (works for all Telegram users).
`
)
// BotChatStore is all the Bot needs to store and read.
type BotChatStore interface {
	List() ([]*telebot.Chat, error)
	Get(telebot.ChatID) (*telebot.Chat, error)
	Add(*telebot.Chat) error
	Remove(*telebot.Chat) error
}
// ChatNotFoundErr returned by the store if a chat isn't found.
var ChatNotFoundErr = errors.New("chat not found in store")
type Telebot interface {
	Start()
	Stop()
	Send(to telebot.Recipient, what interface{}, options ...interface{}) (*telebot.Message, error)
	Notify(to telebot.Recipient, action telebot.ChatAction) error
	Handle(endpoint interface{}, handler interface{})
}
type Alertmanager interface {
	ListAlerts(context.Context, string, bool) ([]*types.Alert, error)
	ListSilences(context.Context) ([]*types.Silence, error)
	Status(context.Context) (*models.AlertmanagerStatus, error)
}
type Bot struct {
	addr         string
	admins       []int  
	alertmanager Alertmanager
	templates    *template.Template
	chats        BotChatStore
	logger       log.Logger
	revision     string
	startTime    time.Time
	telegram Telebot
	commandEvents func(command string)
}
type BotOption func(b *Bot) error
func NewBot(chats BotChatStore, token string, admin int, opts ...BotOption) (*Bot, error) {
	poller := &telebot.LongPoller{
		Timeout: 10 * time.Second,
	}
	bot, err := telebot.NewBot(telebot.Settings{
		Token:  token,
		Poller: poller,
	})
	if err != nil {
		return nil, err
	}
	return NewBotWithTelegram(chats, bot, admin, opts...)
}
func NewBotWithTelegram(chats BotChatStore, bot Telebot, admin int, opts ...BotOption) (*Bot, error) {
	b := &Bot{
		logger:        log.NewNopLogger(),
		telegram:      bot,
		chats:         chats,
		addr:          "127.0.0.1:8080",
		admins:        []int{admin},
		commandEvents: func(command string) {},
	}
	for _, opt := range opts {
		if err := opt(b); err != nil {
			return nil, err
		}
	}
	return b, nil
}