Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hemppa as lib #253

Draft
wants to merge 58 commits into
base: master
Choose a base branch
from
Draft

hemppa as lib #253

wants to merge 58 commits into from

Conversation

alertrix
Copy link

The original version of hemppa requires the users code to be added into the existing repository. To keep the repository of a new project clean, i suggest packaging the project as lib, so it can be installed into any other project.

Creating a new project is as easy as installing hemppa…

For example:
pip install git+https://github.com/alertrix/hemppa.git@4d8559acd8bb2e4ce298bb24e118d23957031501

… adding the files

my_package/
|- my_module/
| |- __init__.py
| |- my_command.py  # This file should have a unique name, as if defines the command used to call the functionality of the module
|- README.md
|- LICENSE

… adding the content

from hemppa.modules.common.module import BotModule


class MatrixModule(BotModule):

    def help(self):
        return "Just sayin' hi!"

    async def matrix_message(self, bot, room, event):
        await bot.send_text(room, 'Hello World')

into my_module/my_command.py

… starting the bot using the script defined in pyproject.toml

hemppa

and enabling the module in matrix:

!bot enable my_module.my_command

What still needs to be done

General consideration

In some environments some of the builtin dependencies might be illegal or require very complex regulation (eg google calendar under the gdpr in europe), so these dependencies should be dropped (or excluded into separate repositories, this pull request enables to install other modules using pip as well). This pull request only includes the bare bones dependencies (see below).

Specific instructions

The current dependencies still need to be added to the new format as demonstrated in this pull request for the mastodon module.

…r this package, so it is less likely to conflict with other packages
alertrix and others added 28 commits January 16, 2025 21:29
Optional dependencies for the mastodon module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant