Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python About Slack's RTM API

Jing Zhang
PLUS
Jing Zhang
Courses Plus Student 6,465 Points

Video outdated? No rmpbot.py file.

There is no rmpbot.py in the project folder.

5 Answers

Dennis O'Keeffe
Dennis O'Keeffe
32,820 Points

ALRIGHT, so I just figured it out! I had the same problem when I started watching this too.

tl;dr

README.md vague.

From the root, change to the rtmbot folder they now have and then create the rtmbot.conf file and plugins folder from there. In the rtmbot file, it should look like this:

DEBUG: True # make this False in production
SLACK_TOKEN: "<your-slack-token--follow-the-vid-for-this>"
ACTIVE_PLUGINS:
    - plugins.motivation.motivation.MotivationPlugin

Where the plugins.motivation.motivation.MotivationPlugin is the relative path the file (last .MotivationPlugin being the class name within that file in my circumstance)

Run rtmbot from the rtmbot folder. Checkout Slack.

HOW DOES THIS WORK AS OF WED 10:49am NOV 16 2016 SYDNEY TIME ON PLANET EARTH?

They changed everything to run from the rtmbot file. Basically, after you've done the installation of everything that you need eg. the correct pip install <package> etc, then change into the rtmbot folder and run rtmbot to run the bot instead of the rtmbot.py file that they used to have.

This also means that you need to create the rtmbot.conf file and the plugins folder etc from that rtmbot directory.

The README.md wasn't very helpful, so I just had to plug away until I figured out the changes they made.

Basically, inside the rtmbot folder that they have, create your rtm.conf file to look like this:

DEBUG: True # make this False in production
SLACK_TOKEN: "<your-slack-token--follow-the-vid-for-this>"
ACTIVE_PLUGINS:
    - plugins.motivation.motivation.MotivationPlugin

Important! the .conf file looks as though it needs the ACTIVE_PLUGINS set up to point to the plugins you want to integrate. I'm only 30min into this, but for me, plugins only seem to work once you have wrote the path from the rtmbot directory - in the above example, the relative path to that plugin class being ./plugins/motivation/motivation.py and then within motivation.py have a class called MotivationPlugin.

My Plugin file looks like so:

// inside MotivationPlugin.py

from __future__ import print_function
from __future__ import unicode_literals

from rtmbot.core import Plugin

class MotivationPlugin(Plugin):

    def process_message(self, data):
        if data['text'].startswith("!d"):
            self.outputs.append(
                [data['channel'], 'pew pew pew!']
            )

I haven't gone through the API enough to debate whether or not you can write things in an easier way but you can copy that file above to test out that it works. I presume continuing on and following the plugin styles written in these tutorials will work after the initial set up.

Hope that helps at least one person save time! Tried to make it as thorough for the debugging of the set up as possible.

Like I said though, v important that you pip install all the requirements. You should be good if you follow the vid above - although I did also pip install things from the core.py file etc. I think... who knows. I pip install'd a lot.

I do remember needing to pip install virtualenv in some cases. Note that if you have certain versions/config for pip, you may need the pip install <package> --user flag on there (or pip3 install it - whatever).

Robert Hemfelt
Robert Hemfelt
7,303 Points

mine also has no rtmbot.py file

Well, the video is definally not outdated since it was released I think 2 weeks ago.

Peter Javorkai
Peter Javorkai
31,477 Points

Thanks for the explorations @Dennis O'Keeffe so at this point you don't need run anything after the first video, so basically you can't test that your bot is connected, just after writing some plugins, correct?