Exemple #1
0
// Initiate nofication service
func initNotifyService() {
	//Init Notification Service Config
	var (
		err     error
		groupId int
	)

	groupId, err = beego.AppConfig.Int("telegram::group_id")

	if err != nil {
		beego.Error("Telegram config read error: group_id", err)
	}

	conf := notify.NotifyMailConfig{}

	err = config.ParseConfig(beego.AppConfig, &conf)
	if err != nil {
		log.Fatalf("Mail Config Read Error %s", err)
		return
	}

	conf.DB = DM

	//Init Notification Service
	NFS = notify.NewNotificationService(notify.Conf{conf, conf.BuffLimit, groupId})
	NFS.Start()
	//Starting Notification Service logging
	go ChannLogger(NFS.Errors(), NFS.Notifications())

}
Exemple #2
0
// !!! TELEGRAM SERVICES NEED CONFIGURED TELEGRAM-CLI
// 1.Download and compile telegram cli on your machine https://github.com/vysheng/tg
// 2.Authentificate manually
// 3.Put your public-key to /etc/telegram-cli/server.pub
//
//Initializes HrkbBot for listening and responding commands
func initBot() {
	botConf := bot.Conf{}
	err := config.ParseConfig(beego.AppConfig, &botConf)

	if err != nil {
		log.Fatalf("Bot Config Read Error %s", err)
		return
	}

	botConf.Cmd = NFS.TgService.GetCmd()

	Bot = bot.NewBot(botConf)
	Bot.Start()

	go ChannLogger(Bot.Errors(), Bot.Notifications())
}