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

Star_added event does not work. #98

Closed
takwas opened this issue May 25, 2016 · 2 comments
Closed

Star_added event does not work. #98

takwas opened this issue May 25, 2016 · 2 comments
Assignees

Comments

@takwas
Copy link

takwas commented May 25, 2016

I tried listening for star_added events, but when I star a message within Slack, the intended debug message doesn't get printed out.

from slackclient import SlackClient

class LikeBot(SlackClient):

    # Create bot instance
    def __init__(self, token):
        SlackClient.__init__(self, token)
        self.connect_rtm()
        self.server.join_channel('#bot-test')


    # Connect to Slack's RTM API
    def connect_rtm(self):
        print 'Likebot connecting to RTM API...' #DEBUG
        if self.rtm_connect():
            print 'Likebot connected!' #DEBUG
        else:
            print 'Likebot failed to connect!' #DEBUG


    # Begin listening for JSON formatted RTM API messages/events
    def listen(self):
        print 'Likebot Listening...' #DEBUG
        while True:
            for event in self.rtm_read():
                # do something with RTM API event
                print event # DEBUG; Fails to print a `star_added` event
                if event.get('type') == 'star_added':
                    print True


if __name__ == '__main__':
    bot = LikeBot('foo_token')
    bot.listen()
@Roach
Copy link
Contributor

Roach commented Dec 16, 2016

In order to receive star_added events, you'd need to connect with a token that has client scope, and you'd only be able to receive star actions for the user that token is associated with.

[{u'event_ts': u'1481855082.395964', u'item': {u'message': {u'permalink': u'...', u'text': u'ahoy', u'ts': u'1481855074.000005', u'user': u'U2X9HJWG6', u'is_starred': True, u'type': u'message'}, u'type': u'message', u'channel': u'...'}, u'type': u'star_added', u'user': u'...'}]

You may want to consider using the Events API, instead, as you'll have more granular control over what events you receive and the authenticating user will have a better idea what your app has access to.. You can see an example Flask app that @karishay put together here: https://github.com/slackapi/Slack-Python-Onboarding-Tutorial

@Roach Roach closed this as completed Dec 16, 2016
@Roach Roach added the question label Dec 16, 2016
@Roach Roach self-assigned this Dec 16, 2016
@takwas
Copy link
Author

takwas commented Jul 23, 2017

Thanks @Roach. Just seeing this.

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

2 participants