Skip to content
This repository has been archived by the owner on Jul 3, 2020. It is now read-only.

get_channel_id function added #12

Merged
merged 2 commits into from Dec 7, 2014
Merged

get_channel_id function added #12

merged 2 commits into from Dec 7, 2014

Conversation

juanpabloaj
Copy link
Collaborator

  • get_channel_id function return the channel id from channel name.
  • mocking test added.
  • requeriments-dev.txt file added.

Some slack API methods need the channel id, not the channel name, like files.upload.

Channel id ('C02GXXYZ') is different to the channel name ('test').

Example:

>>> from slacker import Slacker
>>> from slacker.utils import get_channel_id
>>> token = "aaa"
>>> channel_id = get_channel_id(token, 'test')
>>> slack = Slacker(token)
>>> slack.files.upload('index.png', channels=channel_id)

* get_channel_id function return the channel id from channel name.
@juanpabloaj
Copy link
Collaborator Author

for run tests

python setup.py test

or with nosetest

nosetest

@juanpabloaj
Copy link
Collaborator Author

other option is add the function like a method in Channels class.

@os
Copy link
Owner

os commented Nov 15, 2014

Thanks for this, @juanpabloaj. When I was implementing slacker, I just wanted to make it as close as possible to the original API, so it's passing exactly the same parameters, with the same order.

Unfortunately, Slack API is not very consistent with the use of channel name/ID. When some APIs are passing channel name as a channel parameter, the others are passing channel ID.

A function like this could be useful, but I would go with the second option, get_channel_id method on Channels class. If you could make those changes, I would be happy to merge it into master.

* the tests make mocking over requests library.
@juanpabloaj
Copy link
Collaborator Author

@os ok, now get_channel_id is a method of channels class.

os added a commit that referenced this pull request Dec 7, 2014
get_channel_id function added
@os os merged commit 1ff48ad into os:master Dec 7, 2014
@os
Copy link
Owner

os commented Dec 7, 2014

Thanks @juanpabloaj. tests/init.py was missing, but I just fixed it so it's all good.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants