mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-11-15 22:42:35 +01:00
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)
|
||||
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 < 1 {
|
||||
notice = fmt.Sprintf("Phone battery very low (%d remaining)", battery.Percentage)
|
||||
} else if !battery.Plugged && battery.Percentage < 5 && user.batteryWarningsSent < 2 {
|
||||
notice = fmt.Sprintf("Phone battery very low (%d % remaining)", battery.Percentage)
|
||||
user.batteryWarningsSent = 2
|
||||
} else {
|
||||
} else if battery.Percentage > 15 || battery.Plugged {
|
||||
user.batteryWarningsSent = 0
|
||||
}
|
||||
if notice != "" {
|
||||
|
|
Loading…
Reference in a new issue