Example #1
0
func TriggerPrice(price float64) error {
	lowest_price, err := strconv.ParseFloat(config.Remind["lowest_price"], 64)
	if err != nil {
		logger.Debugln("config item lowest_price is not float")
		return err
	}
	highest_price, err := strconv.ParseFloat(config.Remind["highest_price"], 64)
	if err != nil {
		logger.Debugln("config item highest_price is not float")
		return err
	}

	var alert string
	if config.Remind["disable_email"] != "1" {
		if price < lowest_price {
			alert = fmt.Sprintf("价格 %f 低于设定的阀值 %f", price, config.Remind["lowest_price"])
		} else if price > highest_price {
			alert = fmt.Sprintf("价格 %f 超过设定的阀值 %f", price, config.Remind["highest_price"])
		}

		if alert != "" {
			email.SendAlertEmail(config.Remind["to_email"], alert)
		}
	}

	return nil
}
Example #2
0
func TriggerTrender(alert string) error {

	if config.Remind["disable_email"] != "1" {
		if alert != "" {
			email.SendAlertEmail(config.Remind["to_email"], alert)
		}
	}

	return nil
}