Git Product home page Git Product logo

mbot's Introduction

A discord bot with tools and automatic puzzlehunt progress tracking for a small to medium sized team. For fun, the bot is named after a character from the works of Brandon Sanderson.

Puzzle Manager

Puzzle progress stored in a master "Nexus" google sheet.

  • With a !createround command: create a new category, general channel, voice channel, update nexus
  • With one puzzle !create command: create puzzle channel, duplicate template google sheet, update nexus sheet, send links to discord
  • Log answer in nexus sheet with !solve
  • View and update !login info for team
  • View puzzle progress in !nexus
  • Store and update common resources in !tag

Example of auto-populated nexus sheet (answers removed) example

Toolbox

  • !n: Nutrimatic for anagrams, regex search, patterns, etc
  • !cc: Caesar shift
  • !alpha: Alphanumeric A1Z26
  • !atom: Periodic table
  • !atbash: Atbash cipher
  • !v: Vigenere cipher

Bot setup

The setup relies on a Google service account and a AWS DynamoDB connection.

  1. Create a .env with your tokens.
DISCORD_TOKEN= ...   # your discord bot token
GOOGLE_CLIENT_SECRETS=...   # google service account credentials
AWS_ACCESS_KEY_ID= ...
AWS_SECRET_ACCESS_KEY= ...
  1. Enable Google API following instructions on gspread documentation to get a client_secrets.json for a service account.
  2. Initialize two tables in DynamoDB. Unfortunately I don't have a standalone init script for this, but the code used is commented out in utils/db2.py.
  3. [Per hunt] Set up a google folder (shared w/ service account address) with Nexus and Puzzle Template sheets.
  4. Feel free to message me for details/help.

mbot's People

Contributors

azwong42 avatar dependabot[bot] avatar moonrise55 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

fnv

mbot's Issues

Collaborative whiteboard web software integration

We should consider integrating an API hook for a collaborate whiteboard software. This wouldn't need to create a whiteboard for every puzzle, but puzzles could have commands to generate and link them. This has a few benefits:

  • Normalized whiteboard use: no more having to learn Magma/Miro/Google Drawings/whatever else depending on who creates the first link. However, this is also a potential downside, if the tool we choose here goes bad and we need to switch it out.
  • Centralized information flow: one M-Bot command can tell solvers whether there is a whiteboard for the puzzle, and if so, where it is. The single link can also be automatically pinned and transferred to the puzzle sheet. Once we achieve M-Board integration, M-Board can link the whiteboard as well.

Components:

  • Collaborative whiteboard connector module, which contains the API integration required for whatever software we choose. Miro and Magma both have REST APIs, so they may be good places to start. I believe the team currently favors Miro.
  • !whiteboard command (in the hunt.py cog), which checks whether the puzzle has a whiteboard and links the whiteboard if it does, or creates and links one if not. Creation of the whiteboard should also pin the link message and copy the link to a predetermined field in the puzzle sheet.
  • -recreate flag, which creates and links a second whiteboard in the event that the first one becomes unusable

Puzzle creation should autofill some of the fields in the sheet

Components

  • Automatically insert name into puzzle sheet A1
  • If a website is set, try to make the round/puzzle URL and insert it into puzzle sheet A2

Additionally, we also might want:

  • Add a -slug= flag to !create and !round for puzzles with slugs that aren't just their title
  • Insert a reminder for solvers to check the URL in case it's still weird

Alias various !login update flags

Currently, the !login update flags are a mix of somewhat inconsistent abbreviations. We should support more abbreviation options, as well as single-letter flags like -u and -p.

Clean up !help command(s)

  • Make a separate !helporg command to summarize all the random housekeeping commands floating around. This include how to update !login, how to archive chat history, how to delete categories, how to check server stats.

  • Clean the normal !help command to just be stuff that is relevant to all solvers during a hunt

Fix !nexus errors when the embed is too large

  • Proposed fix: "if !nexus is run within a round category, just display that round." and "if any !nexus command is too large, just link the sheet."
  • We could also consider a #nexus channel (for bighunt mode) that paginates the puzzles in each round

Sheets API frequently hits limit when bot has been running for a while

After the bot has been running for a bit and many puzzles have been created/solved, it starts hitting the 60-second request limit for the Google Sheets API extremely frequently, even in situations where it reasonably shouldn't (i.e. there has been excessive bot activity in the past 10 minutes, but not in the past 1 minute). Presumably this is due to some kind of hanging process or request that we're not closing out properly. We should figure out what's causing this and avoid it, if possible.

!graph improvements

Checklist for additions to the !graph command:

  • Mark metas (points or lines)
  • Include team name in graph title (will require name to be databased)
  • Toggle flag for elapsed hours vs. clock time
  • -stop-at flag to generate a graph from hunt start to N hours

Puzzle link storage in spreadsheets

  • We should store links to puzzles in the Nexus sheet and the puzzle spreadsheet.
  • Puzzle creation should attempt to guess the website slug based on the puzzle name, and should have an additional -slug=<slug> flag to set the slug if the name doesn't match.
  • !update should also support -slug=<slug>

Archive command

There are archive commands for either a channel or a category to save all conversation to a google sheet linked. Currently they just send a link to any images found. I have a branch where the commands download the images to a local folder instead.

  1. revive that branch and make the commands accept a local folder location to save images so anyone can use it
  2. stop sending a message for every channel archived. Gets annoying for an entire category. Probably just pass a status message object around instead.

Channel movement is still bugged

Solving puzzles drops them 2 spaces below the most recent green checkmark. Presumably this is either an issue with channel.move() or the way we're counting category channels.

Add command to generate a hunt solve graph

This would be cool to have, so we don't have to make them manually. Possible options:

  • Generates a graph for the current hunt
  • Generates a graph for any hunt given a Nexus link
  • Organiser only?

Proposed update for puzzle creation cog in larger hunts

Goal is to add some features that might be useful for a multi-round hunt. Namely sorting puzzles into categories by round.

  1. command to create a new round
    will make a new category, text and voice channel, add category id to a table in the nexus

  2. command to create a new puzzle will now

  • if -round given
    [if round exists] sort puzzle into correct category and order nexus appropriately
    [if round does not exist] fail

  • if no -round given
    [if current category is a round] assume current category is the correct round and create puzzle there
    [if current category is not a round] fail

2.1) command to move puzzle across rounds?

  1. a log channel that collects all puzzle creation/solve times

  2. update help menu

As before to minimize black box database storage, the nexus google sheet will be the true state. Except hopefully you won't need to sort puzzles into rounds yourself. Theoretically no editing of the nexus sheet will be needed.

Round category ids will be stored on a new tab in the nexus file (or in the far right of the nexus sheet to minimize sheet importing)
Log channel will be hardcoded in the cog or maybe make another entry for the login db.

Since we might want to revert the changes back after mystery hunt, it's probably easiest to work from a copy of the puzzle.py cog and call it bighunt.py. Then should be a simple matter of swapping out the active cog to revert changes. Should also rename hunt.py -> login.py and puzzle.py -> hunt.py for accuracy.

Cache channel IDs to avoid excessive nexus sheet hits

Currently, every puzzle-related command needs to make:

  • A database request (to get the nexus link)
  • (if multihunt) another database request (to get the nexus link)
  • A read request for the nexus sheet (to retrieve puzzle data for the channel)
  • Whatever else the command is doing

If we cache puzzle data whenever we run an operation on a puzzle (creation, note, solve), we can avoid all three of the overhead requests for a reasonable number of puzzles. We already have LRU cache logic set up for voice channel IDs; this shouldn't be all that different.

Add a meta flag to !create

Add a -meta option to !create to automatically mark a puzzle as a meta in the nexus. This will also make the puzzle creation workflow integrate more easily with M-Board

Combine hunt and bighunt cogs

  • reduce likelihood of duplicate/lingering bugs
  • easier to share new features across modes
  • more flexibility for docs, etc

Multihunt management workflow improvements

A list of improvements for the multihunt management workflow

  • Hide folder access in original command (or figure out a way to not require the folder to be linked)
  • login update -role should update category permissions
  • Store bighunt status in database per-hunt (and add a bighunt version of !createhunt)
  • Update !help again

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.