line-bot-tool
LINEBot用の便利ツール
PIP
pipからインストール可能
$ pip install line-bot-tool
Usage
LINEBotで使用するコマンドを生成
$ lb-tool gen:command help
Generate success! commands/help_command.py
デフォルトで ./commands 配下に生成される。
環境変数 COMMAND_OUTPUT_PATH に設定することで、生成されるファイルの保存場所を変更できる。
生成されたファイル
# Generated by CommandGenerator on 2021-06-23 20:55:00
from typing import Optional, Tuple
from line_bot_tool.base.commnad import BaseCommand
from . import settings
class HelpCommand(BaseCommand):
prefixes: Optional[Tuple[str, ...]] = settings.PREFIXES
cmd: str = 'help'
description: str = 'Please input here command description.'
同じ階層のディレクトリに settings.py が生成される。
# Generated by CommandGenerator on 2021-06-23 20:55:00
from typing import Optional, Tuple
PREFIXES: Optional[Tuple[str, ...]] = ('/', '@')
PREFIXES の値を書き換えることでコマンドの接頭辞を設定できる。
接頭辞が費用な場合は、None を入れる。
from commands.help_command import HelpCommand
HelpCommand.is_executable('/help') # True
HelpCommand.is_executable('@help') # True
HelpCommand.is_executable('help') # False
引数があるコマンドの場合
例えば、/name:引数 というコマンド(引数にユーザーIDを指定し、名前を返す)がある場合、以下のようにコマンドの生成、判定を行う。
また、接頭辞は / のみとする。
$ lb-tool gen:command name
Generate success! commands/name_command.py
commands/name_command.py を少し書き換え。
# Generated by CommandGenerator on 2021-06-23 21:34:39
from typing import Optional, Tuple
from line_bot_tool.base.commnad import BaseCommand
from . import settings
class NameCommand(BaseCommand):
- prefixes: Optional[Tuple[str, ...]] = settings.PREFIXES
- cmd: str = 'name'
+ prefixes: Optional[Tuple[str, ...]] = ('/')
+ cmd: str = 'name:'
description: str = 'Please input here command description.'
from commands.name_command import NameCommand
NameCommand.is_executable_with_arg('/name:UXXXXXXXXXX') # True, UXXXXXXXXXX
# セイウチ演算子を使って書く
if (result := NameCommand.is_executable_with_arg('/name:UXXXXXXXXXX'))[0]:
print(result[1]) # UXXXXXXXXXX
Metadata
Release files for line-bot-tool 1.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-bot-tool-1.0.tar.gz | 11.0 kB | Without provenance | Details for line-bot-tool-1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| line_bot_tool-1.0-py3-none-any.whl | Python 3 | none | any | Details for line_bot_tool-1.0-py3-none-any.whl |
Total release size: 25.5 kB
Release files / line-bot-tool-1.0.tar.gz
| Download URL | line-bot-tool-1.0.tar.gz |
|---|---|
| Size | 11.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f2d97e9ea1dda5f3a857d42c8772bfdeb206f3a6913454238a7526e08453b057
|
|
BLAKE2b-256 checksum How to use checksums |
29ec85380c8a2c217a7b960df8fc6b3accbfbe1c9fdbaae1adcc24082b484d43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.2
|
Release files / line_bot_tool-1.0-py3-none-any.whl
| Download URL | line_bot_tool-1.0-py3-none-any.whl |
|---|---|
| Size | 14.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ef85769c48aadeb38467b3fd0dfcba907d5b2e9eab2363c9514d9d736633b724
|
|
BLAKE2b-256 checksum How to use checksums |
15eb1cb6cc9ccaa1f3f0b497e434902e58108b4a01d4babb50eee4e543185d05
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.2
|
Security for line-bot-tool 1.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.