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.
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 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 Image path
image = client.send_message_with_image_path(
access_token='YOUR_ACCESS_TOKEN',
message='This is notify message',
image_path='./test_image.png'
)
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
lotify-1.2.5.tar.gz
(7.3 kB
view details)
File details
Details for the file lotify-1.2.5.tar.gz
.
File metadata
- Download URL: lotify-1.2.5.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90ed3b2545ceb0659f6ac70bbd84fc5338cd5138825fb9c66efff420ac5cb8bd |
|
MD5 | 7cf7a6315892030349c494fb40d0304d |
|
BLAKE2b-256 | a5901701325e575f2f4ca2ec69e2dfdf85fab868d6bdef98e7d2f782a7731402 |