Giter Site home page Giter Site logo

pythagors's Introduction

Build Result

Pythagors

Rewrite of cyferki-watcher-bot in Rust to use shuttle deployments.

Rules

Game rules can be found in Rules

Required bot Privileged Gateway Intents

  • Message Content Intent

Required bot user permissions

  • Manage Roles ⚠️ Bot's role must be higher than any role that it sets for this feature to work ⚠️
  • Read Messages/View Channels
  • Send Messages
  • Manage Messages

local dev config

Tools

Make sure that rust toolset is up to date.

rustup update

Shuttle plugin for cargo is required for building, running and deployment of bot

cargo install cargo-shuttle

Config

In main project directory create Secrets.toml file with following contents:

CLIENT_TOKEN="" # bot token
WATCHED_CHANNEL="test1" # name of channel to watch
WRONG_INCREMENT_MESSAGE_TEMPLATE="{{author}} learn learn to count" # Content of message sent, when user posts wrong number
WRONG_FORMAT_MESSAGE_TEMPLATE="{{author}} read game rules - message was not correct" # Content of message sent, when user posts message in wrong format
RANK_WON_MESSAGE_TEMPLATE="{{author}}, congratulations on winning rank {{role}}!" # Content of message sent, when user posts message with number winning role 
GAME_OVER_MESSAGE_TEMPLATE="Game over! Thanks for playing" # Content of message sent on last number
RANKS='{"10": "973271221112291409", "15": "973282436047839262"}' # JSON with number - rankId entries
GAME_OVER_NUMBER="16" # Number, on which game will end as a string

Config placeholders

  • {{author}} will be substituted with mention to message's author
  • {{role}} will be substituted with mention to won role

Run project locally

cargo shuttle run

Deploy to shuttle

cargo shuttle project new # only if project does not exist yet
cargo shuttle project start
cargo shuttle deploy

Secrets are populated initially from Secrets.toml file and can be edited with cargo shuttle secrets command.

Stop deployment

cargo shuttle project stop

pythagors's People

Contributors

kryszak avatar dependabot[bot] avatar

Watchers

 avatar

pythagors's Issues

Do not allow to edit messages

If someone edits previously correct message it might breaks the bot's behaviour, so bot should not allow users to edit messages in watched channel.

Use toml array of objects format for defining prized numbers instead of JSON string

Currently pythagors takes prizes numbers from raw JSON string from secrets, i.e.

RANKS='{"10": 973271221112291409, "15": 973282436047839262}' # JSON with number - rankId entries

TOML format supports arrays and tables and pythagors should parse prizes from more readable format, like:

RANKS = [ 
    { number = 10, rankId = 973271221112291409 },
    { number = 15, rankId = 973282436047839262}
]

Reference:
https://toml.io/en/v1.0.0#array

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.