diff --git a/README.md b/README.md index 445c822..0260b84 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ -# piazza-bot -Slack bot that expands piazza post numbers to include a link to the actual +# PiazzaBot +PiazzaBot is a simple slack bot that makes discussing posts on Piazza easier. +When a post is mentioned by ID, PiazzaBot will respond with a link to that post. -## Dependencies -Slack Bolt -python dotenv +## Installation +[to do] + +## Development +PiazzaBot is built using [Slack's Bolt framework]{https://github.com/SlackAPI/bolt-python}. diff --git a/app.py b/app.py index 09937ac..5b6cc3d 100644 --- a/app.py +++ b/app.py @@ -8,21 +8,22 @@ # Make the app load_dotenv() + app = App(token=os.environ.get("SLACK_BOT_TOKEN")) -url = "https://piazza.com/class/%s/post/" % os.environ.get("COURSE_ID") + +base_url = "https://piazza.com/class/%s" % os.environ.get("COURSE_ID") +posts_url = f"{base_url}/post/" # Listens to incoming messages that contain "hello" -# To learn available listener arguments, -# visit https://slack.dev/bolt-python/api-docs/slack_bolt/kwargs_injection/args.html +# To learn available listener arguments, visit +# https://slack.dev/bolt-python/api-docs/slack_bolt/kwargs_injection/args.html @app.message(re.compile("(@\d*)")) -# @app.message(re.compile("(hi|hello|hey)")) -def message_hello(say, context): +def post_link(say, context): for match in context['matches']: number = match.replace('@','') - post_url = url + number + url = posts_url + number # say() sends a message to the channel where the event was triggered - say(f"The number is {number}. the url is: {post_url}") - + say(url) # Run the app if __name__ == "__main__":