Git Product home page Git Product logo

bouncer-go's Introduction

Bouncer-go

It's https://github.com/aquova/bouncer written in go - mostly for fun.

WIP and everything is TBD

Features complete so far

It's mostly framework stuff so far.

  • Logging
  • Load config file
  • Add commands
  • Interact with database

Commands

Command Implemented
ban
block
clear
edit
graph
help
kick
note
preview
remove
reply
say
scam
search
sync
unban
unblock
uptime
waiting
warn
watch
watchlist
unmute
unwatch

Feature to be added

  • Implementing all the commands
  • All the background stuff that isn't a command
  • Docker

Running

Download the latest version of Go. On Arch: sudo pacman -S go.

Also get task, an alternative to make. On Arch: yay -S go-task-bin. I use alias task="go-task".

The program takes in a config directory and expects there to be a bouncer.db and a config.json file inside of them.

The config file is similar to bouncer's except:

  • All ids are strings instead of numbers because discord-go uses strings for ids rather than numbers like discordpy
  • The owner user id field is moved into the roles config named owner (list of role ids)
  • The DM configs are booleans rather than numbers
  • The rolesToAddToThreads field was moved under roles named dm_threads and it's parent messageForwarding removed
  • The debug field isn't used

Sample config.json file (see config.go for meaning):

{
  "discord": "xxxxxx",
  "command_prefix": "$",
  "servers": {
    "home": "12345678910"
  },
  "categories": {
    "listening": [
      "12345678910"
    ]
  },
  "channels": {
    "mailbox": "12345678910",
    "spam": "12345678910",
    "ignore_spam": [],
    "log": "12345678910",
    "syslog": "12345678910",
    "watchlist": "12345678910",
    "ban_appeal": "12345678910"
  },
  "roles": {
    "admin": [
      "12345678910"
    ],
    "owner": [
      "12345678910"
    ],
    "dm_thread": [
      "12345678910"
    ]
  },
  "DM":{
    "ban": true,
    "warn": true
  }
}

The database file is identical to bouncer's.

Then, one of:

  • CLI: task run. Configs are taken from private/ by default, change them using CONFIG=foo/ task run.
  • In IntelliJ IDE: run the Run run configuration. Configs are expected to be in private/.

To just build the binary, run task build.

If you want to run the go commands directly, see taskfile.yml.

Development

Setting up unit tests

Run task generate to generate the mocks. These aren't committed.

Adding commands

  • Add a file in the commands folder with a struct that implements the Command interface
  • Add it to commands.All

Adding new config fields

  • Update config.go

Adding new database fields

  • Update tables.go as well as database.allTables

Docs

Thoughts on the port

  • discordgo is lower level, so more API calls are needed for tasks that discordpy would handle automatically
    • e.g. retrieving the roles a user has, or the category a channel is in
  • everything being typed is already so much nicer than discord-py

Thoughts on go and the libraries used

  • zerolog is neat - has all the features I want out of a logger
    • previous logger framework experience I had was stdlib (lacking features) and logrus (verbose, hard to use)
  • gorm looks neat so far - needs more usage to get it to work

bouncer-go's People

Contributors

danvolchek avatar

Watchers

 avatar  avatar

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.