ISSHA-1329 チャンネルにいる参加者の一覧を返すコマンドを追加#35
Closed
koedoyoshida wants to merge 5 commits intomasterfrom
Closed
Conversation
add all bot help option mention name from real_name or display_name
takanory
requested changes
Feb 2, 2019
|
|
||
| # メンバ一覧から順次処理 | ||
| for member_id in members: | ||
| user_info = webapi.users.info(member_id) |
Member
There was a problem hiding this comment.
重要: この書き方だとmemberの数だけAPIを叩いてしまうので、ちょっと迷惑かなと
users.list APIを1回だけ呼び出して全ユーザー情報を取得し、その情報を使うのがよいかと
| members = cinfo.body['channel']['members'] | ||
|
|
||
| # 作業用リスト初期化 | ||
| nameall = [] |
Member
There was a problem hiding this comment.
nits: 変数名がちょっとアレかなと... member_list とかでいいのでは
| if display_name != "": | ||
| basename = display_name | ||
|
|
||
| if subcommand == 'all': |
Member
There was a problem hiding this comment.
重要: 対象外だったらcontinueして、そうじゃなかったら最後に append するとコードが読みやすい
if subcommand == 'bot' and botじゃないユーザー:
conitnue
if subcommand is None and botユーザー:
continue
nameall.append(basename)
| display_name = user_info.body['user']['profile']['display_name'] | ||
|
|
||
| # display_nameが設定されていればそれが優先されている推測 | ||
| if display_name != "": |
Member
There was a problem hiding this comment.
nits: 以下でよい。空文字列でなければ true になる
if display_name:
basename = display_name
| nameall.sort(key=str.lower) | ||
|
|
||
| # 処理概要、一覧、Countを出力 | ||
| botsend(message, 'このチャンネルの{0}参加者一覧は\n{1}\n{2}参加者です。'.format( |
Member
There was a problem hiding this comment.
nits: メッセージとしては先に人数があった方が見やすいのでは。
あと、人数が多いと表示でメッセージが流れちゃうので、attachements使って折り畳まれて表示されるようにしたほうが良いかと。
https://api.slack.com/docs/message-attachments
このチャンネルの{}参加者はX名です。
takanory
hogehoge
Contributor
Author
|
#48 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
チケット
レビューしてほしいところ