Skip to content

Commit 3a3a01f

Browse files
authored
Develop (#27)
* add app registration manifest and piazza icon * install instructions * readme formatting and clarity * add missing install instructions * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * temp contributing.md * update contributing and add venv to gitignore * bugfix: threaded message replies * install script * update readme * update readme * remove git conflict * update instructions to include install script * Feature reply in thread (#16) * Update issue templates * Delete CONTRIBUTING.md moving to .github * Revert "Update issue templates" This reverts commit 43cd34f. * Revert "Delete CONTRIBUTING.md" This reverts commit 25384ed. * Update issue templates * Create pull_request_template.md * Create pull_request_template.md * Update README.md * Update README.md * Update issue templates * Update feature_request.md * broadcast replies to unthreaded messages * delte test file * Feature update course (#21) * Develop (#19) * add app registration manifest and piazza icon * install instructions * readme formatting and clarity * add missing install instructions * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * temp contributing.md * update contributing and add venv to gitignore * bugfix: threaded message replies * install script * update readme * update readme * remove git conflict * update instructions to include install script * Feature reply in thread (#16) * Update issue templates * Delete CONTRIBUTING.md moving to .github * Revert "Update issue templates" This reverts commit 43cd34f. * Revert "Delete CONTRIBUTING.md" This reverts commit 25384ed. * Update issue templates * Create pull_request_template.md * Create pull_request_template.md * Update README.md * Update README.md * Update issue templates * Update feature_request.md * broadcast replies to unthreaded messages * delte test file * install tinydb and add slash command to upsert forum ids * remove course id from example .eng * store forum id in tinydb * move error message construction * formatting * formatting * update readme * add cache, rename Course -> Q (for query), move post_url building to message (#22) * fix regex
1 parent 4b53bd0 commit 3a3a01f

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,51 @@ post.
88
**\*Note**: I am not affiliated with or endorsed by Piazza or Slack in any way. Neither
99
is this bot.
1010

11+
<<<<<<< HEAD
12+
## Installation (adding to your workspace, and updates)
13+
This app isn't registered through the slack app directory. For now, it's meant
14+
to be used by one workspace per install/instance. To add to your workspace,
15+
we need to do two things:
16+
1. Register a new app in your workspace, and add the appropriate permissions.
17+
2. Set the app up on your host.
18+
3. Once PiazzaBot is up and running, add it to any channel you want to use in.
19+
20+
### Register the app (3-5 min)
21+
1. _[Register a new app](https://api.slack.com/apps?new_app=1) for your
22+
workspace._ Open that link (in a new window/tab). Choose to register the app
23+
from manifest, then copy & paste everything from the `slack-manifest.json`
24+
file in this repo into the window (make sure it's the `json` window and not
25+
the `yaml` window). Click through and confirm the app. This should take you
26+
to the "basic information" settings page.
27+
2. _Install to workspace._ Click the install to workspace button.
28+
3. _Add the piazza icon._ From the "basic information" page, at the bottom
29+
under "display information", upload the icon from this repo as the app icon.
30+
4. _Generate and save App-Level Token._ Under "App Level Tokens", generate a
31+
token with read/write authorizations. Note the token, as we'll need it to set
32+
the app up on your host.
33+
5. _save bot token._ Finally, note the bot token. In the left-side nav, click
34+
into "Features"->"Oauth & Permissions", and note the Bot User OAuth Token.
35+
36+
### Host the app (3-5 min)
37+
38+
1. _Clone this repo._ This is the easiest way to handle updates, since you
39+
can just pull from `main` and restart the app whenever there's an update.
40+
Alternatively, if you need to modify the app for your workspace, fork instead.
41+
2. _Install dependencies._ Set up a virtual environment, and install the
42+
required modules from `requirements.txt`. There's an install script `install.sh`
43+
which contains the commands you'll need to run. Either run each command
44+
individually, or try running the script **make sure python3 is installed on
45+
your system before running**.
46+
3. _Add tokens._ create a `.env` file from `.env-sample` and add the
47+
corresponding tokens you noted when registering the app.
48+
4. _Add Course ID._ Go to your course's dashboard (if you're viewing a question,
49+
click the logo). add the long alphanumeric string to your `.env` as the `COURSE_ID`.
50+
5. create new directory `data/` and a blank file `db.json` inside of it.
51+
6. _Run the app._ Run the app! `python app.py`
52+
=======
1153
## Installation
1254
PiazzaBot now supports multiple workspaces, so installation is very straightforward. Just click the button above.
55+
>>>>>>> main
1356
1457
## Contributing
1558
Still thinking about the ideal workflow, however I'd like to keep PM on

app.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import os
2+
23
from signal import signal, SIGINT
34
from sys import exit
45

56
from slack_bolt import App
7+
68
from slack_bolt.oauth.oauth_settings import OAuthSettings
79
from slack_sdk.oauth.installation_store.sqlalchemy import SQLAlchemyInstallationStore
810
from slack_sdk.oauth.state_store.sqlalchemy import SQLAlchemyOAuthStateStore
@@ -15,7 +17,9 @@
1517
from sqlalchemy import select
1618
from urllib import parse
1719

20+
1821
import re
22+
from tinydb import TinyDB, Query
1923

2024
import logging
2125
logger = logging.getLogger(__name__)
@@ -126,13 +130,13 @@ def update_forum_id(ack, respond, command, context):
126130

127131
# Listens for any message with a piazza tag in it. Piazza tags take the form
128132
# "@123", where the number is the id of a post on Piazza.
129-
#
130133
# https://regex101.com/r/eMmguY/1
131-
@app.message(re.compile(r"@(\d+\b)"))
134+
@app.message(re.compile(r"@(\d+[,|\ |\n|.|?|\r])"))
132135
def post_link(say, context, event, client):
133136
global cache
134137
forum_id = cache.get(context["team_id"], None)
135138

139+
136140
if forum_id is None:
137141
client.chat_postEphemeral(
138142
text=error,

0 commit comments

Comments
 (0)