Skip to main content

Webhook wrapper for ko-fi

Project description

Mofi

A simple webhook wrapper for Ko-fi

Mofi uses FastAPI to handle the webhooks.

Installation

$ pip install mofi

Usage

from mofi import Mofi, Donation, GlobalType, Subscription, ShopOrder

app = Mofi(token="token")


@app.callback("donation")
async def donation(data: Donation):
    print("Donation event.")


@app.callback("subscription")
async def subscription(data: Subscription):
    print("Subscription event")


@app.callback("shop_order")
async def shop_order(data: ShopOrder):
    print("Shop Order event")


@app.callback("global")
async def global_callback(data: GlobalType):
    print("Global event")  # matches all event types


app.run(host="127.0.0.1", port=8000)  # use 0.0.0.0 and 80 on deployment
from fastapi import FastAPI
from mofi import Mofi, GlobalType

app = FastAPI()
mofi_wh = Mofi(token="token")


@mofi_wh.callback("global")
async def global_type(data: GlobalType):
    print(data.from_name)


app.include_router(mofi_wh.as_router())  # add mofi after defining callbacks


@app.get("/")
async def index():
    return {"message": "Hello World"}

To get your token, go here and click "Advanced"

To test, use ngrok or similar to expose your local server to the internet.

$ ngrok http 8000

Then, set your webhook url to the ngrok url and you should see the events in your console.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mofi-0.2.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mofi-0.2.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file mofi-0.2.0.tar.gz.

File metadata

  • Download URL: mofi-0.2.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.5 Windows/10

File hashes

Hashes for mofi-0.2.0.tar.gz
Algorithm Hash digest
SHA256 188f9541d34da435cafaedfc6711bd98632ce0fa99ea73393012e67b76eaa1a5
MD5 1a9270623bde8b5a90463f45e2bd456c
BLAKE2b-256 c0a7c70e9ae03a2a79d021fd63a3a4e130b3fb17b72fa1341b9e187c3d82adbb

See more details on using hashes here.

File details

Details for the file mofi-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mofi-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.5 Windows/10

File hashes

Hashes for mofi-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d3542002366ba8558f3e1382bb630cec0178ad314b854baa9ab75f0c1ad9791
MD5 3a21adea2070a8cc9aa56dd281598a57
BLAKE2b-256 23cb8d30c9da8a36bd394281f96a0abe28cb5281829fd26080f64ea22cfdd85b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page