LINE Official User API wrapper library for Python
Project description
LINEOALib
LINEOALibは、LINE公式アカウントの管理・チャット・認証・自動化をPythonから簡単に扱えるライブラリです。
特徴
- Seleniumによる認証・Cookie管理
- 複数Bot・チャットの取得・送信・監視
インストール
pip install lineoa
使い方
1. 初回認証(SeleniumによるCookie保存)
from LINELib.linebot import LineBot
COOKIE_PATH = os.environ.get("LINEOA_COOKIE_PATH", "lineoa_cookie.json")
bot = LineBot(storage=COOKIE_PATH, ping_secs=20) # 初回はSeleniumで手動ログイン
#storageを設定することによりcookieを保存
2. 以降はCookie自動復元
from LINELib.linebot import LineBot
COOKIE_PATH = os.environ.get("LINEOA_COOKIE_PATH", "lineoa_cookie.json")
bot = LineBot(storage=COOKIE_PATH, ping_secs=20)
#次回からcookieを利用してログイン
3. Bot一覧・チャット一覧取得
bots = bot.bots.ids # {bot名: botId}
chats = bot.chats.user.ids # ユーザーchatId一覧
4. メッセージ送信
bot.sendMessage(bot_id, user_id, "こんにちは!")
5. 画像送信
bot.sendFile(bot_id, chat_id, "sample.png")
6. メッセージ監視
bot.listen(botid="U*****")
7. リプライ返信
bot.sendMessage(bot_id=bot_id, chat_id=chat_id, text="りぷらい", quoteToken=quoteToken)
8. グループ内のメンバー全取得
bot.getMembers(bot_id=bot_id, chat_id=chat_id)
9. 簡単なpolling例
from LINELib.linebot import LineBot
bot = LineBot(
cookie_path="lineoa-storage.json", # cookieファイルパスのみ指定
ping_secs=20
)
BOT_ID = "U****"
@bot.event
def on_message(event):
payload = event.get('payload', {})
chat_payload = payload.get('payload', {})
message = chat_payload.get('message', {})
text = message.get('text', '')
if message.get('type') == 'text' and text == "ping":
bot.sendMessage(bot_id=payload.get('botId'), chat_id=payload.get('chatId'), text="pong!")
if __name__ == "__main__":
bot.listen(botid=BOT_ID)
サンプル
example を参照してください。
クラス構成
linebot... モダンな設計思想に基づくクラスLINELib... 全機能統合のメインクラスAuthService... 認証・Cookie管理ChatService... チャットAPILINEOAError... 例外クラス
ライセンス
MIT 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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lineoa-4.4.4.tar.gz.
File metadata
- Download URL: lineoa-4.4.4.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d6dc71cf87e3c1c4d09856fa5a84790b0710ebd67ac82296717b93bf3f70514
|
|
| MD5 |
7c4f9d0259b185562493094f62c24d01
|
|
| BLAKE2b-256 |
3357424f7397fdb50753b9a19baefb2cf0d71da73381e1fc1ca8569b79daa037
|
Provenance
The following attestation bundles were made for lineoa-4.4.4.tar.gz:
Publisher:
python-publish.yml on Madoa5561/LINELib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lineoa-4.4.4.tar.gz -
Subject digest:
7d6dc71cf87e3c1c4d09856fa5a84790b0710ebd67ac82296717b93bf3f70514 - Sigstore transparency entry: 854969617
- Sigstore integration time:
-
Permalink:
Madoa5561/LINELib@7bb88a266c1855f28287b1ec2d227b9a4068dc3f -
Branch / Tag:
refs/tags/4.4.4 - Owner: https://github.com/Madoa5561
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@7bb88a266c1855f28287b1ec2d227b9a4068dc3f -
Trigger Event:
release
-
Statement type:
File details
Details for the file lineoa-4.4.4-py3-none-any.whl.
File metadata
- Download URL: lineoa-4.4.4-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
568a3c448c15bd2a74d26b5d750a14f134c518ef11fbb0c06115956695f6ec45
|
|
| MD5 |
32d2c008bd88188c32b76dfe121fb18f
|
|
| BLAKE2b-256 |
763aeaed943c9299482e9349e2d426e5d3525c163ad65f22c2931e16da681e91
|
Provenance
The following attestation bundles were made for lineoa-4.4.4-py3-none-any.whl:
Publisher:
python-publish.yml on Madoa5561/LINELib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lineoa-4.4.4-py3-none-any.whl -
Subject digest:
568a3c448c15bd2a74d26b5d750a14f134c518ef11fbb0c06115956695f6ec45 - Sigstore transparency entry: 854969624
- Sigstore integration time:
-
Permalink:
Madoa5561/LINELib@7bb88a266c1855f28287b1ec2d227b9a4068dc3f -
Branch / Tag:
refs/tags/4.4.4 - Owner: https://github.com/Madoa5561
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@7bb88a266c1855f28287b1ec2d227b9a4068dc3f -
Trigger Event:
release
-
Statement type: