to add skill in main:
chobit.addSkill(DiCPUTamaguchi())
chobit.addSkill(DiCPUTamaguchi())
Code:
class DiCPUTamaguchi(DiSkillV2):
def __init__(self):
super().__init__()
def input(self, ear, skin, eye):
match ear:
case "battery":
self.setSimpleAlg(self.get_battery_percentage())
case "are you eating":
self.setSimpleAlg(self.isPlugged())
case "are you hungry":
hunger: int = self.get_battery_percentageInt()
if hunger == 100:
self.setSimpleAlg(f"no I am full")
else:
self.setSimpleAlg(f"I am missing{100 - hunger}%")
@staticmethod
def get_battery_percentage():
battery = psutil.sensors_battery()
if battery is None:
return "No battery found."
return f"Battery Percentage: {battery.percent}%"
@staticmethod
def isPlugged():
battery = psutil.sensors_battery()
if battery is None:
return "No battery found."
return f"**Power plugged in**: {battery.power_plugged}"
@staticmethod
def is_battery_plugged() -> bool:
battery_info = psutil.sensors_battery()
if battery_info is None:
return False # No battery found
return battery_info.power_plugged
@staticmethod
def get_battery_percentageInt() -> int:
battery = psutil.sensors_battery()
if battery is None:
return -1
return battery.percent