CS159 Lab 01

Due 10:00pm Wednesday January 29, 2020

Starter Code

Get the starter code on GitHub Classroom

Docker

There’s a docker image available for this course. See the course docker instructions for details about how to work on your own machine.


RegEx Practice

Practice regular expressions by playing RegEx Golf.

You must complete the following:

Turn In

In the file golf.py, fill in your best regular expression for each of the puzzles that you solved. (autograded, 14 points)

Integrity Note

Since these puzzles are online, there are (undoubtedly) solutions posted somewhere. I trust you not to look for those solutions, but to submit the best solutions you can come up with on your own.


SlackBot

We’ll use Slack for communicating with each other this semester. There are already channels set up on our Slack Workspace for each of the assignments, and you should feel free to create your own channels for communicating with your teammates.

Stop now and make sure that you have access to the CS159 Slack Workspace.

For this part of lab, you will make an ELIZA-like chatbot that can join our slack workspace. You will follow these steps:

  1. Follow the instructions on this page to create a Slack App in the CS159 Workspace. You can name your bot whatever you like. Stop when you get to the page with your Bot User OAuth Access Token.

  2. Create a Slack App in the CS159 Workspace:
    • Go to https://api.slack.com/apps?new_classic_app=1 and create an app. You can name it anything you want.
    • Go to the “App Home” tab and follow the “Add A Legacy Bot User” link. Set up your Bot, choosing any name you would like for it.
    • Click “OAuth & Permissions” and “Install to Workspace.”
    • Copy the Bot User OAuth Access Token.
  3. Open the file slackbot.py and paste in your access token.

  4. Start your bot by running python3 slackbot.py. To see the bot in the Slack app, search for its name (on a mac, command+K opens the search bar). Send a message to your bot in slack, and confirm that it replies.

Once you have those steps working, you’re ready to improve upon your bot.

The only requirement I have is that you must modify the make_message function in slackbot.py to respond to messages from slack users. Your function must make use of regular expressions using the python re library. In particular, you should use each of the following at least once (autograded, 2 points):

You can choose the domain and personality of your both. It can be a Rogerian psychologist like ELIZA, or you can choose a different domain. If you choose a different domain, make sure it’s one where you can reasonably use a lot of repitition from regular expressions.

You should also update the name and emoji image of your chat bot. In Slack, if you click the icon to add an emoji to a message and then hover over the different emoji choices, it will tell you want the text alias for each emoji is. My demo bot uses the :dog: emoji.

Turn In

On Gradescope, you should submit your completed slackbot.py file with your implementation.

You should also submit a .pdf report that describes your Bot. That report should have the following sections:

The starter code has a Markdown file that you can use to write your analysis. To turn your markdown into a .pdf file, use pandoc:

pandoc analysis.md -o analysis.pdf

Please add your analysis.pdf file to your GitHub repository so that we can view it for grading.