-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_command.sh
More file actions
executable file
·60 lines (53 loc) · 1.57 KB
/
send_command.sh
File metadata and controls
executable file
·60 lines (53 loc) · 1.57 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# Script to send commands to the local development bot
# Parse arguments
AUTO_START=true
COMMAND=""
while [[ $# -gt 0 ]]; do
case $1 in
--no-auto-start)
AUTO_START=false
shift
;;
*)
COMMAND="$1"
shift
;;
esac
done
if [ -z "$COMMAND" ]; then
echo "Usage: ./send_command.sh [--no-auto-start] <command>"
echo "Examples:"
echo " ./send_command.sh '!list'"
echo " ./send_command.sh '.status'"
echo " ./send_command.sh '.trigger'"
echo " ./send_command.sh '!check'"
echo " ./send_command.sh --no-auto-start '!list' # Don't start bot automatically"
exit 1
fi
# Get the project root directory (parent of scripts)
PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
# Check if bot is running
check_bot_running() {
pgrep -f "python.*local_dev" > /dev/null
}
# Start bot if needed
if ! check_bot_running; then
if [ "$AUTO_START" = true ]; then
echo "Bot not running, starting it..."
cd "$PROJECT_ROOT"
source venv/bin/activate && python local_dev.py > /dev/null 2>&1 &
BOT_PID=$!
echo "Bot started with PID: $BOT_PID"
echo "Waiting 3 seconds for bot to initialize..."
sleep 3
else
echo "Error: Bot is not running. Start it with 'python local_dev.py' or remove --no-auto-start flag"
exit 1
fi
else
echo "Bot is already running"
fi
echo "$COMMAND" >> "$PROJECT_ROOT/commands.txt"
echo "Command sent: $COMMAND"
echo "Monitor responses with: tail -f $PROJECT_ROOT/logs/bot.log"