A discord bot to help teaching assistants keep track of students who need help.
This bot manages a queue of students who request help from teaching assistants.
We are hosting bot instances for courses on the UiS autograder (https://uis.itest.run/app/home). Please contact [email protected] if you want to use this bot for your course.
-
Students can request help using "!gethelp" or request approval of an assignment using "!approve"
-
Students can cancel their request using "!cancel"
-
Students receive a message when a teaching assistant is ready to help.
-
Teaching assistants can get the next help request using "!next"
- If the queue is empty, the teaching assistant will receive a notification when the next student requests help.
-
Teaching assistants can view the queue.
-
Teaching assistants can clear the queue.
All roles:
- help - displays help text and a list of commands
No role:
- register - assigns the user a nickname and student role based on info from GitHub/Autograder
Student role:
- gethelp - assigns a teaching assistant to help the student, if available. Otherwise the student is put at the back of the queue.
- approve - same as gethelp, but meant to be used for assignment approvals.
- status - shows the student's current position in the queue
- cancel - cancels the help request (student is removed from the queue)
Teaching assistant role:
- next - the teaching assistant is assigned the next student in the queue. If empty, the teaching assistant will be "waiting", and will be assigned the next student who needs help.
- cancel - the teaching assistant can remove their "waiting" status.
- length - Returns the number of students waiting in the queue.
- list (n=10) - Returns the "n" next students in the queue.
- clear - removes all students from the queue.
- unregister (@mention student) - unregisters the mentioned student.
- Registration is halfway implemented:
- Currently, new users can become "registered" by using the command "!register" and typing their GitHub username. The bot will then check if that GitHub username has access to the course's GitHub organization. If enabled, the bot will also get the student's real name from autograder.
- In the future, this should be properly authenticated using Oauth either using the GitHub API, or by using Discord connections.
- When the bot has confirmed that the user has access to GitHub/autograder, the bot will automatically assign a nickname and roles.
Your discord server needs to provide two different roles: one for students, and one for teaching assistants. You should also ensure that the bot has read access to all of the text channels that it needs to be able to monitor. The bot can, however, operate entirely through direct messages (DMs), and this is the intended way for the bot to be used.
The bot needs to have the Manage Nicknames
and Manage Roles
permissions in order to support automatic registration.
Note: If your bot has a specific role in your server, you need to ensure that the bot role is above the students role, otherwise, the bot will not be able to manage roles and nicknames of students, and you will get permission errors. You can read more about the Role Hierarchies in the discord documentation.
Go to the Discord Developer Portal and create a new application. Next, click on the "bot" page and add a bot user. Here you can set the bot username and icon. You will also find the bot token, which is needed to start the bot.
To invite your bot to your server, go to the Oauth2 page and check the bot scope. Then, enable the permissions as needed. Finally, copy the generated url and open the url in your browser. You will then be able to add the bot to your server.
The bot uses Discord IDs for configuration. You can find these by turning on developer mode in Discord settings:
You can then copy discord IDs by right clicking a role or a channel, for example:
You will need to copy the following IDs:
- The ID of the server itself - Right click the server name in the top-left corner of the discord window.
- The ID of both the student and teaching assistant roles - Right click the name of the role in the server settings.
A github access token is needed for the bot to verify github organization memberships.
To create a token, go to https://github.com/settings/tokens and click "Generate new token".
Then, under scopes, select the read:org
scope. Then click generate on the bottom of the page.
Remember to copy the access token that is generated.
A config file must be named .helpbotrc
. The default syntax is TOML.
You may specify a different file extension, for example ".yml" or ".json" if you prefer a different markup language.
Discord IDs are obtained as explained above.
The following configuration variables must be set:
[[instances]]
db-path = "<path to sqlite database file>" # if empty, an in-memory database will be used
token = "<discord bot token>" # the token that you got from the Discord Developer Portal
prefix = "!" # the prefix used before each command, for example !help
guild = <discord id> # the id of the server
student-role = <discord id> # the id of the student role
assistant-role = <discord id> # the id of the teaching assistant role
The following configuration variables are needed to allow students to register by providing a github username associated with the course's github organization:
gh-token = "<github access token>" # github access token with `read:org` access to the relevant github organization
gh-org = "<github org name>" # the name of the course's github organization
The follwing configuration variables are available to enable autograder support: Currently, we have to run the bot on the same physical server as autograder for this to work.
autograder = true # enable autograder support for this instance
course-code = "<course code>" # the course code to use with autograder
course-year = 2020 # the year of the course
You can create multiple bot instances by adding several configurations, each beginning with [[instances]]
.
The following configurations apply to all instances
autograder = true # enable autograder support
The following environment variable should be set before running the helpbot. This variable must the same as the token used by the QuickFeed server.
QUICKFEED_AUTH_TOKEN = "<quickfeed auth token>" # quickfeed auth token