Skip to content

Jedddy/mofi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

With fastapi:

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.

About

A webhook wrapper for Ko-fi written in Python

Resources

License

Stars

Watchers

Forks

Contributors

Languages