VK Teams Bot API Cli
🤖 Powerful command-line interface for VK Teams Bot API with interactive setup, progress bars, and comprehensive chat management features.
✨ Features
- 📤 Message Operations: Send text, files, and voice messages
- 💬 Chat Management: Get info, manage members, set titles and descriptions
- 🔧 Message Editing: Edit, delete, pin/unpin messages
- 📁 File Handling: Upload and download files with progress bars
- 🎯 Event Monitoring: Real-time event listening with long polling
- ⏰ Message Scheduling: Schedule messages with cron expressions, intervals, or specific times
- 🤖 Task Automation: Background scheduler daemon with task management
- ⚙️ Smart Configuration: Interactive setup wizard and multiple config sources
- 🔍 Diagnostics: Built-in validation and connection testing
- 🎨 User-Friendly: Colored output, progress indicators, and helpful examples
- 📊 Structured Output: JSON output support for all commands for easy integration
Table of Contents
- Installation
- Shell Completion
- Quick Start
- Configuration
- Output Formats
- Commands
- Examples
- Advanced Usage
Installation
From crates.io (Recommended)
From source
Shell Completion
Shell completion provides intelligent Tab completion for all commands, options, and file paths.
🚀 One-Command Setup
# Build CLI
# Install completions using the CLI
What You Get
After installation, use Tab completion for:
- Commands:
vkteams-bot-cli s[Tab]→send-text,send-file,schedule - Options:
vkteams-bot-cli config --[Tab]→--show,--wizard,--help - File paths:
vkteams-bot-cli send-file -p /path/[Tab]→ auto-complete files
Runtime Generation
# Generate completion for your shell
# Generate to stdout
Manual Installation
Bash
# Generate and source the completion script
# Add to your ~/.bashrc
Zsh
# Generate completion script
# Ensure completions are enabled in ~/.zshrc
Fish
# Fish automatically loads completions from this directory
PowerShell
# 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"
Build from Source with Completions
# Clone and build
# Install completions using the CLI
# Completions are now available in your shell! 🎉
📋 Build Guide: See BUILD.md for detailed build instructions, troubleshooting, and advanced options.
Quick Start
| completion | Generate shell completions | vkteams-bot-cli completion bash |
1. Get Your Bot Credentials
Follow the VK Teams Bot API instructions to create a bot and get your:
- API Token
- API URL
2. Interactive Setup
This will guide you through the initial configuration process.
3. Test Your Setup
4. Send Your First Message
5. Set Up Shell Completion (Optional)
# Install for your shell
# Or generate to file
Configuration
The CLI supports multiple configuration methods (in order of precedence):
1. Environment Variables
# Required
# Optional
2. Configuration File
The CLI automatically looks for config files in:
- Current directory:
cli_config.toml - User config:
~/.config/vkteams-bot/cli_config.toml - System config:
/etc/vkteams-bot/cli_config.toml(Unix only)
3. Interactive Configuration
# Initial setup wizard
# Update existing configuration
# View current configuration
Output Formats
The CLI supports multiple output formats for all commands:
Default (Pretty) Output
By default, commands display human-readable formatted output with colors and emoji:
# ✅ Message sent successfully (msgId: 123456789)
JSON Output
For programmatic usage and integration with other tools, use --output json:
Output:
Other Output Formats
--output table: Tabular format (where applicable)--output quiet: Minimal output, only errors
Using JSON Output in Scripts
# Extract message ID using jq
MSG_ID=
# Check command success
if | ; then
fi
# Get scheduler task count
TASK_COUNT=
📚 See detailed JSON Output documentation for more examples and integration guides.
Commands
📖 Complete Command Reference - Detailed documentation for all commands with options and examples.
📤 Message Operations
| 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 |
💬 Chat Management
| 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 |
📁 File Operations
| Command | Description | Example |
|---|---|---|
get-file |
Download file with progress | vkteams-bot-cli get-file -f FILE_ID -p /downloads/ |
📡 Event Monitoring
| 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 |
🔍 Information & Diagnostics
| 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 |
⏰ Message Scheduling
| 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" |
🔧 Scheduler Management
| 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 |
📋 Task Management
| 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 |
⚙️ Configuration
| 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 |
Examples
Basic Messaging
# Send a simple text message
# Send a file with automatic progress bar
# Send a voice message
Chat Management
# Get detailed chat information
# List all members in a chat
# Update chat settings
Message Operations
# Edit a message
# Pin an important message
# Delete a message
File Operations
# Download a file to specific directory
# The file will be saved with its original name in the specified directory
Event Monitoring
# Get events once
# Start continuous event monitoring
# Monitor events and filter for specific types
|
# Monitor events and search for keywords
|
Chat Interaction
# Send typing indicator
# Send looking indicator
Message Scheduling
# Schedule a text message for a specific date and time
# Schedule a daily message using cron expression (9 AM every day)
# Schedule a file to be sent every hour
# Schedule a voice message for tomorrow
# Schedule a typing action in 30 minutes
# Schedule a weekly reminder (every Monday at 10 AM)
# Schedule a one-time message with limited runs
Scheduler Management
# Start the scheduler daemon (runs in background)
# Check scheduler status and active tasks
# List all scheduled tasks with details
# Stop the scheduler daemon
Task Management
# Show detailed information about a specific task
# Run a scheduled task immediately (one-time execution)
# Temporarily disable a task
# Re-enable a disabled task
# Permanently remove a task
Advanced Scheduling Examples
# Business hours notifications (Monday to Friday, 9 AM to 5 PM)
# End of month reports (last day of every month at 6 PM)
# Hourly health checks during business hours
# Multiple interval scheduling
# Relative time scheduling
JSON Output Examples
# Get chat info in JSON format
# Parse response and extract specific fields
|
# Check if bot is healthy and get details
|
# Get all scheduled tasks and filter active ones
|
# Create a monitoring script
#!/bin/bash
HEALTH=
if [; then
BOT_ID=
else
ERROR=
fi
# Batch operations with JSON output
for; do
RESULT=
MSG_ID=
done
# Store command results in files
# Process multiple chats
CHATS=
for; do
|
done
Advanced Usage
Configuration Management
# Save configuration to custom location
# Use custom configuration file
# Initialize configuration with defaults
# Generate shell completions for better UX
Scripting and Automation
#!/bin/bash
# Example script for daily notifications
CHAT_ID="your_chat_id"
MESSAGE="Daily reminder: Check your tasks!"
# Send notification
# Send typing action first for more natural interaction
Scheduler Automation Scripts
#!/bin/bash
# Setup automated notifications for a development team
TEAM_CHAT="dev-team-chat"
ALERTS_CHAT="alerts-chat"
# Daily standup reminder
# End of sprint reminders
# Weekly retrospective
# System maintenance notifications
#!/bin/bash
# Scheduler management script
Environment-Specific Configuration
# Environment
# Validate current setup
# Set up completion for development environment
Troubleshooting
# Test your configuration
# Get detailed bot information
# Check configuration
# View all available commands with descriptions
# See usage examples
# Install shell completion for better command discovery
Error Handling
The CLI provides clear error messages and appropriate exit codes:
- Exit Code 0: Success
- Exit Code 64: Usage error (invalid arguments)
- Exit Code 69: Service unavailable (API errors)
- Exit Code 74: I/O error (file operations)
- Exit Code 70: Software error (unexpected errors)
Configuration File Format
Example cli_config.toml:
[]
= "your_bot_token"
= "https://example.com"
= 30
= 3
[]
= "/home/user/downloads"
= "/home/user/uploads"
= 104857600 # 100MB
= 65536 # 64KB
[]
= "info"
= "text"
= true
[]
= true
= "unicode"
= 100
[]
= "http://proxy:8080"
# user = "username" # optional
# password = "password" # optional
[]
= false # Disable rate limiting for CLI usage
= 1000 # Maximum requests per time window
= 60 # Time window in seconds
= 500 # Delay between retries in milliseconds
= 3 # Maximum retry attempts
[]
= "/home/user/.config/vkteams-bot/scheduler_tasks.json"
= 60 # seconds
= 100
Scheduler Features
Schedule Types
The CLI supports three types of scheduling:
- One-time scheduling - Execute once at a specific time
- Cron-based scheduling - Use cron expressions for complex recurring schedules
- Interval-based scheduling - Repeat every N seconds/minutes/hours
Time Formats
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 now
Cron 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 minutes
Task Management
Each scheduled task has:
- Unique ID - UUID for task identification
- Status - Active/disabled state
- Run count - Number of times executed
- Next run time - When the task will run next
- Maximum runs - Optional limit on executions
Scheduler Daemon
The scheduler runs as a background process that:
- Checks for due tasks every minute
- Executes tasks at their scheduled time
- Manages task state and run counts
- Automatically disables completed one-time tasks
- Persists task data between restarts