Improve low battery warning
This commit is contained in:
parent
44b399790b
commit
d9874ab1b4
1 changed files with 4 additions and 4 deletions
8
user.go
8
user.go
|
@ -685,12 +685,12 @@ func (user *User) HandleBatteryMessage(battery whatsapp.BatteryMessage) {
|
||||||
user.log.Debugfln("Battery message: %+v", battery)
|
user.log.Debugfln("Battery message: %+v", battery)
|
||||||
var notice string
|
var notice string
|
||||||
if !battery.Plugged && battery.Percentage < 15 && user.batteryWarningsSent < 1 {
|
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
|
user.batteryWarningsSent = 1
|
||||||
} else if !battery.Plugged && battery.Percentage < 5 && 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
|
user.batteryWarningsSent = 2
|
||||||
} else {
|
} else if battery.Percentage > 15 || battery.Plugged {
|
||||||
user.batteryWarningsSent = 0
|
user.batteryWarningsSent = 0
|
||||||
}
|
}
|
||||||
if notice != "" {
|
if notice != "" {
|
||||||
|
|
Loading…
Reference in a new issue