Skip to content
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.

Latest commit

 

History

History
262 lines (173 loc) · 7.66 KB

README.md

File metadata and controls

262 lines (173 loc) · 7.66 KB

openhiven.py


Important info!

This repository will from now (the day of writing) on be read-only and there will not be any further releases or development. The Hiven platform seems to give off no live signals since months, so there seems to be no good reason to continue this project. You are welcome to fork this repo, but for now this project is retired.

Luna Klatzer, 28.4.2022


The Hiven API-Wrapper openhiven.py

PyPI version Python Version Build Lines of Code License Coverage codecov

Dependencies

aiohttp python-dotenv fastjsonschema yarl

Installation

Install (PyPi Release)

python3 -m pip install -U openhivenpy

Install (PyPi Specific Version)

python3 -m pip install -U openhivenpy==version

Install (Github Build)

python3 -m pip install -U https://github.com/Luna-Klatzer/openhiven.py/archive/main.zip

Documentation

For the full documentation visit the documentation build here

Usage Example

A simple UserClient Bot for quick usage:

import openhivenpy as hiven

client = hiven.UserClient()

@client.event()
async def on_ready():
    print("Bot is ready")

client.run("Insert token")

A simple CommandListener for reacting to commands:

import openhivenpy as hiven

client = hiven.UserClient()

@client.event()
async def on_ready():
    print("Bot is ready")

@client.event()
async def on_message_create(msg):
    if msg.content.startswith("-"):
        if msg.content == "-ping":
            return await msg.room.send("pong")

client.run("Insert token")
 

Inherited HivenClient Example:

import openhivenpy as hiven

class Bot(hiven.UserClient):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    async def on_ready(self):
        print("Bot is ready!")

if __name__ == '__main__':
    client = Bot()
    client.run("Insert token")

Development

Testing

Testing openhiven.py is done over GitHub Actions and more specific pytest, which runs tests for the module that are located in ./pytest.

These tests validate functionality and also make requests to the Hiven API or rather in this case a Mock API to not spam the native Rest API of Hiven. (Visible here: https://mockapi.io/projects/61143430cba40600170c1e66)

To run these tests simply use (Make sure the pypi module pytest is installed):

cd ./pytest
pytest -q --token=<HIVEN_TOKEN>

A HIVEN_TOKEN is required for testing. Get one before running the tests, so they can run successfully. More info here

You need to be registered on Hiven and inside the openhiven.py house for correctly running the tests

Building

Building the module to be able to install it can be done using the build module of Python. Simply install build and then use this snippet to build the module:

python -m build

The build module/s should be located in ./dist

Uploading to PyPi and testing using twine

To upload a new version to PyPi simply use the pypi module twine.

Before uploading build the module and then test them using:

twine check dist/*

If everything is fine upload using:

twine upload dist/*

Docs

Deploying and testing docs

To deploy the docs simply use the python module mike, which is used for versioning. The following snippet will run a simple http server and update the docs when changed:

mike serve

Note! Install openhiven.py locally for the autodoc extension to work

Deploying new version to the gh-pages branch

To deploy new changes onto a new version, the gh-pages branch is used, which contains the docs for all previous versions. To push there you can either manually push changes (not recommended) or use mike to build, push and directly deploy using GitHub Pages:

Pushing new version:

mike deploy --push <version>

Note! This command can also be used to overwrite old documentations

Updating the latest alias

Delete old latest alias value

mike delete latest

Set new latest alias value

mike alias <version> latest 

Set default version/alias

Note! This is already set as default to the latest tag, meaning if the latest alias is updated, the default does not have to be altered.

mike set-default <version>

Version management

Mike: https://github.com/jimporter/mike

Contributors

Copyright and License

License

Copyright (c) 2021, Nicolas Klatzer* . All rights reserved.

See the LICENSE for information on terms & conditions for usage

*Legal name, which does not match the preferred and commonly used name Luna Klatzer