Skip to main content

Memos Webhook Python Implementation

This is a simple webhook implementation in Python.

It implements a simple URL resource download feature. All url you-get support for command you-get https://xxxxx can be configured to download.

Quick Feel It

  1. Create a docker_compose.yaml with following contents. Replace xxxxxxxx with your memos token.

    version: "3.0"
    services:
    memos:
        networks:
        - memos
        image: neosmemo/memos:0.22.1
        container_name: memos
        ports:
        - 5230:5230
    webhook:
        image: ghcr.io/ryojerryyu/memos-webhook-py:0.3.0
        networks:
        - memos
        container_name: webhook
        environment:
        - LOG_LEVEL=debug
        - WEBHOOK_PORT=8000
        - MEMOS_HOST=memos
        - MEMOS_PORT=5230
        - MEMOS_TOKEN=xxxxxxxx
        volumes:
        - ./.download:/app/download
    
    networks:
    memos:
    
  2. Run docker-compose up -d to start the services.

  3. Access localhost:5230 , login and make sure the Memos server work. Create a webhook to http://webhook:8000/webhook . (It's for Memos server after 0.22.2. For before 0.22.1, use http://webhook:8000/webhook_old)

  4. Post a memo with contents containing a twitter url. If that tweet was attached with some image, the webhook will download them and upload to the Memo server automatically.

You can use a config file to configure what url you want to download. The default config file is config.yaml.

Config

You can use a config file by setting the environment variable CONFIG_PATH. Here is a docker_compose.yaml example:

version: "3.0"
services:
  memos:
    networks:
      - memos
    image: neosmemo/memos:0.22.1
    container_name: memos
    ports:
      - 5230:5230
  webhook:
    image: ghcr.io/ryojerryyu/memos-webhook-py:0.3.0
    networks:
      - memos
    container_name: webhook
    environment:
      - CONFIG_PATH=/app/config.yaml
    volumes:
      - ./.download:/app/download
      - ./path/to/your/local/config/file.yaml:/app/config.yaml

networks:
  memos:

You should place your config file in ./path/to/your/local/config/file.yaml and the webhook will read the config from it.

Here is an example of the configuration file: config.yaml

webhook:
  host: localhost
  port: 11100

memos:
  host: localhost
  port: 5230
  token: xxxxxxx

plugins:
  - name: download
    tag: webhook/download
    you_get_plugin:
      patterns:
        - https://twitter.com/\w+/status/\d+
        - https://x.com/\w+/status/\d+
  - name: fix_typos
    tag: task/fix_typos
    zhipu_plugin:
      api_key: xxxxxxx
      prompt: |
        You are a fix typos plugin.
        Please fix the typos in the text.

        The text is:
        ```
        {content}
        ```

And config definitionn is in config.py

Metadata

Release files for memos-webhook 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for memos-webhook 0.6.0
File Size Uploaded
memos_webhook-0.6.0.tar.gz 47.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for memos-webhook 0.6.0
File Interpreter ABI Platform
memos_webhook-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 102.4 kB

Release files / memos_webhook-0.6.0.tar.gz

Download URL memos_webhook-0.6.0.tar.gz
Size 47.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c00274f5ec314ed1688e4476da251b14163999f5501c43df7087f7e4b82a95a5
BLAKE2b-256 checksum
How to use checksums
35192973c4e7c85bd50a8bbdc0f0a0e4a26de64d698c44ca47c76c15d4c3e2c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.3

Release files / memos_webhook-0.6.0-py3-none-any.whl

Download URL memos_webhook-0.6.0-py3-none-any.whl
Size 55.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9389d91c4c38bf82bb5168c2aa35e1de5b136e29b9353a29eb5399382245c1eb
BLAKE2b-256 checksum
How to use checksums
d36b569d448b23371a9f0559060207fc0d15fe471eee6b288c50f2a9d63e4585
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.3
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page