Skip to content

Added support for rtm.connect. Fixes #190#209

Merged
Roach merged 10 commits into
masterfrom
roach/rtm.connect
Aug 23, 2017
Merged

Added support for rtm.connect. Fixes #190#209
Roach merged 10 commits into
masterfrom
roach/rtm.connect

Conversation

@Roach

@Roach Roach commented Aug 17, 2017

Copy link
Copy Markdown
Contributor

Summary

Added support for rtm.connect. Fixes #190

With rtm.start:
Print channel count (should be 13)

>>> if sc.rtm_connect():
...     while True:
...         event = sc.rtm_read()
...         print(len(sc.server.channels))
...         time.sleep(1)
... else:
...     print("Connection Failed")
... 
13

With rtm.connect:
Print channel count (should be 0)

>>> if sc.rtm_connect(with_team_state=False):
...     while True:
...         event = sc.rtm_read()
...         # Print channel count (should be 0)
...         print(len(sc.server.channels))
...         time.sleep(1)
... else:
...     print("Connection Failed")
... 
0

Requirements (place an x in each [ ])

@Roach Roach left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accidentally left some lines commented out, fixing.

Comment thread docs-src/real_time_messaging.rst Outdated
rtm.start vs rtm.connect
---------------------------

If you expect your app to be used on large teams, we recommend using starting the RTM client with `rtm.connect` rather than `rtm.start`, which is the default connection method for this client.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recommedation: ... rather than the default connection method for this client, rtm.start.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when the code will be checked in?

@aoberoi aoberoi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly looks good... but the age-old question: tests? it doesn't look like we have a very deep coverage right now, but i think for new changes we should aim to improve that situation.

`rtm.connect` provides a lighter initial connection payload, without the team's channel and user information included. You'll need to request channel and user info via
the Web API separately.

To do this, simply pass `with_team_state=False` into the `rtm_connect` call, like so:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the word "this" is ambiguous and might refer to "requesting channel and user info via the Web API". maybe say "To get a lighter connection payload, ..."

time.sleep(1)
else:
print "Connection Failed, invalid token?"
print "Connection Failed"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uhh.. this directory is supposedly ignored, you're still committing files here? might want to git rm -rf docs/_sources to get the actual delete as part of the commit

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto for the docs/.doctrees directory. seems like something that should be ignored too.

Comment thread slackclient/client.py Outdated
:Args:
None
with_team_state (bool): Connect via `rtm.start` to pull workspace state information.
`false` connects via `rtm.connect, which is lighter weight and better for very large teams.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

capital F in False?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ending backtick after rtm.connect

Comment thread slackclient/client.py Outdated
self.server.rtm_connect(use_rtm_start=with_team_state)
return True
# except:
# return False

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just delete these lines?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They weren't supposed to stay commented out 😐

@aoberoi

aoberoi commented Aug 17, 2017

Copy link
Copy Markdown
Contributor

so for the lines you just uncommented, if we actually removed them, wouldn't that also solve #181? jeez we should really have some tests. 😢

@codecov

codecov Bot commented Aug 18, 2017

Copy link
Copy Markdown

Codecov Report

Merging #209 into master will decrease coverage by 0.07%.
The diff coverage is 41.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #209      +/-   ##
==========================================
- Coverage   61.84%   61.76%   -0.08%     
==========================================
  Files           9        9              
  Lines         304      306       +2     
  Branches       56       57       +1     
==========================================
+ Hits          188      189       +1     
- Misses        102      103       +1     
  Partials       14       14
Impacted Files Coverage Δ
slackclient/server.py 61.66% <40%> (-0.2%) ⬇️
slackclient/client.py 38.88% <50%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 24dec80...775b091. Read the comment docs.

@Roach

Roach commented Aug 18, 2017

Copy link
Copy Markdown
Contributor Author

@aoberoi it would, but if a dev is explicitly checking if rtm_connect is True as opposed to just seeing if it's truthy, it'd be a breaking change... 🤔

@aoberoi

aoberoi commented Aug 18, 2017

Copy link
Copy Markdown
Contributor

ah, thanks for pointing that out @Roach.

we spoke about it in person and realized we can still fix the issue regarding the visibility of thrown exceptions (by not catching them and returning False) while leaving the return type the same (so that successful connections still return True).

we should pop back into conversations where people wanted the entire rtm.start Web API payload and direction them to inside the rtm.server Python object.

@Roach

Roach commented Aug 23, 2017

Copy link
Copy Markdown
Contributor Author

Merging this with tests coming in a future release in order to resolve a customer issue.

@Roach Roach merged commit 6d2fa8c into master Aug 23, 2017
@rkbala

rkbala commented Aug 23, 2017

Copy link
Copy Markdown

I am getting the below error:

TypeError: rtm_connect() got an unexpected keyword argument 'with_team_state'

Roach added a commit that referenced this pull request Aug 23, 2017
@Roach Roach mentioned this pull request Aug 23, 2017
2 tasks
Roach added a commit that referenced this pull request Aug 23, 2017
* Reverting #209

* Rebuilt docs to remove 'rtm.connect' references
@Roach Roach added this to the 1.x milestone Dec 2, 2017
c-goosen pushed a commit to c-goosen/python-slackclient that referenced this pull request Jun 18, 2019
* Added rtm.connect support

* updated docs

* updated gitignore

* Uncommented lines which were accidentally left commented

* Updated docs

* Removed ignored doc source files

* Fixed typo in method docs

* fixed line length

* updated rim start tests

* regenerated docs
c-goosen pushed a commit to c-goosen/python-slackclient that referenced this pull request Jun 18, 2019
* Reverting slackapi#209

* Rebuilt docs to remove 'rtm.connect' references
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

Successfully merging this pull request may close these issues.

3 participants