Metadata-Version: 2.1
Name: python-presence
Version: 0.1.2
Summary: minimal implementation of a serverless XMPP client
Home-page: https://github.com/jmechnich/python-presence
Author: Joerg Mechnich
Author-email: joerg.mechnich@gmail.com
License: GNU GPLv3
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: POSIX :: Linux
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE

[![PyPI versio](https://img.shields.io/pypi/v/python-presence)](https://pypi.org/project/python-presence/)
[![PyPi format](https://img.shields.io/pypi/format/python-presence)](https://pypi.org/project/python-presence/)
[![PyPI license](https://img.shields.io/pypi/l/python-presence)](https://pypi.org/project/python-presence/)
[![PyPi weekly downloads](https://img.shields.io/pypi/dw/python-presence)](https://pypi.org/project/python-presence/)

## python-presence - a minimal implementation of a serverless XMPP client.

### Installation

  * Clone this repository
  * Run `pip3 install .`

### Usage (example client)

There is a minimal python script called `python-presence` for running a service:

```
usage: python-presence [-h] [-d] [-k] [-f] [-v]

python-presence

optional arguments:
  -h, --help     show this help message and exit
  -d, --daemon   run as daemon
  -k, --kill     kill running instance if any before start
  -f, --force    force start on bogus lockfile
  -v, --verbose
```

### Default client commands

The client currently supports the following built-in trigger commands/keywords:

| Commmand | Description                         |
|----------|-------------------------------------|
| `echo`   | echo message text                   |
| `help`   | print a list of commands            |
| `hello`  | print a hello message               |
| `vars`   | print variables                     |
| `ls`     | list contents of download directory |

### Extending the client with custom commands

A simple application of client commands is remote query of system information.

```python
    import subprocess
    commands = {
        'df': ClientThread.make_command(
            func=staticmethod(
                lambda client, _: client.send_ascii(
                    subprocess.check_output("df -h", shell=True).decode('utf-8'))
            ),
            helptext='show list of processes',
        ),
        'ps': ClientThread.make_command(
            func=staticmethod(
                lambda client, _: client.send_ascii(
                    subprocess.check_output("ps aux", shell=True).decode('utf-8'))
            ),
            helptext='show list of processes',
        ),
    }
```

### Dependencies

- `python3-daemon`
- `python3-lockfile`
- `python3-psutil`
