Using Line Notify more easily
Project description
Lotify - LINE Notify client SDK
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:
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
response = client.send_message(access_token='YOUR_ACCESS_TOKEN', message='This is notify message')
print(response)
# {'status': 200, 'message': 'ok'}
Send message 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
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
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 = 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
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
Built Distribution
File details
Details for the file lotify-2.1.1.tar.gz
.
File metadata
- Download URL: lotify-2.1.1.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 508d53b300c3221d49489700aa6b0fe5f9d4e362fa98def2e3c6176e8b57f3fa |
|
MD5 | 9fd08d5ec204e8d8709d8148a9e071e7 |
|
BLAKE2b-256 | 45b5476e0fad054c68006030987deff4fd06baa77252230f1860cd4084d97084 |
File details
Details for the file lotify-2.1.1-py3-none-any.whl
.
File metadata
- Download URL: lotify-2.1.1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb6ed7f3fd3b0880a2ed7b6c6d2e5f6ce1e04f977c3984ff9083b5e641b3495e |
|
MD5 | 486fb2e78ebb91c6234ebb00148c04cf |
|
BLAKE2b-256 | ec462623e329b3d79d98750ab112a9c236d5eb8fce6a508b30094796be2a09f1 |