|
42 | 42 | storage_client = Client() # initialize the Google Storage client |
43 | 43 | bucket = storage_client.bucket(os.environ["USER_DATA_BUCKET_NAME"]) |
44 | 44 | slack_client_id = os.environ["SLACK_CLIENT_ID"] |
| 45 | +slash_command = os.environ.get("SLACK_SLASH_COMMAND", "/multireact") |
45 | 46 | # initialize the app with the OAuth configuration |
46 | 47 | app = AsyncApp( |
47 | 48 | signing_secret=os.environ["SLACK_SIGNING_SECRET"], |
|
69 | 70 |
|
70 | 71 |
|
71 | 72 | # https://api.slack.com/interactivity/slash-commands, https://slack.dev/bolt-python/concepts#commands |
72 | | -@app.command("/multireact") |
| 73 | +@app.command(slash_command) |
73 | 74 | async def save_or_display_reactions( |
74 | 75 | ack: AsyncAck, |
75 | 76 | client: AsyncWebClient, |
@@ -121,20 +122,20 @@ async def save_or_display_reactions( |
121 | 122 | reactions = " ".join(reactions) |
122 | 123 | blob.upload_from_string(reactions) |
123 | 124 | await respond("Great! Your new reactions are saved :sunglasses: " |
124 | | - "Type `/multireact` to see them at any time.") |
| 125 | + f"Type `{slash_command}` to see them at any time.") |
125 | 126 | logger.info("User %s saved %s", user_id, reactions) |
126 | 127 |
|
127 | 128 | else: # otherwise, report to user any reactions they have |
128 | 129 | if blob.exists(): # display any reactions the user has saved |
129 | 130 | reactions = blob.download_as_text(encoding="utf-8") |
130 | 131 | reactions = " ".join([f":{r}:" for r in reactions.split(" ")]) |
131 | 132 | await respond(f"Your current reactions are: {reactions}. " |
132 | | - "Type `/multireact <new list of emojis>` to change them.") |
| 133 | + f"Type `{slash_command} <new list of emojis>` to change them.") |
133 | 134 | logger.info("User %s loaded %s", user_id, reactions) |
134 | 135 |
|
135 | 136 | else: # or say that user doesn't have any |
136 | 137 | await respond("You do not have any reactions set :anguished:\n" |
137 | | - "Type `/multireact <list of emojis>` to set one.") |
| 138 | + f"Type `{slash_command} <list of emojis>` to set one.") |
138 | 139 | logger.info("User %s has no reactions", user_id) |
139 | 140 |
|
140 | 141 |
|
@@ -220,7 +221,7 @@ async def add_reactions( |
220 | 221 | "text": { |
221 | 222 | "type": "mrkdwn", |
222 | 223 | "text": ("You do not have any reactions set :anguished:\n" |
223 | | - "Type `/multireact <list of emojis>` in the chat to set one.") |
| 224 | + f"Type `{slash_command} <list of emojis>` in the chat to set one.") |
224 | 225 | } |
225 | 226 | } |
226 | 227 | ] |
@@ -266,9 +267,9 @@ async def update_home_tab( |
266 | 267 | user_id = event["user"] |
267 | 268 | # https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed#domain_name_is_included_in_the_request_data |
268 | 269 | if "host" in request.headers and len(request.headers["host"]) > 0: |
269 | | - view = build_home_tab_view(app_url=f"https://{request.headers['host'][0]}") |
| 270 | + view = build_home_tab_view(slash_command, app_url=f"https://{request.headers['host'][0]}") |
270 | 271 | else: |
271 | | - view = build_home_tab_view() |
| 272 | + view = build_home_tab_view(slash_command) |
272 | 273 |
|
273 | 274 | await client.views_publish( |
274 | 275 | user_id=user_id, # Use the user ID associated with the event |
|
0 commit comments