Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

post_command実行時にchannel idやuser idを引数で指定するようにする #271

Merged
merged 4 commits into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@
- 鳩botに対しコマンドを実行したい時は `post_command.py` を使うと便利です。

```sh
pipenv run python post_command.py "{hato-botのコマンド}"
pipenv run python post_command.py --channel {投稿先のチャンネルのchannel id} \
--user {自分のuser_id} \
"{hato-botのコマンド}"
```

- または[ngrok](https://ngrok.com/)を使うこともできます。
Expand Down
6 changes: 4 additions & 2 deletions post_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ def main():
"""メイン関数"""

parser = argparse.ArgumentParser()
parser.add_argument('message', type=str)
parser.add_argument('message', type=str, help='投稿するメッセージ')
parser.add_argument('--channel', type=str, help='投稿先のチャンネルのchannel id')
parser.add_argument('--user', type=str, help='メッセージを送ったユーザーのuser id')
args = parser.parse_args()
requests.post('http://localhost:3000/',
json={'message': args.message, 'channel': 'C0123A4B5C6', 'user': 'U012A34BCDE'})
json={'message': args.message, 'channel': args.channel, 'user': args.user})


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def http_app():

or

pipenv run python post_command.py "鳩"
pipenv run python post_command.py --channel C0123A4B5C6 --user U012A34BCDE "鳩"
"""
msg = request.json['message']
channel = request.json['channel']
Expand Down