Escape % in battery low warning. Fixes #205

This commit is contained in:
Tulir Asokan 2020-07-04 16:21:41 +03:00
parent 43a3815970
commit 4608c09656

View file

@ -685,10 +685,10 @@ func (user *User) HandleBatteryMessage(battery whatsapp.BatteryMessage) {
user.log.Debugfln("Battery message: %+v", battery)
var notice string
if !battery.Plugged && battery.Percentage < 15 && user.batteryWarningsSent < 1 {
notice = fmt.Sprintf("Phone battery low (%d % remaining)", battery.Percentage)
notice = fmt.Sprintf("Phone battery low (%d %% remaining)", battery.Percentage)
user.batteryWarningsSent = 1
} else if !battery.Plugged && battery.Percentage < 5 && user.batteryWarningsSent < 2 {
notice = fmt.Sprintf("Phone battery very low (%d % remaining)", battery.Percentage)
notice = fmt.Sprintf("Phone battery very low (%d %% remaining)", battery.Percentage)
user.batteryWarningsSent = 2
} else if battery.Percentage > 15 || battery.Plugged {
user.batteryWarningsSent = 0