Package: lotify
Lotify - LINE Notify client SDK📖Chinese traditional versionLotifyis aLINE Notifyclient SDK that you can build notification bot quickly.If your programing language is not python, here had another language:RubyPHPUsageFirst, you need aLINE accountand create a LINE Notify channel as following:Install packagepip install lotifyHere has example -flask-line-notifyCommand linelotify -t YOUR_TOKEN -m 'this is example'Environment variablesInput those variables in your.envfile or OS environment (or usingexport).Then you don't need to input any parameters ininitialize step.LINE_NOTIFY_CLIENT_ID
LINE_NOTIFY_CLIENT_SECRET
LINE_NOTIFY_REDIRECT_URIInitialize instanceIf you already have Notify environment variables:fromlotify.clientimportClientclient=Client()else:fromlotify.clientimportClientclient=Client(client_id='YOUR_CLIENT_ID',client_secret='YOUR_CLIENT_SECRET',redirect_uri='YOUR_URI')Get authorizer linklink=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=fooGet access tokenaccess_token=client.get_access_token(code='NOTIFY_RESPONSE_CODE')print(access_token)# N6g50DiQZk5Xh...25FoFzrs2npkU3zGet Statusstatus=client.status(access_token='YOUR_ACCESS_TOKEN')print(status)# {'status': 200, 'message': 'ok', 'targetType': 'USER', 'target': 'NiJia Lin'}Send messageresponse=client.send_message(access_token='YOUR_ACCESS_TOKEN',message='This is notify message')print(response)# {'status': 200, 'message': 'ok'}Send message with StickerYou can find stickerId and stickerPackageIdhere.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 Filesimage=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 urlimage=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 tokenrevoke=client.revoke(access_token='YOUR_ACCESS_TOKEN')print(revoke)# {'status': 200, 'message': 'ok'}Command Line Interfacelotify --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 sendContributingFork before Clone the repository:git clone git@github.com:your-username/line-notify.gitFirst install for development.pip install -r requirements-dev.txtRunpytestto make sure the tests pass:cd line-notify/
python -m tox
python -m pytest --flake8 tests/Command Line DebugIf you met following logs.Traceback(mostrecentcalllast):File"/usr/local/bin/lotify",line33,in<module>sys.exit(load_entry_point('lotify==2.3.2','console_scripts','lotify')())File"/usr/local/bin/lotify",line25,inimportlib_load_entry_pointreturnnext(matches).load()StopIterationUninstall old package and reinstall.pipuninstalllotify
pipinstalllotifyThenStopIterationwould go away.LicenseMIT©NiJia Lin&Duncan Huang