Skip to content
hakimifrPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

219 Commits

Folders and files

Repository files navigation

hbot

Note

If you ever plan on working with this codebase:

  1. Make sure ruff and uv is installed
  2. Before commiting, make sure to run make lint (this will run the codebase through ruff)

How to Run

As seen in main.py, you need to export a few variables.

api_id = os.getenv("API_ID")
api_hash = os.getenv("API_HASH")

That is, API_ID and API_HASH. These can be obtained from https://my.telegram.org/apps.

Also, for the Gemini plugin, you will need to export GEMINI_API_KEY. Without it, the bot won't crash, but the gemini plugin itself will log an error if you try to use it.

Here's a snippet where that happens:

async def search_handler(self, client: Client, message: Message) -> None:
    if os.getenv(key="GEMINI_API_KEY") is None:
        await message.edit_text("api key for gemini is not set")
        logger.error("api key for gemini is not set, please export GEMINI_API_KEY")
        return

        [...snipped...]

Once you meet the prerequisites above, you can run the bot with uv:

uv sync --frozen
uv run python3 -m hbot

For convenience, you can run the bot using the Makefile provided:

make run

Hosting

The bot by default assume you have persistent storage at /persist/storage. However, should you have the need to use a different path, export the variable PERSIST_DIR with the desired path. All you configs will by saved by jsondb to the path.

Building Documentations

You probably want to read the documentations here instead.

To build the documentations, you need to have make installed. Simply run

make html

The Makefile was generated by sphinx. The built page live on build/html directory.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages