Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jacklowrie committed Oct 5, 2022
1 parent 513c4ff commit 40fca4e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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}.
17 changes: 9 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down

0 comments on commit 40fca4e

Please sign in to comment.