-
Notifications
You must be signed in to change notification settings - Fork 4
refs #56 slackbot バージョンアップ #200
Changes from all commits
bfedad1
b89ab4a
b64e227
089b782
4104416
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,16 +6,16 @@ geopy==1.11.0 | |
idna==2.6 | ||
kml2geojson==4.0.2 | ||
Mako==1.0.7 | ||
MarkupSafe==1.0 | ||
MarkupSafe==1.1.1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [変更] CI で、pallets/markupsafe#116 と同事象が発生したため、バージョンアップしました。 (最新の 1.1.1であれば発生しない)
|
||
Pillow==5.2.0 | ||
prettytable==0.7.2 | ||
PyMySQL==0.7.11 | ||
python-dateutil==2.6.1 | ||
python-editor==1.0.3 | ||
requests==2.18.4 | ||
six==1.11.0 | ||
slackbot==0.5.1 | ||
slacker==0.9.60 | ||
slackbot==1.0.0 | ||
slacker==0.14.0 | ||
Comment on lines
+17
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [変更] 廃止予定のAPI [参考] https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api |
||
SQLAlchemy==1.2.2 | ||
urllib3==1.22 | ||
websocket-client==0.44.0 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import logging | ||
import random | ||
|
||
from slackbot.bot import respond_to | ||
|
@@ -13,14 +14,16 @@ | |
- `$random help`: randomコマンドの使い方を返す | ||
''' | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@respond_to('^random$') | ||
@respond_to('^random\s+(active|help)$') | ||
def random_command(message, subcommand=None): | ||
""" | ||
チャンネルにいるメンバーからランダムに一人を選んで返す | ||
- https://github.com/os/slacker | ||
- https://api.slack.com/methods/channels.info | ||
- https://api.slack.com/methods/conversations.members | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [変更]
[参考] |
||
- https://api.slack.com/methods/users.getPresence | ||
- https://api.slack.com/methods/users.info | ||
""" | ||
|
@@ -33,16 +36,11 @@ def random_command(message, subcommand=None): | |
channel = message.body['channel'] | ||
webapi = slacker.Slacker(settings.API_TOKEN) | ||
try: | ||
cinfo = webapi.channels.info(channel) | ||
members = cinfo.body['channel']['members'] | ||
cinfo = webapi.conversations.members(channel) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
[参考] |
||
members = cinfo.body['members'] | ||
except slacker.Error: | ||
try: | ||
cinfo = webapi.groups.info(channel) | ||
members = cinfo.body['group']['members'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
except slacker.Error: | ||
# TODO: 例外で判定しないように修正する | ||
# チャンネルに紐付かない場合はreturn | ||
return | ||
logger.exception('An error occurred while fetching members: channel=%s', channel) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. エラー発生時は、ログを出力するようにしました。 |
||
return | ||
|
||
# bot の id は除く | ||
bot_id = message._client.login_data['self']['id'] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[typo]
typo 修正