Skip to main content

CMDOP Bot - Multi-channel bot integrations for remote machine access

Project description

CMDOP Bots

Multi-channel bot integrations for remote machine access.

Control your servers via Telegram, Discord, or Slack. Simple, reliable, open-source.

📖 Read the article: PicoClaw and OpenClaw Are Not Infrastructure: The $10 AI Agent Myth

Install

pip install cmdop-bot

# With Telegram support
pip install cmdop-bot[telegram]

# With Discord support
pip install cmdop-bot[discord]

# With Slack support
pip install cmdop-bot[slack]

# With all channels
pip install cmdop-bot[all]

Quick Start

Telegram Bot

from cmdop_bots.channels.telegram import TelegramBot

bot = TelegramBot(
    token="YOUR_TELEGRAM_BOT_TOKEN",
    cmdop_api_key="YOUR_CMDOP_API_KEY",
    allowed_users=[123456789],  # Your Telegram user ID
    machine="my-server",  # Optional: target machine
)

bot.run()

Discord Bot

from cmdop_bots.channels.discord import DiscordBot

bot = DiscordBot(
    token="YOUR_DISCORD_BOT_TOKEN",
    cmdop_api_key="YOUR_CMDOP_API_KEY",
    guild_ids=[123456789],  # Optional: for faster command sync
)

bot.run()

Slack App

from cmdop_bots.channels.slack import SlackApp

app = SlackApp(
    bot_token="xoxb-YOUR-BOT-TOKEN",
    app_token="xapp-YOUR-APP-TOKEN",
    cmdop_api_key="YOUR_CMDOP_API_KEY",
)

app.run()

Commands

Channel Command Description
Telegram /shell <cmd> Execute shell command
Telegram /exec <cmd> Alias for /shell
Telegram /agent <task> Run AI agent task
Telegram /ls [path] List directory
Telegram /cat <path> Read file
Telegram /machine <host> Set target machine
Discord /shell <cmd> Execute shell command
Discord /agent <task> Run AI agent task
Discord /ls [path] List directory
Discord /cat <path> Read file
Discord /machine <host> Set target machine
Discord /status Show connection status
Slack /cmdop shell <cmd> Execute shell command
Slack /cmdop agent <task> Run AI agent task
Slack /cmdop ls [path] List directory
Slack /cmdop cat <path> Read file
Slack /cmdop machine <host> Set target machine
Slack /cmdop status Show connection status

Features

Telegram

  • MarkdownV2 formatting
  • Code block syntax highlighting
  • Typing indicators
  • User allowlist

Discord

  • Slash commands
  • Rich embeds
  • Ephemeral messages for sensitive data
  • Deferred responses for slow operations
  • Guild-specific command sync

Slack

  • Socket Mode (no public webhooks needed)
  • Block Kit messages
  • Interactive buttons
  • Slash command handling

Handlers

Use handlers directly in your own bot:

from cmdop_bots.handlers import ShellHandler, AgentHandler, FilesHandler

# Create handlers
shell = ShellHandler(cmdop_api_key="cmd_xxx", machine="my-server")
agent = AgentHandler(cmdop_api_key="cmd_xxx")
files = FilesHandler(cmdop_api_key="cmd_xxx")

# Use in your handler
async def handle_command(command, send):
    await shell.handle(command, send)

# Clean up
await shell.close()
await agent.close()
await files.close()

Permissions

Control who can use your bot:

from cmdop_bots import PermissionManager, PermissionLevel

pm = PermissionManager()

# Add admin (full access)
pm.add_admin("telegram:123456789")

# Grant execute permission
pm.grant("discord:987654321", machine="prod-server", level=PermissionLevel.EXECUTE)

# Use with bot
bot = TelegramBot(
    token="...",
    cmdop_api_key="...",
    permissions=pm,
)

Architecture

+--------------+
|  Telegram    |
|  Discord     |------> CMDOP SDK ------> Your Servers
|  Slack       |
+--------------+
  • Simple: Each bot is < 200 lines of code
  • Reliable: Proper error handling, reconnection
  • Secure: Permission system, user allowlists

Development

# Clone repository
git clone https://github.com/commandoperator/cmdop-bot
cd cmdop-bot

# Install dev dependencies
pip install -e ".[dev,all]"

# Run tests
pytest

# Type check
mypy src/cmdop_bot

# Lint
ruff check src/cmdop_bot

Environment Variables

Variable Description Required
TELEGRAM_BOT_TOKEN Telegram bot token For Telegram
DISCORD_BOT_TOKEN Discord bot token For Discord
SLACK_BOT_TOKEN Slack bot token (xoxb-...) For Slack
SLACK_APP_TOKEN Slack app token (xapp-...) For Slack
CMDOP_API_KEY CMDOP API key (cmd_xxx) Yes
CMDOP_MACHINE Default target machine No
ALLOWED_USERS Comma-separated user IDs No

Examples

See the examples/ directory:

  • telegram_bot.py - Full Telegram bot example
  • discord_bot.py - Full Discord bot example
  • slack_app.py - Full Slack app example
  • multi_channel.py - Multi-channel hub example

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmdop_bot-0.1.3.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cmdop_bot-0.1.3-py3-none-any.whl (37.4 kB view details)

Uploaded Python 3

File details

Details for the file cmdop_bot-0.1.3.tar.gz.

File metadata

  • Download URL: cmdop_bot-0.1.3.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for cmdop_bot-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e880fa4c84e2d866cf84a8ffa31ce6e815f6433637d4cb6f5614ba9acafb684e
MD5 25b895822fed6dcf217d93001b51f100
BLAKE2b-256 2901ad903ecdae82073e2592fd493262f54487e6e2aa3ac533c811a04b496bb0

See more details on using hashes here.

File details

Details for the file cmdop_bot-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: cmdop_bot-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 37.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for cmdop_bot-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0fbea262a6abc0d01fdcdde7e62ba5af0b33f848a33486d1762be0da321bf069
MD5 03fb4a80e1a41c69cd940cc6fe146024
BLAKE2b-256 c583a8dff14cedcdfd45d20d0f9578d978beb9f00e27b7e8933e7ef21f859560

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page