https://github.com/operable/pycog3
Python3 command SDK for the Cog ChatOps platform
https://github.com/operable/pycog3
Last synced: 9 months ago
JSON representation
Python3 command SDK for the Cog ChatOps platform
- Host: GitHub
- URL: https://github.com/operable/pycog3
- Owner: operable
- License: other
- Created: 2016-06-09T13:54:36.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-11-13T00:11:16.000Z (over 8 years ago)
- Last Synced: 2025-05-20T01:09:24.749Z (10 months ago)
- Language: Python
- Size: 11.7 KB
- Stars: 3
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.MD
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[](https://travis-ci.org/operable/pycog3)
# pycog3
Simple, opinionated library for building Cog commands in Python3.
## Usage
pycog3 combines information available in the Cog runtime environment
with assumptions about Python project structure to simplify command
development.
pycog3 includes a driver executable, [bin/cog-command](https://github.com/cog-bundles/pycog3/blob/master/bin/cog-command), which dynamically
imports, instantiates, and runs Python command code based on the
values of `$COG_BUNDLE` and `$COG_COMMAND`.
`cog-command`'s magic requires that Python projects follow a strict
directory layout (basic):
```
|
|--
|-- __init__.py
|-- commands
|
|-- __init__.py
|-- .py
|-- .py
```
pycog3 also supports more advanced, multi-level structure when using the `-` field separator in the command name.
For example, defining:
* `commands\commanda.py` - maps to `!commanda`
* `commands\level1\commandb.py` - maps to `!level1-commandb`
* `commands\level1\level2a\commandc.py` - maps to `!level1-level2a-commandb`
* `commands\level1\level2b\leveln\commandz.py` - maps to `!level1-level2b-leveln-commandz`
```
|
|--
|-- __init__.py
|-- commands
|
|-- __init__.py
|-- .py
|-- .py
.
.
|-- .py
|
|--
|
|-- __init__.py
|-- .py
|-- .py
.
.
|-- .py
|
|--
| |
| |-- .py
| |-- .py
| |-- .py
| .
| .
| |-- .py
|
|--
|
|-- __init__.py
|-- <...>
|
|-- __init__.py
| --
|
|-- __init__.py
|-- .py
|-- .py
.
.
|-- .py
```
The only requirement is a class with the same name of the filename should exist (first letter capital).
## Examples
See the [cog-bundles/statuspage](https://github.com/cog-bundles/statuspage) repository for an example of this library in action.
If you're interested in the multi-level usage, check the cog-bundle [pi-bundle](https://github.com/pan-net-security/pi-bundle) or the test bundle in `test/`.
## Installation
Add this line to your application's setup.py or requirements.txt:
```
pycog3>=0.1.28
```
## TODO
- Add [Cog service](http://docs.operable.io/docs/services) support
- Add transparent accumulation support a la [cog-bundles/cog-rb](https://github.com/cog-bundles/cog-rb)