Skip to content

hemppa as lib#253

Draft
alertrix wants to merge 58 commits into
vranki:masterfrom
alertrix:hemppa-as-lib
Draft

hemppa as lib#253
alertrix wants to merge 58 commits into
vranki:masterfrom
alertrix:hemppa-as-lib

Conversation

@alertrix
Copy link
Copy Markdown

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…

Details 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