Crates.io | vkteams-bot-cli |
lib.rs | vkteams-bot-cli |
version | 0.7.5 |
created_at | 2023-12-22 18:31:05.047976+00 |
updated_at | 2025-08-19 20:28:43.62898+00 |
description | High-performance VK Teams Bot API toolkit with CLI and MCP server support |
homepage | https://github.com/bug-ops/vkteams-bot |
repository | https://github.com/bug-ops/vkteams-bot/tree/master/crates/vkteams-bot-cli |
max_upload_size | |
id | 1078578 |
size | 923,395 |
🤖 Powerful command-line interface for VK Teams Bot API with interactive setup, progress bars, and comprehensive chat management features.
cargo install vkteams-bot-cli
git clone https://github.com/bug-ops/vkteams-bot
cd vkteams-bot
cargo install --path crates/vkteams-bot-cli
Shell completion provides intelligent Tab completion for all commands, options, and file paths.
# Build CLI
cargo build --release
# Install completions using the CLI
vkteams-bot-cli completion bash --install
vkteams-bot-cli completion zsh --install
After installation, use Tab completion for:
vkteams-bot-cli s[Tab]
→ send-text
, send-file
, schedule
vkteams-bot-cli config --[Tab]
→ --show
, --wizard
, --help
vkteams-bot-cli send-file -p /path/[Tab]
→ auto-complete files# Generate completion for your shell
vkteams-bot-cli completion bash --output completion.bash
vkteams-bot-cli completion zsh --install
# Generate to stdout
vkteams-bot-cli completion bash
# Generate and source the completion script
vkteams-bot-cli completion bash > ~/.local/share/bash-completion/completions/vkteams-bot-cli
# Add to your ~/.bashrc
echo 'source ~/.local/share/bash-completion/completions/vkteams-bot-cli' >> ~/.bashrc
# Generate completion script
vkteams-bot-cli completion zsh > ~/.local/share/zsh/site-functions/_vkteams-bot-cli
# Ensure completions are enabled in ~/.zshrc
echo 'autoload -Uz compinit && compinit' >> ~/.zshrc
# Fish automatically loads completions from this directory
vkteams-bot-cli completion fish > ~/.config/fish/completions/vkteams-bot-cli.fish
# Generate completion script
vkteams-bot-cli completion powershell > vkteams-bot-cli-completion.ps1
# Add to your PowerShell profile
Add-Content $PROFILE ". $(pwd)\vkteams-bot-cli-completion.ps1"
# Clone and build
git clone https://github.com/bug-ops/vkteams-bot
cd vkteams-bot/crates/vkteams-bot-cli
cargo build --release
# Install completions using the CLI
./target/release/vkteams-bot-cli completion bash --install
./target/release/vkteams-bot-cli completion zsh --install
# Completions are now available in your shell! 🎉
📋 Build Guide: See BUILD.md for detailed build instructions, troubleshooting, and advanced options.
| completion
| Generate shell completions | vkteams-bot-cli completion bash
|
Follow the VK Teams Bot API instructions to create a bot and get your:
vkteams-bot-cli setup
This will guide you through the initial configuration process.
vkteams-bot-cli validate
vkteams-bot-cli send-text -u USER_ID -m "Hello from CLI!"
# Install for your shell
vkteams-bot-cli completion bash --install
vkteams-bot-cli completion zsh --install
vkteams-bot-cli completion fish --install
# Or generate to file
vkteams-bot-cli completion bash > ~/.local/share/bash-completion/completions/vkteams-bot-cli
The CLI supports multiple configuration methods (in order of precedence):
# Required
export VKTEAMS_BOT_API_TOKEN=your_token_here
export VKTEAMS_BOT_API_URL=your_api_url_here
# Optional
export VKTEAMS_PROXY=http://proxy:8080
export VKTEAMS_LOG_LEVEL=info
export VKTEAMS_DOWNLOAD_DIR=/path/to/downloads
The CLI automatically looks for config files in:
cli_config.toml
~/.config/vkteams-bot/cli_config.toml
/etc/vkteams-bot/cli_config.toml
(Unix only)# Initial setup wizard
vkteams-bot-cli setup
# Update existing configuration
vkteams-bot-cli config --wizard
# View current configuration
vkteams-bot-cli config --show
The CLI supports multiple output formats for all commands:
By default, commands display human-readable formatted output with colors and emoji:
vkteams-bot-cli send-text -u USER_ID -m "Hello!"
# ✅ Message sent successfully (msgId: 123456789)
For programmatic usage and integration with other tools, use --output json
:
vkteams-bot-cli --output json send-text -u USER_ID -m "Hello!"
Output:
{
"success": true,
"data": {
"msgId": "123456789",
"ok": true
},
"error": null,
"timestamp": "2024-01-20T10:30:45Z",
"command": "send-text"
}
--output table
: Tabular format (where applicable)--output quiet
: Minimal output, only errors# Extract message ID using jq
MSG_ID=$(vkteams-bot-cli --output json send-text -u USER_ID -m "Test" | jq -r '.data.msgId')
# Check command success
if vkteams-bot-cli --output json health-check | jq -e '.success' > /dev/null; then
echo "Bot is healthy"
fi
# Get scheduler task count
TASK_COUNT=$(vkteams-bot-cli --output json scheduler list | jq '.data.total')
📚 See detailed JSON Output documentation for more examples and integration guides.
📖 Complete Command Reference - Detailed documentation for all commands with options and examples.
Command | Description | Example |
---|---|---|
send-text |
Send text message | vkteams-bot-cli send-text -u USER_ID -m "Hello!" |
send-file |
Send file with progress | vkteams-bot-cli send-file -u USER_ID -p file.pdf |
send-voice |
Send voice message | vkteams-bot-cli send-voice -u USER_ID -p voice.ogg |
edit-message |
Edit existing message | vkteams-bot-cli edit-message -c CHAT_ID -m MSG_ID -t "New text" |
delete-message |
Delete message | vkteams-bot-cli delete-message -c CHAT_ID -m MSG_ID |
pin-message |
Pin message | vkteams-bot-cli pin-message -c CHAT_ID -m MSG_ID |
unpin-message |
Unpin message | vkteams-bot-cli unpin-message -c CHAT_ID -m MSG_ID |
Command | Description | Example |
---|---|---|
get-chat-info |
Get chat details | vkteams-bot-cli get-chat-info -c CHAT_ID |
get-chat-members |
List chat members | vkteams-bot-cli get-chat-members -c CHAT_ID |
set-chat-title |
Change chat title | vkteams-bot-cli set-chat-title -c CHAT_ID -t "New Title" |
set-chat-about |
Set chat description | vkteams-bot-cli set-chat-about -c CHAT_ID -a "Description" |
send-action |
Send typing/looking action | vkteams-bot-cli send-action -c CHAT_ID -a typing |
Command | Description | Example |
---|---|---|
get-file |
Download file with progress | vkteams-bot-cli get-file -f FILE_ID -p /downloads/ |
Command | Description | Example |
---|---|---|
get-events |
Get events once | vkteams-bot-cli get-events |
get-events -l true |
Start long polling | vkteams-bot-cli get-events -l true |
Command | Description | Example |
---|---|---|
get-self |
Get bot information | vkteams-bot-cli get-self |
get-profile |
Get user profile | vkteams-bot-cli get-profile -u USER_ID |
validate |
Test configuration | vkteams-bot-cli validate |
examples |
Show usage examples | vkteams-bot-cli examples |
list-commands |
Show all commands | vkteams-bot-cli list-commands |
Command | Description | Example |
---|---|---|
schedule text |
Schedule text message | vkteams-bot-cli schedule text -u CHAT_ID -m "Hello" -t "2024-01-01 10:00" |
schedule file |
Schedule file message | vkteams-bot-cli schedule file -u CHAT_ID -p file.pdf -c "0 9 * * *" |
schedule voice |
Schedule voice message | vkteams-bot-cli schedule voice -u CHAT_ID -p voice.ogg -i 3600 |
schedule action |
Schedule chat action | vkteams-bot-cli schedule action -u CHAT_ID -a typing -t "30m" |
Command | Description | Example |
---|---|---|
scheduler start |
Start scheduler daemon | vkteams-bot-cli scheduler start |
scheduler stop |
Stop scheduler daemon | vkteams-bot-cli scheduler stop |
scheduler status |
Show scheduler status | vkteams-bot-cli scheduler status |
scheduler list |
List all scheduled tasks | vkteams-bot-cli scheduler list |
Command | Description | Example |
---|---|---|
task show |
Show task details | vkteams-bot-cli task show TASK_ID |
task remove |
Remove scheduled task | vkteams-bot-cli task remove TASK_ID |
task enable |
Enable disabled task | vkteams-bot-cli task enable TASK_ID |
task disable |
Disable active task | vkteams-bot-cli task disable TASK_ID |
task run |
Run task immediately | vkteams-bot-cli task run TASK_ID |
Command | Description | Example |
---|---|---|
setup |
Interactive setup wizard | vkteams-bot-cli setup |
config --show |
Show current config | vkteams-bot-cli config --show |
config --wizard |
Update config interactively | vkteams-bot-cli config --wizard |
completion |
Generate shell completions | vkteams-bot-cli completion bash |
# Send a simple text message
vkteams-bot-cli send-text -u user123 -m "Hello, World!"
# Send a file with automatic progress bar
vkteams-bot-cli send-file -u user123 -p /path/to/document.pdf
# Send a voice message
vkteams-bot-cli send-voice -u user123 -p /path/to/audio.ogg
# Get detailed chat information
vkteams-bot-cli get-chat-info -c chat456
# List all members in a chat
vkteams-bot-cli get-chat-members -c chat456
# Update chat settings
vkteams-bot-cli set-chat-title -c chat456 -t "New Project Chat"
vkteams-bot-cli set-chat-about -c chat456 -a "Discussion for the new project"
# Edit a message
vkteams-bot-cli edit-message -c chat456 -m msg789 -t "Updated message content"
# Pin an important message
vkteams-bot-cli pin-message -c chat456 -m msg789
# Delete a message
vkteams-bot-cli delete-message -c chat456 -m msg789
# Download a file to specific directory
vkteams-bot-cli get-file -f file123 -p /downloads/
# The file will be saved with its original name in the specified directory
# Get events once
vkteams-bot-cli get-events
# Start continuous event monitoring
vkteams-bot-cli get-events -l true
# Monitor events and filter for specific types
vkteams-bot-cli get-events -l true | jq '.events[] | select(.type == "newMessage")'
# Monitor events and search for keywords
vkteams-bot-cli get-events -l true | grep -i "urgent"
# Send typing indicator
vkteams-bot-cli send-action -c chat456 -a typing
# Send looking indicator
vkteams-bot-cli send-action -c chat456 -a looking
# Schedule a text message for a specific date and time
vkteams-bot-cli schedule text -u chat456 -m "Meeting reminder" -t "2024-01-15 09:00:00"
# Schedule a daily message using cron expression (9 AM every day)
vkteams-bot-cli schedule text -u chat456 -m "Daily standup time!" -c "0 9 * * *"
# Schedule a file to be sent every hour
vkteams-bot-cli schedule file -u chat456 -p "/path/to/report.pdf" -i 3600
# Schedule a voice message for tomorrow
vkteams-bot-cli schedule voice -u chat456 -p "/path/to/announcement.ogg" -t "tomorrow"
# Schedule a typing action in 30 minutes
vkteams-bot-cli schedule action -u chat456 -a typing -t "30m"
# Schedule a weekly reminder (every Monday at 10 AM)
vkteams-bot-cli schedule text -u chat456 -m "Weekly team meeting in 1 hour" -c "0 10 * * 1"
# Schedule a one-time message with limited runs
vkteams-bot-cli schedule text -u chat456 -m "Limited offer!" -t "2h" --max-runs 1
# Start the scheduler daemon (runs in background)
vkteams-bot-cli scheduler start
# Check scheduler status and active tasks
vkteams-bot-cli scheduler status
# List all scheduled tasks with details
vkteams-bot-cli scheduler list
# Stop the scheduler daemon
vkteams-bot-cli scheduler stop
# Show detailed information about a specific task
vkteams-bot-cli task show a1b2c3d4-e5f6-7890-abcd-ef1234567890
# Run a scheduled task immediately (one-time execution)
vkteams-bot-cli task run a1b2c3d4-e5f6-7890-abcd-ef1234567890
# Temporarily disable a task
vkteams-bot-cli task disable a1b2c3d4-e5f6-7890-abcd-ef1234567890
# Re-enable a disabled task
vkteams-bot-cli task enable a1b2c3d4-e5f6-7890-abcd-ef1234567890
# Permanently remove a task
vkteams-bot-cli task remove a1b2c3d4-e5f6-7890-abcd-ef1234567890
# Business hours notifications (Monday to Friday, 9 AM to 5 PM)
vkteams-bot-cli schedule text -u team-chat -m "Working hours reminder" -c "0 9-17 * * 1-5"
# End of month reports (last day of every month at 6 PM)
vkteams-bot-cli schedule file -u reports-chat -p "/reports/monthly.pdf" -c "0 18 L * *"
# Hourly health checks during business hours
vkteams-bot-cli schedule text -u monitoring-chat -m "System health check" -c "0 9-17 * * 1-5"
# Multiple interval scheduling
vkteams-bot-cli schedule text -u alerts-chat -m "Every 5 minutes alert" -i 300
vkteams-bot-cli schedule text -u daily-chat -m "Every 30 minutes update" -i 1800
# Relative time scheduling
vkteams-bot-cli schedule text -u chat456 -m "In 1 hour" -t "1h"
vkteams-bot-cli schedule text -u chat456 -m "Tomorrow morning" -t "tomorrow"
vkteams-bot-cli schedule text -u chat456 -m "Next week" -t "7d"
# Get chat info in JSON format
vkteams-bot-cli --output json get-chat-info -c chat456
# Parse response and extract specific fields
vkteams-bot-cli --output json get-chat-info -c chat456 | jq '.data.title'
# Check if bot is healthy and get details
vkteams-bot-cli --output json health-check | jq '{healthy: .success, bot_id: .data.userId}'
# Get all scheduled tasks and filter active ones
vkteams-bot-cli --output json scheduler list | jq '.data.tasks[] | select(.enabled == true)'
# Create a monitoring script
#!/bin/bash
HEALTH=$(vkteams-bot-cli --output json health-check)
if [ $(echo $HEALTH | jq -r '.success') == "true" ]; then
BOT_ID=$(echo $HEALTH | jq -r '.data.userId')
echo "Bot $BOT_ID is healthy"
else
ERROR=$(echo $HEALTH | jq -r '.error')
echo "Bot check failed: $ERROR"
exit 1
fi
# Batch operations with JSON output
for user in user1 user2 user3; do
RESULT=$(vkteams-bot-cli --output json send-text -u $user -m "Batch message")
MSG_ID=$(echo $RESULT | jq -r '.data.msgId')
echo "Sent message $MSG_ID to $user"
done
# Store command results in files
vkteams-bot-cli --output json get-chat-members -c chat456 > members.json
vkteams-bot-cli --output json scheduler list > tasks.json
# Process multiple chats
CHATS=$(vkteams-bot-cli --output json list-chats | jq -r '.data[].chatId')
for chat in $CHATS; do
vkteams-bot-cli --output json get-chat-info -c $chat | jq '.data.membersCount'
done
# Save configuration to custom location
vkteams-bot-cli --save-config /path/to/custom-config.toml
# Use custom configuration file
vkteams-bot-cli --config /path/to/custom-config.toml send-text -u user123 -m "Hello"
# Initialize configuration with defaults
vkteams-bot-cli config --init
# Generate shell completions for better UX
vkteams-bot-cli completion bash --install
#!/bin/bash
# Example script for daily notifications
CHAT_ID="your_chat_id"
MESSAGE="Daily reminder: Check your tasks!"
# Send notification
vkteams-bot-cli send-text -u "$CHAT_ID" -m "$MESSAGE"
# Send typing action first for more natural interaction
vkteams-bot-cli send-action -c "$CHAT_ID" -a typing
sleep 2
vkteams-bot-cli send-text -u "$CHAT_ID" -m "$MESSAGE"
#!/bin/bash
# Setup automated notifications for a development team
TEAM_CHAT="dev-team-chat"
ALERTS_CHAT="alerts-chat"
# Daily standup reminder
vkteams-bot-cli schedule text \
-u "$TEAM_CHAT" \
-m "🏃♂️ Daily standup in 15 minutes! Please prepare your updates." \
-c "0 9 * * 1-5"
# End of sprint reminders
vkteams-bot-cli schedule text \
-u "$TEAM_CHAT" \
-m "📊 Sprint ends tomorrow. Please update your task status." \
-c "0 17 * * 4"
# Weekly retrospective
vkteams-bot-cli schedule text \
-u "$TEAM_CHAT" \
-m "🔄 Weekly retrospective today at 4 PM. What went well this week?" \
-c "0 16 * * 5"
# System maintenance notifications
vkteams-bot-cli schedule text \
-u "$ALERTS_CHAT" \
-m "🔧 Scheduled maintenance window starts in 1 hour" \
-t "2024-01-20 01:00:00"
echo "All scheduled notifications have been set up!"
#!/bin/bash
# Scheduler management script
case "$1" in
start)
echo "Starting VK Teams Bot scheduler..."
vkteams-bot-cli scheduler start
;;
stop)
echo "Stopping VK Teams Bot scheduler..."
vkteams-bot-cli scheduler stop
;;
status)
echo "Checking scheduler status..."
vkteams-bot-cli scheduler status
;;
list)
echo "Listing all scheduled tasks..."
vkteams-bot-cli scheduler list
;;
*)
echo "Usage: $0 {start|stop|status|list}"
exit 1
;;
esac
# Environment
export VKTEAMS_BOT_API_URL="https://api.example.com"
export VKTEAMS_LOG_LEVEL="info"
# Validate current setup
vkteams-bot-cli validate
# Set up completion for development environment
vkteams-bot-cli completion bash --install
# Test your configuration
vkteams-bot-cli validate
# Get detailed bot information
vkteams-bot-cli get-self --detailed
# Check configuration
vkteams-bot-cli config --show
# View all available commands with descriptions
vkteams-bot-cli list-commands
# See usage examples
vkteams-bot-cli examples
# Install shell completion for better command discovery
vkteams-bot-cli completion bash --install
vkteams-bot-cli completion zsh --install
The CLI provides clear error messages and appropriate exit codes:
Example cli_config.toml
:
[api]
token = "your_bot_token"
url = "https://example.com"
timeout = 30
max_retries = 3
[files]
download_dir = "/home/user/downloads"
upload_dir = "/home/user/uploads"
max_file_size = 104857600 # 100MB
buffer_size = 65536 # 64KB
[logging]
level = "info"
format = "text"
colors = true
[ui]
show_progress = true
progress_style = "unicode"
progress_refresh_rate = 100
[proxy]
url = "http://proxy:8080"
# user = "username" # optional
# password = "password" # optional
[rate_limit]
enabled = false # Disable rate limiting for CLI usage
limit = 1000 # Maximum requests per time window
duration = 60 # Time window in seconds
retry_delay = 500 # Delay between retries in milliseconds
retry_attempts = 3 # Maximum retry attempts
[scheduler]
data_file = "/home/user/.config/vkteams-bot/scheduler_tasks.json"
check_interval = 60 # seconds
max_task_history = 100
The CLI supports three types of scheduling:
Absolute time:
2024-01-15 14:30:00
- Specific date and time2024-01-15 14:30
- Date and time (seconds default to 00)2024-01-15
- Date only (time defaults to 00:00:00)Relative time:
30s
- 30 seconds from now5m
- 5 minutes from now2h
- 2 hours from now1d
- 1 day from now1w
- 1 week from nowtomorrow
- Tomorrow at the same timenow
- Right nowCron expressions:
0 9 * * *
- Every day at 9:00 AM0 */2 * * *
- Every 2 hours0 9 * * 1-5
- Weekdays at 9:00 AM0 0 1 * *
- First day of every month at midnight*/30 * * * *
- Every 30 minutesEach scheduled task has:
The scheduler runs as a background process that: