示例#1
0
func loadTemplates() {
	log.Infof("Loading HTML templates...")
	err := data.LoadTemplates(config.ImageTemplate)
	if err != nil {
		log.Fatalf("Failed to load image page: %s", err)
		os.Exit(3)
	}
	log.Debugln("Successfully loaded HTML templates")
}
示例#2
0
func loadDatabase() {
	log.Infof("Loading database...")

	database = data.CreateDatabase(config.SQL)

	err := database.Load()
	if err != nil {
		log.Fatalf("Failed to load database: %[1]s", err)
		os.Exit(2)
	}

	auth, err = mauth.Create(database.GetInternalDB())
	if err != nil {
		log.Fatalf("Failed to load Mauth: %[1]s", err)
	}

	log.Debugln("Successfully loaded database.")
}
示例#3
0
文件: maulu.go 项目: tulir293/maulu
func loadConfig() {
	log.Infoln("Loading config...")
	var err error
	config, err = data.LoadConfig(*confPath)
	if err != nil {
		log.Fatalf("Failed to load config: %[1]s", err)
		os.Exit(1)
	}
	log.Debugln("Successfully loaded config.")
}
示例#4
0
文件: maulu.go 项目: tulir293/maulu
func loadTemplates() {
	log.Infoln("Loading HTML redirect template...")

	var err error
	templRedirect, err = template.ParseFiles(config.RedirectTemplate)
	if err != nil {
		log.Fatalf("Failed to load HTML redirect template: %s", err)
		os.Exit(3)
	}
	log.Debugln("Successfully loaded HTML redirect template.")
}
示例#5
0
文件: maulu.go 项目: tulir293/maulu
func loadDatabase() {
	log.Infoln("Loading database...")

	var err error
	err = data.LoadDatabase(config.SQL)
	if err != nil {
		log.Fatalf("Failed to load database: %[1]s", err)
		os.Exit(2)
	}

	log.Debugln("Successfully loaded database.")
}
示例#6
0
func main() {
	start := util.TimestampMS()
	// Connect to Telegram
	var err error
	bot, err = telebot.NewBot(*token)
	if err != nil {
		log.Fatalf("Error connecting to Telegram: %[1]s", err)
		return
	}
	messages := make(chan telebot.Message)
	// Enable message listener
	bot.Listen(messages, 1*time.Second)
	// Print "connected" message
	log.Infof("Successfully connected to Telegram!")

	// Update timetables
	timetables.Update()

	go posts.Loop(bot, *debug)
	go laundry.Loop(bot)
	go listen(bot)

	startedAt = time.Now()

	var startup = "Ranssibot started up"
	if *debug {
		startup = fmt.Sprintf("Ranssibot started up in %[1]dms @ %[2]s (Debug mode)", util.TimestampMS()-start, startedAt.Format("15:04:05 02.01.2006"))
	}

	log.Infof(startup)
	onoffspam(startup)

	// Listen to messages
	for message := range messages {
		go handleCommand(bot, message)
	}
}