Skip to content

Commit 40fca4e

Browse files
committed
readme
1 parent 513c4ff commit 40fca4e

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
# piazza-bot
2-
Slack bot that expands piazza post numbers to include a link to the actual
1+
# PiazzaBot
2+
PiazzaBot is a simple slack bot that makes discussing posts on Piazza easier.
3+
When a post is mentioned by ID, PiazzaBot will respond with a link to that
34
post.
45

5-
## Dependencies
6-
Slack Bolt
7-
python dotenv
6+
## Installation
7+
[to do]
8+
9+
## Development
10+
PiazzaBot is built using [Slack's Bolt framework]{https://github.com/SlackAPI/bolt-python}.

app.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,22 @@
88

99
# Make the app
1010
load_dotenv()
11+
1112
app = App(token=os.environ.get("SLACK_BOT_TOKEN"))
12-
url = "https://piazza.com/class/%s/post/" % os.environ.get("COURSE_ID")
13+
14+
base_url = "https://piazza.com/class/%s" % os.environ.get("COURSE_ID")
15+
posts_url = f"{base_url}/post/"
1316

1417
# Listens to incoming messages that contain "hello"
15-
# To learn available listener arguments,
16-
# visit https://slack.dev/bolt-python/api-docs/slack_bolt/kwargs_injection/args.html
18+
# To learn available listener arguments, visit
19+
# https://slack.dev/bolt-python/api-docs/slack_bolt/kwargs_injection/args.html
1720
@app.message(re.compile("(@\d*)"))
18-
# @app.message(re.compile("(hi|hello|hey)"))
19-
def message_hello(say, context):
21+
def post_link(say, context):
2022
for match in context['matches']:
2123
number = match.replace('@','')
22-
post_url = url + number
24+
url = posts_url + number
2325
# say() sends a message to the channel where the event was triggered
24-
say(f"The number is {number}. the url is: {post_url}")
25-
26+
say(url)
2627

2728
# Run the app
2829
if __name__ == "__main__":

0 commit comments

Comments
 (0)