📖 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:
You need a LINE account and create a Notify like this:
pip install lotify
You can find sample - flask-line-notify
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
- 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
access_token = client.get_access_token(code='NOTIFY_RESPONSE_CODE')
print(access_token)
# N6g50DiQZk5Xh...25FoFzrs2npkU3z
status = client.status(access_token='YOUR_ACCESS_TOKEN')
print(status)
# {'status': 200, 'message': 'ok', 'targetType': 'USER', 'target': 'NiJia Lin'}
response = client.send_message(access_token='YOUR_ACCESS_TOKEN', message='This is notify message')
print(response)
# {'status': 200, 'message': 'ok'}
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'}
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'}
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 = client.revoke(access_token='YOUR_ACCESS_TOKEN')
print(revoke)
# {'status': 200, 'message': 'ok'}
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
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/
MIT © NiJia Lin & Duncan Huang