lotify


Namelotify JSON
Version 2.3.4 PyPI version JSON
download
home_pagehttps://github.com/louis70109/line-notify
SummaryUsing LINE Notify more easily
upload_time2021-05-31 11:23:21
maintainerNiJia Lin
docs_urlNone
authorNiJia Lin
requires_python!=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
licenseMIT
keywords line notify python lotify
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Lotify - LINE Notify client SDK

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/louis70109/line-notify#contributing)
[![Build Status](https://travis-ci.com/louis70109/lotify.svg?branch=master)](https://travis-ci.org/louis70109/lotify)
[![pypi package](https://badge.fury.io/py/lotify.svg)](https://badge.fury.io/py/lotify)
[![Python Version](https://img.shields.io/badge/Python-%3E%3D%203.5-blue.svg)](https://badge.fury.io/py/lotify)

📖 [Chinese traditional version](https://github.com/louis70109/lotify/blob/master/README-zh_TW.md)

**Lotify** is a [LINE Notify](https://notify-bot.line.me/doc/en/) client SDK that you can build notification bot quickly.

![](https://i.imgur.com/Rms5ZNG.png)

If your programing language is not python, here had another language:

- [Ruby](https://github.com/etrex/lotify)
- [PHP](https://github.com/eric0324/lotify)

# Usage

First, you need a **LINE account** and create a LINE Notify channel as following:

![create-a-line-notify](https://i.imgur.com/m9q4jLOl.png)

## Install package

```
pip install lotify
```

> Here has example - [flask-line-notify](https://github.com/louis70109/flask-line-notify)

## Command line

```
lotify -t YOUR_TOKEN -m 'this is example'
```

## Environment variables

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

```python
from lotify.client import Client

client = Client()
```

- else:

```python
from lotify.client import Client

client = Client(
    client_id='YOUR_CLIENT_ID',
    client_secret='YOUR_CLIENT_SECRET',
    redirect_uri='YOUR_URI'
)
```

## Get authorizer link

```python
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

```python
access_token = client.get_access_token(code='NOTIFY_RESPONSE_CODE')
print(access_token)
# N6g50DiQZk5Xh...25FoFzrs2npkU3z
```

## Get Status

```python
status = client.status(access_token='YOUR_ACCESS_TOKEN')
print(status)
# {'status': 200, 'message': 'ok', 'targetType': 'USER', 'target': 'NiJia Lin'}
```

## Send message

![push-notify](https://i.imgur.com/RhvwZVm.png)

```python
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](https://i.imgur.com/EWpZahk.png)

#### You can find stickerId and stickerPackageId [here](https://developers.line.biz/media/messaging-api/sticker_list.pdf).

```python
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](https://i.imgur.com/ESCrk8b.png)

```python
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](https://i.imgur.com/0Lxatu9.png)

```python
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](https://i.imgur.com/7GAAzOi.png)

```python
revoke = client.revoke(access_token='YOUR_ACCESS_TOKEN')
print(revoke)
# {'status': 200, 'message': 'ok'}
```

## Command Line Interface
```commandline
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
```

# 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/
```

# Command Line Debug
If you met following logs.

```shell
Traceback (most recent call last):
  File "/usr/local/bin/lotify", line 33, in <module>
    sys.exit(load_entry_point('lotify==2.3.2', 'console_scripts', 'lotify')())
  File "/usr/local/bin/lotify", line 25, in importlib_load_entry_point
    return next(matches).load()
StopIteration
```

Uninstall old package and reinstall.

```shell
pip uninstall lotify
pip install lotify
```

Then `StopIteration` would go away.

# License

[MIT](https://github.com/louis70109/line-notify/blob/master/LICENSE) © [NiJia Lin](https://nijialin.com/about/) & [Duncan Huang](https://github.com/ragnaok)



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/louis70109/line-notify",
    "name": "lotify",
    "maintainer": "NiJia Lin",
    "docs_url": null,
    "requires_python": "!=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
    "maintainer_email": "louis70109@gmail.com",
    "keywords": "LINE notify python lotify",
    "author": "NiJia Lin",
    "author_email": "louis70109@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/15/30/f4c3eb067aa0e72aad51916a98a52e1d82c06eb595486fc4693af8f7f227/lotify-2.3.4.tar.gz",
    "platform": "",
    "description": "# Lotify - LINE Notify client SDK\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/louis70109/line-notify#contributing)\n[![Build Status](https://travis-ci.com/louis70109/lotify.svg?branch=master)](https://travis-ci.org/louis70109/lotify)\n[![pypi package](https://badge.fury.io/py/lotify.svg)](https://badge.fury.io/py/lotify)\n[![Python Version](https://img.shields.io/badge/Python-%3E%3D%203.5-blue.svg)](https://badge.fury.io/py/lotify)\n\n\ud83d\udcd6 [Chinese traditional version](https://github.com/louis70109/lotify/blob/master/README-zh_TW.md)\n\n**Lotify** is a [LINE Notify](https://notify-bot.line.me/doc/en/) client SDK that you can build notification bot quickly.\n\n![](https://i.imgur.com/Rms5ZNG.png)\n\nIf your programing language is not python, here had another language:\n\n- [Ruby](https://github.com/etrex/lotify)\n- [PHP](https://github.com/eric0324/lotify)\n\n# Usage\n\nFirst, you need a **LINE account** and create a LINE Notify channel as following:\n\n![create-a-line-notify](https://i.imgur.com/m9q4jLOl.png)\n\n## Install package\n\n```\npip install lotify\n```\n\n> Here has example - [flask-line-notify](https://github.com/louis70109/flask-line-notify)\n\n## Command line\n\n```\nlotify -t YOUR_TOKEN -m 'this is example'\n```\n\n## Environment variables\n\nInput those variables in your `.env` file or OS environment (or using `export`).\n\nThen you don't need to input any parameters in `initialize step`.\n\n```\nLINE_NOTIFY_CLIENT_ID\nLINE_NOTIFY_CLIENT_SECRET\nLINE_NOTIFY_REDIRECT_URI\n```\n\n## Initialize instance\n\n- If you already have Notify environment variables:\n\n```python\nfrom lotify.client import Client\n\nclient = Client()\n```\n\n- else:\n\n```python\nfrom lotify.client import Client\n\nclient = Client(\n    client_id='YOUR_CLIENT_ID',\n    client_secret='YOUR_CLIENT_SECRET',\n    redirect_uri='YOUR_URI'\n)\n```\n\n## Get authorizer link\n\n```python\nlink = client.get_auth_link(state='RANDOM_STRING')\nprint(link)\n# 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\n```\n\n## Get access token\n\n```python\naccess_token = client.get_access_token(code='NOTIFY_RESPONSE_CODE')\nprint(access_token)\n# N6g50DiQZk5Xh...25FoFzrs2npkU3z\n```\n\n## Get Status\n\n```python\nstatus = client.status(access_token='YOUR_ACCESS_TOKEN')\nprint(status)\n# {'status': 200, 'message': 'ok', 'targetType': 'USER', 'target': 'NiJia Lin'}\n```\n\n## Send message\n\n![push-notify](https://i.imgur.com/RhvwZVm.png)\n\n```python\nresponse = client.send_message(access_token='YOUR_ACCESS_TOKEN', message='This is notify message')\nprint(response)\n# {'status': 200, 'message': 'ok'}\n```\n\n## Send message with Sticker\n\n![push-notify-with-sticker](https://i.imgur.com/EWpZahk.png)\n\n#### You can find stickerId and stickerPackageId [here](https://developers.line.biz/media/messaging-api/sticker_list.pdf).\n\n```python\nresponse = client.send_message_with_sticker(\n    access_token='YOUR_ACCESS_TOKEN',\n    message='This is notify message',\n    sticker_id=1,\n    sticker_package_id=1)\nprint(response)\n# {'status': 200, 'message': 'ok'}\n```\n\n## Send message with Files\n\n![send-message-with-image-path](https://i.imgur.com/ESCrk8b.png)\n\n```python\nimage = client.send_message_with_image_file(\n    access_token='YOUR_ACCESS_TOKEN',\n    message='This is notify message',\n    file=open('./test_image.png', 'rb')\n)\nprint(image)\n# {'status': 200, 'message': 'ok'}\n```\n\n## Send message with Image url\n\n![send-message-with-image-url](https://i.imgur.com/0Lxatu9.png)\n\n```python\nimage = client.send_message_with_image_url(\n    access_token='YOUR_ACCESS_TOKEN',\n    message='This is notify message',\n    image_thumbnail='https://i.imgur.com/RhvwZVm.png',\n    image_fullsize='https://i.imgur.com/RhvwZVm.png',\n)\nprint(image)\n# {'status': 200, 'message': 'ok'}\n```\n\n## Revoke access token\n\n![revoke-line-notify-token](https://i.imgur.com/7GAAzOi.png)\n\n```python\nrevoke = client.revoke(access_token='YOUR_ACCESS_TOKEN')\nprint(revoke)\n# {'status': 200, 'message': 'ok'}\n```\n\n## Command Line Interface\n```commandline\nlotify --help\n-t, --access_token TEXT  access token  [required]\n-m, --message TEXT       message to send  [required]\n-u, --image-url TEXT     image url to send\n-f, --image-file TEXT    image file path to send\n```\n\n# Contributing\n\nFork before Clone the repository:\n\n```\ngit clone git@github.com:your-username/line-notify.git\n```\n\nFirst install for development.\n\n```\npip install -r requirements-dev.txt\n```\n\nRun `pytest` to make sure the tests pass:\n\n```\ncd line-notify/\npython -m tox\npython -m pytest --flake8 tests/\n```\n\n# Command Line Debug\nIf you met following logs.\n\n```shell\nTraceback (most recent call last):\n  File \"/usr/local/bin/lotify\", line 33, in <module>\n    sys.exit(load_entry_point('lotify==2.3.2', 'console_scripts', 'lotify')())\n  File \"/usr/local/bin/lotify\", line 25, in importlib_load_entry_point\n    return next(matches).load()\nStopIteration\n```\n\nUninstall old package and reinstall.\n\n```shell\npip uninstall lotify\npip install lotify\n```\n\nThen `StopIteration` would go away.\n\n# License\n\n[MIT](https://github.com/louis70109/line-notify/blob/master/LICENSE) \u00a9 [NiJia Lin](https://nijialin.com/about/) & [Duncan Huang](https://github.com/ragnaok)\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Using LINE Notify more easily",
    "version": "2.3.4",
    "project_urls": {
        "Bug Reports": "https://github.com/louis70109/lotify/issues",
        "Homepage": "https://github.com/louis70109/line-notify",
        "Source": "https://github.com/louis70109/lotify"
    },
    "split_keywords": [
        "line",
        "notify",
        "python",
        "lotify"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4703a5d42eda83ed55a76415e11ff5da9d05044fed1dd9b7617955f3d78ad8d5",
                "md5": "0afadaf192ad71fa2abaa935efd193e5",
                "sha256": "18611519bbc53d06c4da3138a78b14535cbda0c76ba33efa899fcfd7b68247d4"
            },
            "downloads": -1,
            "filename": "lotify-2.3.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0afadaf192ad71fa2abaa935efd193e5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "!=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
            "size": 6680,
            "upload_time": "2021-05-31T11:23:20",
            "upload_time_iso_8601": "2021-05-31T11:23:20.108257Z",
            "url": "https://files.pythonhosted.org/packages/47/03/a5d42eda83ed55a76415e11ff5da9d05044fed1dd9b7617955f3d78ad8d5/lotify-2.3.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1530f4c3eb067aa0e72aad51916a98a52e1d82c06eb595486fc4693af8f7f227",
                "md5": "79e95bd84f806883918902c1ecbda57b",
                "sha256": "5cf0437bcc5320863e0fb1029bb60711e395fe624b099289e922f390c3df570f"
            },
            "downloads": -1,
            "filename": "lotify-2.3.4.tar.gz",
            "has_sig": false,
            "md5_digest": "79e95bd84f806883918902c1ecbda57b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "!=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
            "size": 7791,
            "upload_time": "2021-05-31T11:23:21",
            "upload_time_iso_8601": "2021-05-31T11:23:21.283771Z",
            "url": "https://files.pythonhosted.org/packages/15/30/f4c3eb067aa0e72aad51916a98a52e1d82c06eb595486fc4693af8f7f227/lotify-2.3.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-05-31 11:23:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "louis70109",
    "github_project": "line-notify",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "lotify"
}
        
Elapsed time: 0.32253s