Skip to main content

Lotify - LINE Notify client SDK

License: MIT PRs Welcome Build Status pypi package Python Version

📖 Chinese traditional version

Lotify is a LINE Notify client SDK that you can build notification bot quickly.

If your programing language is not python, here had another language:

Usage

First, you need a LINE account and create a LINE Notify channel as following:

create-a-line-notify

Install package

pip install lotify

Here has example - flask-line-notify

Command line

lotify -t YOUR_TOKEN -m 'this is example'

Environment variables

Input those variables in your .env file or OS environment (or using export).

Then you don't need to input any parameters in initialize step.

LINE_NOTIFY_CLIENT_ID
LINE_NOTIFY_CLIENT_SECRET
LINE_NOTIFY_REDIRECT_URI

Initialize instance

  • If you already have Notify environment variables:
from lotify.client import Client

client = Client()
  • else:
from lotify.client import Client

client = Client(
    client_id='YOUR_CLIENT_ID',
    client_secret='YOUR_CLIENT_SECRET',
    redirect_uri='YOUR_URI'
)
link = client.get_auth_link(state='RANDOM_STRING')
print(link)
# https://notify-bot.line.me/oauth/authorize?scope=notify&response_type=code&client_id=QxUxF..........i51eITH&redirect_uri=http%3A%2F%2Flocalhost%3A5000%2Fnotify&state=foo

Get access token

access_token = client.get_access_token(code='NOTIFY_RESPONSE_CODE')
print(access_token)
# N6g50DiQZk5Xh...25FoFzrs2npkU3z

Get Status

status = client.status(access_token='YOUR_ACCESS_TOKEN')
print(status)
# {'status': 200, 'message': 'ok', 'targetType': 'USER', 'target': 'NiJia Lin'}

Send message

push-notify

response = client.send_message(access_token='YOUR_ACCESS_TOKEN', message='This is notify message')
print(response)
# {'status': 200, 'message': 'ok'}

Send message with Sticker

push-notify-with-sticker

You can find stickerId and stickerPackageId here.

response = client.send_message_with_sticker(
    access_token='YOUR_ACCESS_TOKEN',
    message='This is notify message',
    sticker_id=1,
    sticker_package_id=1)
print(response)
# {'status': 200, 'message': 'ok'}

Send message with Files

send-message-with-image-path

image = client.send_message_with_image_file(
    access_token='YOUR_ACCESS_TOKEN',
    message='This is notify message',
    file=open('./test_image.png', 'rb')
)
print(image)
# {'status': 200, 'message': 'ok'}

Send message with Image url

send-message-with-image-url

image = client.send_message_with_image_url(
    access_token='YOUR_ACCESS_TOKEN',
    message='This is notify message',
    image_thumbnail='https://i.imgur.com/RhvwZVm.png',
    image_fullsize='https://i.imgur.com/RhvwZVm.png',
)
print(image)
# {'status': 200, 'message': 'ok'}

Revoke access token

revoke-line-notify-token

revoke = client.revoke(access_token='YOUR_ACCESS_TOKEN')
print(revoke)
# {'status': 200, 'message': 'ok'}

Command Line Interface

lotify --help
-t, --access_token TEXT  access token  [required]
-m, --message TEXT       message to send  [required]
-u, --image-url TEXT     image url to send
-f, --image-file TEXT    image file path to send

Contributing

Fork before Clone the repository:

git clone git@github.com:your-username/line-notify.git

First install for development.

pip install -r requirements-dev.txt

Run pytest to make sure the tests pass:

cd line-notify/
python -m tox
python -m pytest --flake8 tests/

Command Line Debug

If you met following logs.

Traceback (most recent call last):
  File "/usr/local/bin/lotify", line 33, in <module>
    sys.exit(load_entry_point('lotify==2.3.2', 'console_scripts', 'lotify')())
  File "/usr/local/bin/lotify", line 25, in importlib_load_entry_point
    return next(matches).load()
StopIteration

Uninstall old package and reinstall.

pip uninstall lotify
pip install lotify

Then StopIteration would go away.

License

MIT © NiJia Lin & Duncan Huang

Metadata

Release files for lotify 2.3.4

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

Source distribution (sdist)

Source distribution for lotify 2.3.4
File Size Uploaded Provenance
lotify-2.3.4.tar.gz 7.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for lotify 2.3.4
File Interpreter ABI Platform
lotify-2.3.4-py3-none-any.whl Python 3 none any Details

Total release size: 14.5 kB

Release files / lotify-2.3.4.tar.gz

Download URL lotify-2.3.4.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5cf0437bcc5320863e0fb1029bb60711e395fe624b099289e922f390c3df570f
BLAKE2b-256 checksum
How to use checksums
1530f4c3eb067aa0e72aad51916a98a52e1d82c06eb595486fc4693af8f7f227
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

Release files / lotify-2.3.4-py3-none-any.whl

Download URL lotify-2.3.4-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
18611519bbc53d06c4da3138a78b14535cbda0c76ba33efa899fcfd7b68247d4
BLAKE2b-256 checksum
How to use checksums
4703a5d42eda83ed55a76415e11ff5da9d05044fed1dd9b7617955f3d78ad8d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

Security for lotify 2.3.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

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