vEnhance / mosp-web

General MOSP website
MIT License
3 stars 0 forks source link

Discord logging #14

Open vEnhance opened 3 years ago

vEnhance commented 3 years ago

Send out a message to Discord when someone solves a puzzle (or submits a wrong answer, etc.)

vEnhance commented 3 years ago

@anser0 do you want to try this when you get a chance? I'm about to update the MOSP-WEB config to have the same log setup as OTIS, so you would only have to insert logging statements in the right places in the views files. You can see OTIS-WEB for some hints on how this is done.

anser0 commented 3 years ago

I'm down to try this! Although I don't know how and would need some help to get started... 😄

vEnhance commented 3 years ago

@anser0 Yeah, here's a rough outline. I can go into more detail the next time we're in the same room / voice channel.

  1. git pull so you're up to date.
  2. In mospweb/settings.py, you'll want to delete the require_debug_true filter that's on the Discord logger, so you can test the logger.
  3. Create some webhooks in Discord for channels you want logs to appear in. For example, maybe there's a channel for server errors, another channel for successful solves, etc. Up toyou.
  4. Create .env and populate it with entries like WEBHOOK_SUCCESS_URL=[url], WEBHOOK_ERROR_URL=[url], etc. Read discordLogging.py for a list of log levels supported.
  5. In */views.py add logging events at points that should generate log entries. Search for the word logging in https://github.com/vEnhance/otis-web/blob/main/dashboard/views.py for some idea of how this work.
  6. Test locally to see if the Discord messages work.
  7. Send the .env file to me on Discord, do not commit the .env file into Git, it is supposed to contain secrets that shouldn't be in a version control system.
  8. Commit the other files except .env and submit a pull request.
vEnhance commented 3 years ago

@anser0 have you had a chance to look at this yet?