line.py
Python 非阻塞式 LINE Messaging API 串接, 輕鬆快速的製作 LINE 機器人
⚠️ 此 package 目前僅供(我)個人使用, 所以並沒有 cover 全部的 API, 如果有其他人想用的話, 我再加
安裝
pip install line-messaging-api
快速入門
import asyncio
from line import Bot, Cog, command, Context
class MyCog(Cog):
def __init__(self, bot: Bot) -> None:
super().__init__(bot)
@command
async def hello(self, ctx: Context) -> None:
await ctx.reply_text("Hello, world!")
async def main():
bot = Bot(channel_secret="YOUR_CHANNEL_SECRET", access_token="YOUR_ACCESS_TOKEN")
bot.add_cog(MyCog(bot))
await bot.run()
asyncio.run(main())
功能
- 使用 aiohttp 及 asyncio, 完全非阻塞式運行 (async/await)
- 底層使用 LINE 官方 Python SDK
- 完整的 type hints (PEP 484)
- 簡單上手, 快速製作 LINE 機器人
文檔
其他
LINE 已經有 SDK 了, 為什麼還要寫 line.py?
- v3 的 SDK 可能因為是從 API 自動生成 model 的關係, 有非常糟糕的 typing 問題, 使用 line.py 完全不會遇到奇怪的紅線跟需要大量使用 type: ignore 的問題
- 學習難度高, 不易使用, 不適合新手
- 沒有一個快速新增指令的方法, 導致程式碼很冗長
你是不是抄襲 discord.py?
對。
但是 discord.py 的程式碼太高深了我看不懂, 所以只是參考概念 (例如 cog, 一些 function 的名稱, 新增指令的方式), 然後慢慢刻出來 line.py。
聯絡
有疑問可以加我 Discord:@seria_ati
Metadata
Release files for line-messaging-api 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| line_messaging_api-0.9.0.tar.gz | 70.2 kB | Without provenance | Details for line_messaging_api-0.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| line_messaging_api-0.9.0-py3-none-any.whl | Python 3 | none | any | Details for line_messaging_api-0.9.0-py3-none-any.whl |
Total release size: 112.8 kB
Release files / line_messaging_api-0.9.0.tar.gz
| Download URL | line_messaging_api-0.9.0.tar.gz |
|---|---|
| Size | 70.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d85004648afa3b65ab99a3741f276f31ee1c3aeeeeec1cc77ab3a030fc7b4bba
|
|
BLAKE2b-256 checksum How to use checksums |
1e19bf1ae43c369fd03f4cf083d5dddb4f5fc44858464285a54e1a3a02a06ca6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.4.18
|
Release files / line_messaging_api-0.9.0-py3-none-any.whl
| Download URL | line_messaging_api-0.9.0-py3-none-any.whl |
|---|---|
| Size | 42.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d044437c262f19345212dd038459cdbfabf3d629f9b50f2581cae823eb5c4581
|
|
BLAKE2b-256 checksum How to use checksums |
bca8b55567a97dd32d31314aa96f47c1340f5a52e4caf97b482e991681ce8587
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.4.18
|
Security for line-messaging-api 0.9.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.