/canvas-discord-bot

A Discord Bot made to communicate with Canvas LMS API via user commands.

Primary LanguagePythonApache License 2.0Apache-2.0

canvas-discord-bot


Canvas Discord Bot

This is a discord bot that gets information about courses and announcements from Canvas API and sends this information in a discord channel.

Report Bug · Request Feature

Table of Contents

  1. About The Project
  2. Getting Started
  3. Commands
  4. Make Your Own Command?
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgements

About The Project

We are a group of students studying at Gothenburg University who decided that we wanted to build a bridge between Canvas LMS and Discord. The result is a bot that can recieve and post announcements made by, for example, teachers in a Discord channel.

Built With

Getting Started

Below you will find the steps to get started with the bot.

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/Dedas/canvas-discord-bot
  2. Navigate into your cloned folder

    cd "Drive:/folder/folder/canvas-discord-bot"
  3. Install the following modules:

    pip install requests
    pip install environs
    pip install apscheduler
    pip install discord
    pip install BeautifulSoup4
    pip install lxml

Usage

To use the bot you need to fill in some parameters in the .env file.

  1. Rename the .env.example file to .env

  2. In the .env file, replace the text with your parameters

    Make sure that the Canvas Token has access to all the availible courses!

    DISCORD_TOKEN='https://discord.com/developers/applications'
    CANVAS_TOKEN='YOUR CANVAS TOKEN'
    CANVAS_DOMAIN='YOUR CANVAS DOMAIN'
    DEFAULT_CHANNEL_ID='YOUR DISCORD DEFAULT_CHANNEL_ID'
  3. Run the bot

    python bot.py

    With debug messages on:

    python bot.py -d

Commands

  • .courses - List all the courses that the bot has access to.
  • .subscribe <course_id> <channel_id> - Subscribing to a course and recieve announcements from that course in a specific channel.
  • .unsubscribe <course_id> - Unsubscribe to a course.

Options in "config.json"

Discord specific

  • "discord_command_prefix" : "<prefix>" - The prefix that will be used to communicate with the bot in Discord. Default prefix "!"

Internal scheduler loops

  • "monitor_scheduler_interval" : <seconds> - Interval of loop that fetches data from Canvas in X seconds.
  • "announcement_scheduler_interval" : <seconds> - Interval of loop that sends announcements to Canvas in X seconds.

Database specific

  • "permanent_database" : <true>|<false> - If the system should keep the stored database or rebuild it after a restart. Default = false

Announcement command

  • "announcement_date_cut_off_time" : <days> - No announcement will be sent to Discord older that X time in days. Default = 3

Debug

  • "debug_mode" : <true>|<false> - A log file will be created under preset directory. Default = false

License

Contact

Andreas Winkler - guskalinan@student.gu.se | LinkedIn

Tove Andersson - gusandtocs@student.gu.se | LinkedIn

Josef Gunnarsson - gusgunjoae@student.gu.se

Heidi Hedman - gusheidihe@student.gu.se

Henrietta Sundberg - gussunhem@student.gu.se

Acknowledgements

We have been inspired by: