You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
!wolfram ask <question> (Ask wolfram alpha a question)
51
51
```
52
52
53
-
## Retrieving the API token
53
+
## Retrieving the API tokens
54
54
55
55
Bot applications are not allowed to access all api methods from Slack. Thus, if
56
56
you create a bot integration on slack, the bot won't be able to create new
57
-
channels for example. To get around this restriction, you have to create a real
58
-
slack user and generate an authentication token for it, which can then be used
59
-
instead of a bot token.
57
+
channels for example. To get around this restriction you must create a new
58
+
slack integration ("Slack App"), assign it to your workspace, enable the Socket
59
+
Mode event feed, generate an "App Level Token" (`xapp1`), assign scopes to your
60
+
bot user and subsequently create a "Bot User Token" (`xoxb`), and then finally
61
+
install it to your workspace.
60
62
61
-
1. Create a new user in slack (this will be the bot user, so give it an appropriate username)
62
-
2. Log into slack with this newly created user
63
-
3. Navigate to https://api.slack.com/custom-integrations/legacy-tokens
64
-
* The user should show up there together with your slack workspace
65
-
5. Press "Create token"
66
-
* This should create a token starting with "xoxp-"
67
-
7. Use this token as the `api_key` for the bot
68
-
8. Logout and login with your regular user again.
63
+
Once generated, the tokens must be scoped to the appropriate privilege levels
64
+
required for the bot to function. Finally, you must ensure that you have
65
+
subscribed the bot users to the list of events it will need to receive in order
66
+
to operate.
69
67
70
-
After restarting the bot, the bot user should now show up in your slack workspace.
68
+
1. First, navigate to `api.slack.com/apps` and create a new slack app. Give it
69
+
a name and select the workspace that it will serve, and then click create.
70
+
71
+
2. Enable socket mode by clicking on the menu of the same name and then
72
+
clicking on the toggle labelled "Enable Socket Mode". You'll be prompted to
73
+
create an App Level Token which you must do next.
74
+
75
+
3. App Level Token
76
+
77
+
This token is used by the bot to access the websocket event feed in version 3
78
+
of the Slack API. The toggle you enabled in the previous step, "Enable Socket
79
+
Mode", is what turns on the event feed. Assuming you've not already created an
80
+
App Level Token you'll now be prompted to do so. Place it into the config file
81
+
under the entry `app_key`.
82
+
83
+
4. Bot User Token
84
+
85
+
This token is used by the bot to interact with the workspace and users via
86
+
Slack's conversations API. In order to create this token you must first
87
+
navigate to the OAuth & Permissions section of the Slack API control panel.
88
+
89
+
Once there, take note of the greyed out "Install to Workspace" button. You need
90
+
to add scopes to the bot user's token before you can install the bot. Scroll
91
+
down to the bottom of this page and in the section labelled "Bot Token Scopes"
92
+
add the following scopes.
93
+
94
+
```
95
+
app_mentions:read
96
+
channels:history
97
+
channels:join
98
+
channels:manage
99
+
channels:read
100
+
chat:write
101
+
chat:write.customize
102
+
chat:write.public
103
+
dnd:read
104
+
groups:history
105
+
groups:read
106
+
groups:write
107
+
im:history
108
+
im:read
109
+
im:write
110
+
links:read
111
+
links:write
112
+
mpim:history
113
+
mpim:read
114
+
mpim:write
115
+
reactions:read
116
+
reactions:write
117
+
reminders:list
118
+
reminders:write
119
+
team:read
120
+
users:read
121
+
users:write
122
+
```
123
+
124
+
Next, return to the top of the page and install the bot user using the button
125
+
from before which should no longer be greyed out. Now copy the "Bot User OAuth
126
+
Access Token" (begins with `xoxb`) into the config file under the entry
127
+
`api_key`. The bot should show up inside the workspace now. You can change its
128
+
display name using the menu on the left labelled "Basic Information", if you
129
+
want.
130
+
131
+
5. Event subscription
132
+
133
+
NOTE: Make sure you toggle "Enable Socket" (step 2) before attempting this!
134
+
135
+
Once the tokens have been configured you will need to navigate to the Event
136
+
Subscriptions panel of the slack API control panel and register the bot to
137
+
receive the events it needs to operate.
138
+
139
+
First toggle the switch labelled "Enable Events", then use the picker to select
140
+
at least the events below. They are probably all that you will need, but it's
141
+
fine to select all of the event subscriptions here if you want to be on the simple side.
142
+
143
+
```
144
+
app_mention
145
+
app_mentions:read
146
+
channels:history
147
+
emoji_changed
148
+
emoji:read
149
+
groups:history
150
+
im:history
151
+
link_shared
152
+
links:read
153
+
message.channels
154
+
message.im
155
+
message.groups
156
+
message.mpim
157
+
mpim:history
158
+
reaction_added
159
+
reactions:read
160
+
reaction_removed
161
+
```
71
162
72
163
73
164
## Installation
74
165
75
-
1. Copy `config/config.json.template` to `config/config.json`
76
-
2. Fill the API token and bot name in the config.json file.
77
-
3. Add your user id (slack id, not the username) to `admin_users` group in `config/config.json`
166
+
1. Copy _config/config.json.template_ to _config/config.json_
167
+
2. Fill the APP and API token names in the _config.json_ file.
168
+
3. Add your user id (slack id, not the username) to `admin_users` group in _config/config.json_
78
169
4. If you want to use the wolfram alpha api, register a valid app id on http://products.wolframalpha.com/api/ and set `wolfram_app_id` in `config/config.json`
79
-
5. Copy `intro_msg.template` to `intro_msg` and set a proper introduction message, which can be shown with `!intro`
170
+
5. Copy _intro_msg.template_ to _intro_msg_ and set a proper introduction message, which can be shown with `!intro`
80
171
6.`docker build -t ota-challenge-bot .`
81
172
7.`docker run -it --rm --name live-ota-challenge-bot ota-challenge-bot`
82
173
83
174
84
175
## Development
85
176
86
-
1. Copy `config/config.json.template` to `config/config.json`
87
-
2. Fill the API token and bot name in the config.json file.
177
+
1. Copy _config/config.json.template_ to _config/config.json_
178
+
2. Fill the API token and bot name in the _config.json_ file.
88
179
3. Create a virtual env: `python3 -m venv .venv`
89
180
4. Enter the virtual env: `source .venv/bin/activate`
1. Copy `config/config_solvetracker.json.template` to `config/config_solvetracker.json`.
186
+
1. Copy _config/config_solvetracker.json.template_ to _config/config_solvetracker.json_.
96
187
2. Configure the git account, the local repo and the remote path, which should be used to access your git repository.
97
188
98
189
Example:
@@ -107,20 +198,20 @@ Example:
107
198
}
108
199
```
109
200
110
-
Alternatively, you may decide to omit the "git_repopass" entry. In such an event (or if the entry is left blank) then the handler will attempt to push to the configured "git_remoteuri" using the `git` protocol, including using any SSH identities you may have configured.
201
+
Alternatively, you may decide to omit the `git_repopass` entry. In such an event (or if the entry is left blank) then the handler will attempt to push to the configured "git_remoteuri" using the `git` protocol, including using any SSH identities you may have configured.
111
202
Note: If you configure the solvetracker this way, you need to make sure you are using an SSH identity without a passphrase.
112
203
113
204
3. Update the templates in `templates` according to your preferences (or go with the default ones).
114
-
4. Make sure that there's a `_posts` and `_stats` folder in your git repository.
205
+
4. Make sure that there's a __posts_ and __stats_ folder in your git repository.
115
206
5. You should be good to go now and git support should be active on the next startup. You can now use the `postsolves` command to push blog posts with the current solve status to git.
116
207
117
208
118
209
## Using Link saver
119
210
120
211
1. Setup a github repo with jekyll and staticman (e.g. https://github.com/ujjwal96/links).
121
-
2. Copy `config/config_savelink.json.template` to `config/config_savelink.json`.
212
+
2. Copy _config/config_savelink.json.template_ to _config/config_savelink.json_.
122
213
3. Configure the git repo and branch to be used.
123
-
4. Add the decrypted staticman-token used in `staticman.yml` in the config.
214
+
4. Add the decrypted staticman-token used in _staticman.yml_ in the config.
124
215
5. Add a link to your repo, so people can look it up via `showlinkurl`
125
216
126
217
Example:
@@ -136,7 +227,7 @@ Example:
136
227
137
228
## Archive reminder
138
229
139
-
To enable archive reminders set an offset (in hours) in `config/config.json` for `archive_ctf_reminder_offset`. Clear or remove the setting to disable reminder handling.
230
+
To enable archive reminders set an offset (in hours) in _config/config.json_ for `archive_ctf_reminder_offset`. Clear or remove the setting to disable reminder handling.
140
231
141
232
If active, the bot will create a reminder for every bot admin on `!endctf` to inform him, when the ctf was finished for the specified time and it should be archived.
142
233
@@ -150,7 +241,7 @@ Example (for being reminded one week after the ctf has finished):
150
241
151
242
## Log command deletion
152
243
153
-
To enable logging of deleting messages containing specific keywords, set `delete_watch_keywords` in `config/config.json` to a comma separated list of keywords.
244
+
To enable logging of deleting messages containing specific keywords, set `delete_watch_keywords` in _config/config.json_ to a comma separated list of keywords.
154
245
Clear or remove the setting to disable deletion logging.
0 commit comments