Only start/stop charge if plugged in
This commit is contained in:
31
commands.go
31
commands.go
@ -306,13 +306,25 @@ func startCharge(m chat1.MsgSummary) {
|
|||||||
if v == nil {
|
if v == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := v.StartCharging()
|
state, err := v.ChargeState()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tracker := uuid.NewString()
|
tracker := uuid.NewString()
|
||||||
k.SendMessageByConvID(m.ConvID, "There was an error starting your charge. Contact @rudi9719 for more information with code %+v", tracker)
|
k.SendMessageByConvID(m.ConvID, "There was an error getting charge state. Contact @rudi9719 for more information with code %+v", tracker)
|
||||||
log.LogError("%+v: %+v", tracker, err)
|
log.LogError("%+v: %+v", tracker, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if state.ChargingState != "Disconnected" {
|
||||||
|
err := v.StartCharging()
|
||||||
|
if err != nil {
|
||||||
|
tracker := uuid.NewString()
|
||||||
|
k.SendMessageByConvID(m.ConvID, "There was an error starting your charge. Contact @rudi9719 for more information with code %+v", tracker)
|
||||||
|
log.LogError("%+v: %+v", tracker, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
k.SendMessageByConvID(m.ConvID, "You must plug in first, to be able to charge.")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func stopCharge(m chat1.MsgSummary) {
|
func stopCharge(m chat1.MsgSummary) {
|
||||||
@ -320,13 +332,24 @@ func stopCharge(m chat1.MsgSummary) {
|
|||||||
if v == nil {
|
if v == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := v.StopCharging()
|
state, err := v.ChargeState()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tracker := uuid.NewString()
|
tracker := uuid.NewString()
|
||||||
k.SendMessageByConvID(m.ConvID, "There was an error stopping your charge. Contact @rudi9719 for more information with code %+v", tracker)
|
k.SendMessageByConvID(m.ConvID, "There was an error getting charge state. Contact @rudi9719 for more information with code %+v", tracker)
|
||||||
log.LogError("%+v: %+v", tracker, err)
|
log.LogError("%+v: %+v", tracker, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if state.ChargingState != "Disconnected" {
|
||||||
|
err := v.StopCharging()
|
||||||
|
if err != nil {
|
||||||
|
tracker := uuid.NewString()
|
||||||
|
k.SendMessageByConvID(m.ConvID, "There was an error stopping your charge. Contact @rudi9719 for more information with code %+v", tracker)
|
||||||
|
log.LogError("%+v: %+v", tracker, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
k.SendMessageByConvID(m.ConvID, "You must plug in first, to be able to stop charging.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func enableStart(m chat1.MsgSummary) {
|
func enableStart(m chat1.MsgSummary) {
|
||||||
|
|||||||
Reference in New Issue
Block a user