slack-cli icon indicating copy to clipboard operation
slack-cli copied to clipboard

channels.list deprecated

Open pwoolvett opened this issue 5 years ago • 4 comments

Today slack-cli stopped working

https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api

We'll stop allowing newly created Slack apps to use these deprecated APIs beginning June 10th, 2020.

:(

related: https://github.com/os/slacker/issues/116

temporary workaround (I dunno about side effects, Im only using it to PM me):

  1. upgrade slacker: pip install --upgrade slacker
  2. change the channel fetcher in slackcli.messaging:iter_resources to lambda: slack.client().conversations.list().body["channels"]
  3. comment out the group fetcher

EDIT: This no longer works as pkg_resources avoids newer slacker versions, as reported by @william-dowling

pwoolvett avatar Jun 10 '20 19:06 pwoolvett

It stopped for me too:

Traceback (most recent call last):
  File "/usr/local/bin/slack-cli", line 11, in <module>
    load_entry_point('slack-cli==2.2.9', 'console_scripts', 'slack-cli')()
  File "/usr/local/lib/python3.7/dist-packages/slackcli/cli.py", line 27, in main
    sys.exit(run())
  File "/usr/local/lib/python3.7/dist-packages/slackcli/cli.py", line 140, in run
    send_message(args.dst, message, pre=args.pre, username=args.user)
  File "/usr/local/lib/python3.7/dist-packages/slackcli/cli.py", line 187, in send_message
    destination_id = messaging.get_destination_id(destination)
  File "/usr/local/lib/python3.7/dist-packages/slackcli/messaging.py", line 13, in get_destination_id
    return get_resource(name)[1]["id"]
  File "/usr/local/lib/python3.7/dist-packages/slackcli/messaging.py", line 17, in get_resource
    for resource_type, resource in iter_resources():
  File "/usr/local/lib/python3.7/dist-packages/slackcli/messaging.py", line 36, in iter_resources
    for resource in fetcher():
  File "/usr/local/lib/python3.7/dist-packages/slackcli/messaging.py", line 31, in <lambda>
    ("channel", lambda: slack.client().channels.list().body["channels"]),
  File "/usr/local/lib/python3.7/dist-packages/slacker/__init__.py", line 297, in list
    'exclude_members': exclude_members})
  File "/usr/local/lib/python3.7/dist-packages/slacker/__init__.py", line 117, in get
    api, **kwargs
  File "/usr/local/lib/python3.7/dist-packages/slacker/__init__.py", line 99, in _request
    raise Error(response.error)
slacker.Error: method_deprecated

jeremycurny avatar Jul 18 '20 18:07 jeremycurny

Trying @pwoolvett solution today (17 Sept 2020) gets this for me:

  File "/Users/dowlingw/venv/slack-cli/bin/slack-cli", line 11, in <module>
    load_entry_point('slack-cli==2.2.9', 'console_scripts', 'slack-cli')()
  File "/Users/dowlingw/venv/slack-cli/lib/python3.7/site-packages/slackcli/cli.py", line 27, in main
    sys.exit(run())
  File "/Users/dowlingw/venv/slack-cli/lib/python3.7/site-packages/slackcli/cli.py", line 140, in run
    send_message(args.dst, message, pre=args.pre, username=args.user)
  File "/Users/dowlingw/venv/slack-cli/lib/python3.7/site-packages/slackcli/cli.py", line 187, in send_message
    destination_id = messaging.get_destination_id(destination)
  File "/Users/dowlingw/venv/slack-cli/lib/python3.7/site-packages/slackcli/messaging.py", line 13, in get_destination_id
    return get_resource(name)[1]["id"]
  File "/Users/dowlingw/venv/slack-cli/lib/python3.7/site-packages/slackcli/messaging.py", line 17, in get_resource
    for resource_type, resource in iter_resources():
  File "/Users/dowlingw/venv/slack-cli/lib/python3.7/site-packages/slackcli/messaging.py", line 37, in iter_resources
    for resource in fetcher():
  File "/Users/dowlingw/venv/slack-cli/lib/python3.7/site-packages/slackcli/messaging.py", line 32, in <lambda>
    ("channel", lambda: slack.client().conversations.list().body["channels"]),
AttributeError: 'Slacker' object has no attribute 'conversations'

william-dowling avatar Sep 17 '20 14:09 william-dowling

Trying again, this time remembering to run pip install --upgrade slacker

$ pip install slack-cli
Collecting slack-cli
[...]
Using legacy 'setup.py install' for slack-cli, since package 'wheel' is not installed.
Installing collected packages: slacker, slack-cli
    Running setup.py install for slack-cli ... done
Successfully installed slack-cli-2.2.9 slacker-0.11.0

$ pip install --upgrade slacker
Collecting slacker
[...]
Using legacy 'setup.py install' for slacker, since package 'wheel' is not installed.
Installing collected packages: slacker
  Attempting uninstall: slacker
    Found existing installation: slacker 0.11.0
    Uninstalling slacker-0.11.0:
      Successfully uninstalled slacker-0.11.0
    Running setup.py install for slacker ... done
ERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts.

We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default.

slack-cli 2.2.9 requires slacker<0.12.0, but you'll have slacker 0.14.0 which is incompatible.
Successfully installed slacker-0.14.0

$ slack-cli -t xoxp-..... -T elscs  -d 'wdowling' "Testing CLI'" 
Traceback (most recent call last):
  File "/Users/dowlingw/venv/slack-cli/lib/python3.7/site-packages/pkg_resources/__init__.py", line 583, in _build_master
    ws.require(__requires__)
  File "/Users/dowlingw/venv/slack-cli/lib/python3.7/site-packages/pkg_resources/__init__.py", line 900, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/Users/dowlingw/venv/slack-cli/lib/python3.7/site-packages/pkg_resources/__init__.py", line 791, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (slacker 0.14.0 (/Users/dowlingw/venv/slack-cli/lib/python3.7/site-packages), Requirement.parse('slacker<0.12.0'), {'slack-cli'})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dowlingw/venv/slack-cli/bin/slack-cli", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/Users/dowlingw/venv/slack-cli/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3250, in <module>
    @_call_aside
  File "/Users/dowlingw/venv/slack-cli/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3234, in _call_aside
    f(*args, **kwargs)
  File "/Users/dowlingw/venv/slack-cli/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3263, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/Users/dowlingw/venv/slack-cli/lib/python3.7/site-packages/pkg_resources/__init__.py", line 585, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/Users/dowlingw/venv/slack-cli/lib/python3.7/site-packages/pkg_resources/__init__.py", line 598, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/Users/dowlingw/venv/slack-cli/lib/python3.7/site-packages/pkg_resources/__init__.py", line 786, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'slacker<0.12.0' distribution was not found and is required by slack-cli

william-dowling avatar Sep 18 '20 13:09 william-dowling

I use slack cli for deleting bot created channels like this: https://blog.rmotr.com/how-to-delete-multiple-slack-channels-at-once-7ba00f4890cd

and replacing line 80 of api.py with resp = self.__request('conversations.list', **kwargs)

got me taken care of

jbelf avatar Mar 04 '21 06:03 jbelf