Skip to content

A multi-platform notification tool. Support telegram, wechat, webhook, wirepusher and more

License

Notifications You must be signed in to change notification settings

George-Miao/Knotify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Knotify

Knotify is a simple tool that helps you to push notifications and other messages to the dedicated clients Include Telegram Bot, Webhook, WirePusher, Wechat Bot (Server Chan)

Quick Start

Use pip to install Knotify first:

pip install knotify

Then get the "key" from the client you want to use:

Use context manager for a quick and easy notification:

from knotify import WirePusher
async def main():
    async with WirePusher("Your_Token_From_WirePusher") as w:
        w.emit("FooBar")

If you want to keep the instance for a longer lifespan, remember to use await PusherInstance.close() afterwards:

from knotify import WirePusher
async def main():
    w = WirePusher("Your_Token_From_WirePusher")            
    await w.emit("Foo")
    await w.emit("Bar")
    await w.close()

Pre-defined Pushers

Webhook

The "key" will be the url you want to post to itself

e.g. Discord Server Webhook

Wechat

The wechat client is Server Chan(Server酱) and the key will be sckey

Telegram

The telegram client is tg_push_bot from Fndroid. Use Manual

WirePusher

WirePusher is an Android app that allows you to send push notifications right to your device.

Custom Pusher

Create a custom pusher by inheriting from BasePusher:

class CustomPusher(BasePusher):
    pass

And all you need to do is to overload the _push function which will be invoked by emit function:

async def _push(self, message, **kwargs) -> bool:
    """
    Overload this function to create custom pusher
    :param message: message to be sent
    :param kwargs: all params to be sent
        use function `_build_body` to build a dict for params
    :return: Returns True if pushing is succeeded, Otherwise False
    """
    pass

Use the built-in aiohttp.ClientSession to invoke http api and self._check_result to check result:

async def _push(self, message, **kwargs) -> bool:
    with self.s.get("api", data=kwargs) as result:
        return self._check_result(result)

Requirement

  • Python 3.6+
  • aiohttp

License

MIT License

About

A multi-platform notification tool. Support telegram, wechat, webhook, wirepusher and more

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages