telecmd

module
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2023 License: MIT

README

telecmd

A simple utility for running commands via Telegram messages.

Usage

telecmd --token '123:token' config.yaml

Configuration

Bot token can be passed with --token option or as an environment variable.

TELEGRAM_BOT_TOKEN=13256:token

Rules are defined in config.yaml

commandTimeout: 1s  # Anything parseable by time.ParseDuration
rules:
  - name: echo
    pattern: "/start"  # Regex to match incoming messages
    workingDir: /path/to/cwd
    # useStdin: true  # Pass message text in stdin 
    env:
      - PYTHONIOENCODING=utf-8
      - PYTHONLEGACYWINDOWSSTDIO=utf-8
      - PYTHONUTF8=1
    command:  # Command to execute. Message text will be passed as commandline argument.
      - python3
      - -c
      - |-
        import sys
        import os
        
        print(os.argv)
        for k in sorted(os.environ):
          print(f'{k}={os.environ[k]}')

TODO

  • Stream output and display progress

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL