Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtm_send_message fails on newly opened IMs #73

Closed
elementc opened this issue Feb 26, 2016 · 3 comments
Closed

rtm_send_message fails on newly opened IMs #73

elementc opened this issue Feb 26, 2016 · 3 comments

Comments

@elementc
Copy link
Contributor

Replication:

  1. Generate a new bot api key.
  2. Run the following script:
from slackclient import SlackClient

def search(dict_list, key, value):
    for item in dict_list:
        if item[key] == value:
            return item

SLACK_DEBUG_KEY = "YOUR-BRAND-NEW-SLACK-DEBUG-KEY-HERE"
sc = SlackClient(SLACK_DEBUG_KEY)
sc.rtm_connect()
users = sc.api_call('users.list')['members']
user = search(users, 'name', 'your-slack-username-here')
dm = sc.api_call('im.open', user=user['id'])['channel']['id']
sc.rtm_send_message(dm, 'this should be a message you receive')

Expected:

A message from the bot whose key you used on the first time.

Actual:

This error the first time:

Traceback:
  File "~/pycharmprojects/python-slackclient/slackclient/_client.py", line 40, in rtm_send_message
    return self.server.channels.find(channel).send_message(message)
AttributeError: 'NoneType' object has no attribute 'send_message'

Works as expected the second time.

Notes:

rtm_send_message depends on the cached set of channels. Fix will be in rtm_send_message definition, probably by inserting or creating a channel object if not there. But it's four in the morning here and I'm gonna get some sleep first.

@elementc
Copy link
Contributor Author

I've posted #74, which fixes both this and #47. Could someone from Slack ( @l12s ?) take a look at this? I know I've posted a lot of PRs this weekend, but #74 is an important one.

@ghost
Copy link

ghost commented Feb 28, 2016

Looking now.

@elementc
Copy link
Contributor Author

Thanks for the merge! Have fun with 1.0.0

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

No branches or pull requests

1 participant