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
Release history Release notifications | RSS feed
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 hashes)
Built Distribution
mofi-0.2.0-py3-none-any.whl
(4.8 kB
view hashes)