Skip to main content

Using LINE Notify more easily

Project description

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 Notify bot quickly.

If you programing language is not python, here can find other language version:

Usage

You need a LINE account and create a Notify like this:

create-a-line-notify

Install package

pip install lotify

You can find sample - flask-line-notify

Environment variables

Input those variables in your .env file or OS environment (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'
)

Get authorizer link

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'}

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/

License

MIT © NiJia Lin & Duncan Huang

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

lotify-2.1.5.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

lotify-2.1.5-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file lotify-2.1.5.tar.gz.

File metadata

  • Download URL: lotify-2.1.5.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for lotify-2.1.5.tar.gz
Algorithm Hash digest
SHA256 7cb8e2682b5d2c2ca4d8e3b9a6fb681d5fc65705f8b6ca6d11976d807ca98066
MD5 3d89828d3b08e3e93082720b1526c1f1
BLAKE2b-256 703e2336e6ca43598605c5163d662e20ab676500d87d6052b531724755bcfbbe

See more details on using hashes here.

File details

Details for the file lotify-2.1.5-py3-none-any.whl.

File metadata

  • Download URL: lotify-2.1.5-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for lotify-2.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 98ab8a6b62a2a516f6855973a73a2f9c44c8fb71fcd838f8d9ceabd4a13d5026
MD5 dc8eea28af576581761866ee76c9cccf
BLAKE2b-256 fb9bb2a979a00775988dfdbb7ef15e5cf24269ac6b2d62d42f35b9f292b3eeab

See more details on using hashes here.

Supported by

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