Skip to content

Commit

Permalink
files.upload : 内部でfiles_upload_v2を使うようにしました。 (#138)
Browse files Browse the repository at this point in the history
* "--channel_id"に変更

* 月ごとに更新

* 修正
  • Loading branch information
yuji38kwmt authored May 13, 2024
1 parent cf355b9 commit 91ee797
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: weekly
interval: monthly
open-pull-requests-limit: 10
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,6 @@ venv.bak/
# output directory of tests
tests/out/

pip-wheel-metadata/
pip-wheel-metadata/

out/
8 changes: 4 additions & 4 deletions slack_primitive_cli/command/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@click.command(name="files.upload", help="Uploads or creates a file. See https://api.slack.com/methods/files.upload ")
@click.option("--token", envvar=TOKEN_ENVVAR, required=True, help=TOKEN_HELP_MESSAGE)
@click.option("--channels", required=True, help="Comma-separated list of channel names or IDs where the file will be shared.")
@click.option("--channel_id", required=True, help="Channel IDs where the file will be shared.")
@optgroup.group("File contents", cls=RequiredMutuallyExclusiveOptionGroup)
@optgroup.option("--file", help="File contents via multipart/form-data. If omitting this parameter, you must submit content.")
@optgroup.option("--content", help="File contents via a POST variable. If omitting this parameter, you must provide a file.")
Expand All @@ -22,15 +22,15 @@
@click.option("--thread_ts", help="Provide another message's ts value to upload this file as a reply.")
@click.option("--title", help="Title of file.")
@my_backoff
def upload(token, channels, file, content, filename, filetype, initial_comment, thread_ts, title): # noqa: ANN001, ANN201
def upload(token, channel_id, file, content, filename, filetype, initial_comment, thread_ts, title): # noqa: ANN001, ANN201
set_logger()
client = slack_sdk.WebClient(token=token)

if filename is None and file is not None:
filename = os.path.basename(file)

response = client.files_upload(
channels=channels,
response = client.files_upload_v2(
channel=channel_id,
file=file,
content=content,
filename=filename,
Expand Down

0 comments on commit 91ee797

Please sign in to comment.