File size: 849 Bytes
90d2159
 
c5f750a
90d2159
 
 
f6da057
9ffa70c
f6da057
 
 
 
 
 
 
 
dab61c8
f6da057
eada831
dab61c8
eada831
9ffa70c
dab61c8
f6da057
9ffa70c
f6da057
eada831
9ffa70c
eada831
9ffa70c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import time
import logging

class VirtualRobot:
    def __init__(self):
        self.state = "IDLE"
        logging.info("πŸ€– Robot initialized")

    def perform_action(self, command):
        command = (command or "").strip().lower()
        
        if command == "wave":
            return self._wave()
        elif command.startswith("say"):
            return self._speak(command[3:].strip())
        return "❓ Try 'wave' or 'say [message]'"

    def _wave(self):
        self.state = "WAVING"
        time.sleep(0.5)
        self.state = "IDLE"
        return "πŸ‘‹ Wave complete!"

    def _speak(self, message):
        if not message:
            return "❌ No message provided"
        self.state = "SPEAKING"
        time.sleep(max(0.3, len(message)*0.05))
        self.state = "IDLE"
        return f"πŸ—£οΈ {message.capitalize()}"