Git Product home page Git Product logo

kotlin-fabric-discord-bot's Introduction

The project has been continued by https://github.com/FabricMC/discord-bot

fabric-discord-bot

This bot is designed for a specific discord server, so it most likely will not fit the needs of your server.

Note: If you're testing the bot, make sure you have both privileged intents enabled for the OAuth app. See here for more information.

If you're using the bot via Docker, note that GIT_DIRECTORY will automatically be set to /git. You will most likely want to mount this directory.

Configuration

Note that the bot can be configured using a config file called config.toml instead if you prefer. The part of the environment variable name before the first underscore is the section you should use, and the rest is the camelCase key you should use within that section.

For example, you might do this in a bash script:

export CHANNELS_ACTION_LOG_CATEGORY=764817953463861288

In config.toml, you might do this:

[channels]
actionLog = 746875064200462416

You may also use system properties to configure the bot. Configuration takes the following order of precedence, with later sources overriding earlier ones:

  • default.toml bundled inside the JAR
  • Environment variables
  • System properties
  • config.toml if it exists

Required Environment Variables

  • BOT_TOKEN = The discord bot token

  • GITHUB_OAUTH = GitHub OAuth token

  • DB_URL = MySQL URL, eg mysql://host:port/database

  • DB_USERNAME = Database username to auth with

  • DB_PASSWORD = Database password to auth with

Optional Environment Variables

  • BOT_GUILD = The ID of the discord guild this bot should operate on

  • BOT_EMOJI_GUILD = The ID of the discord guild this bot should index emojis from

  • BOT_PREFIX = The prefix required for commands

  • GIT_DIRECTORY = The directory to store cloned Git repositories (for extensions)

  • GIT_TAGS_REPO_BRANCH = The branch name to checkout for the tags repo

  • GIT_TAGS_REPO_URL = URL to the git repo containing tags

  • GIT_TAGS_REPO_PATH = Root directory (within the repository) containing tags

  • GITHUB_ORG = The target github organisation for the github commands.

  • GITHUB_TOKEN = The github personal access token, with admin:org permission

    • Only optional if you are not using the github commands
  • CHANNELS_ACTION_LOG_CATEGORY = The ID of the action log category

  • CHANNELS_ALERTS = The ID of the alerts channel

  • CHANNELS_BOT_COMMANDS = The ID of the bot commands channel

  • CHANNELS_MODERATOR_LOG = The ID of the moderator log channel

  • CHANNELS_IGNORED_CHANNELS = A list of channels to ignore for the purposes of filtering and logging

  • ROLES_ADMIN = The ID of the admin role

  • ROLES_MOD = The ID of the moderator role

  • ROLES_TRAINEE_MOD = The ID of the trainee moderator role

  • ROLES_MUTED = The ID of the muted role

  • ROLES_NO_META = The ID of the meta-muted role

  • ROLES_NO_REACTIONS = The ID of the reactions-muted role

  • ROLES_NO_REQUESTS = The ID of the requests-muted role

  • ROLES_NO_SUPPORT = The ID of the support-muted role

  • LIVE_UPDATES_MINECRAFT_CHANNELS = A comma separated list of discord channels to send minecraft version updates to

  • LIVE_UPDATES_JIRA_CHANNELS = A comma separated list of discord channels to send JIRA version updates to

kotlin-fabric-discord-bot's People

Contributors

arc-blroth avatar gdude2002 avatar i509vcb avatar iotabread avatar modmuss50 avatar scotsguy avatar sfplayer1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

kotlin-fabric-discord-bot's Issues

Tag translations

(I chose here and not on the community github because this is where tags are read)
Many people who come onto fabricord for help with mods or modding don't know English or have trouble understanding English. It would be much easier to give them help if we could have translations of tags that allow us to send tags in other languages, such as French, or Spanish.

Link to yarn javadoc

https://github.com/FabricMC/fabric-discord-bot/blob/f8ea657b6ffb1e5af268b5a656627fe522dc48c5/src/main/kotlin/net/fabricmc/bot/extensions/MappingsExtension.kt#L286 <- can probably add here

So for a class like net/minecraft/village/ZombieSiegeManager for yarn 21w05a+build.7, the link to that class is https://maven.fabricmc.net/docs/yarn-21w05a+build.7/net/minecraft/village/ZombieSiegeManager.html
so the general pattern is like
https://maven.fabricmc.net/docs/yarn-${yarnVersion}/${namedClassName}.html
Note: you need to replace the $ in class name with ., like https://maven.fabricmc.net/docs/yarn-21w05a+build.7/net/minecraft/village/ZombieSiegeManager.State.html

For fields, it's like
https://maven.fabricmc.net/docs/yarn-${yarnVersion}/${namedClassName}.html#${namedFieldName}
like https://maven.fabricmc.net/docs/yarn-21w05a+build.7/net/minecraft/village/ZombieSiegeManager.State.html#SIEGE_CAN_ACTIVATE

For methods, it's like
https://maven.fabricmc.net/docs/yarn-21w05a+build.7/net/minecraft/village/ZombieSiegeManager.html#spawn(net.minecraft.server.world.ServerWorld,boolean,boolean)
for int spawn​(ServerWorld world, boolean spawnMonsters, boolean spawnAnimals) in ZombieSiegeManager.
This one requires a bit more complex anchor building.

Tags (Tricks) system

This will replace K9's tricks system once implemented. The idea is to have something similar, with the following design:

  • Tags will be stored on Git only, and the bot will maintain a local copy of the repo
  • As tags should be able to generate embeds, we've come up with a simple format: Markdown with YAML front matter. This won't actually be front matter in the strictest sense - it'll contain everything about the tag aside from the actual main content itself, including embed fields and colours.
  • Add some additional parsing - for example, {Role:MODERATORS} to insert a role mention.
  • Multiple tag types - text, embed and alias

This will involve writing some library-style code, but it should be possible to write a tag linter into the bot as well, so that the JAR could be downloaded by the CI system and used to lint the tags in the repo. We'll see, though.

Logging enhancements

As requested by Player on Discord:

  • Add user#discrim to mod-log/action-log messages
  • Add infraction duration to mod-logs (we already have creation/expiry, this is just for display)

Additionally:

  • Work on deduplicating/lowering the frequency of action-logging events through filtering and getting deltas of objects

Ping System

Since K9 has been removed we could use a replacement for its ping system.
As a reminder, the ping system for k9 was essentially that you could register an arbitrary regex, which k9 would run on every message and if it matched send you a DM with a link to the message that triggered it.

I would recommend the following restrictions, compared to what k9 had:

  • Only works in channels that the user (maybe even @everyone just to be safe?) can read
  • Pings are essentially just input.toLowerCase().contains(ping.toLowerCase()), no regex involved
  • Pings should have a minimum length and/or a maximum amount of triggers per unit of time, to avoid situations where someone wants a ping any time the letters e or t are used in a message, or is otherwise burdening the bot.

Adaptive Slowmode

Add a sort of slowmode that changes dynamically based on the amount of people talking in a channel. For example, discord-side slowmode could be 2 seconds when only 4 people are talking, but 10 seconds or more if 12 people are talking - measured by "people who have sent a message in the last x minutes"
(Actual calculation TBD, maybe base it on the total amount of messages the channel would allow with x amount of people talking)

Modlog messages should include user name verbatim

Entries like "<@227459273100230656> has been muted..." aren't very useful to look at if the discord client doesn't load the username. I'd suggest changing it to send e.g. "2xsaiko#0001 (<@227459273100230656>) has been muted..." for better readability.

Rotating action logs

I had planned on looking into this on a later date, but some concerns were raised with me in private so I'm going to enumerate it now.

We don't need to keep action logs permanently. I think 30 days is plenty, and had considered deleting messages monthly, but there are some issues with that:

  • Discord won't let you bulk-delete messages older than 2 weeks, which is not enough retention time
  • Monthly rotations have windowing issues, making it harder for people to know the exact duration we're storing things for
  • Direct deletion of messages requires a ton of database work, plus maintaining rows, deleting old ones when messages are deleted, etc

Instead, I'd like to propose the following solution:

  • We keep a rotation of 5 channels for action logs
  • Action log channels are rotated weekly - with the oldest one being deleted when a new one is created
  • We formalize our informal action log policy, along the lines of "don't leak anything from the action log channels"

I think this is a relatively simple solution that retains action logs as long as we need them for (35 days), whilst stil respecting users' expectation of privacy (messages are always eventually removed if users delete/edit them). That said, I'd be happy to take constructive feedback in the comments of this issue.


Things that have been considered and decided against:

  • Per-user opt-out: We simply can't trust users with this. Most users don't really care enough, and many people that decide to opt-out are likely to turn out to be troublemakers, even if there are people that behave themselves and would like to opt-out.

More mappings command syntaxes

The following syntax would be added for lookup using fields and methods:

  • Owner#field. Get field/method data within a specific class. This would be useful for limiting scope in a lookup.
  • Owner.field. Same as above
  • DeobfOwner.obfMember. Sometimes useful if you need to know the de obfuscated name of a field/method but you know the de obfuscated owner name.
  • field_26935:Lnet/minecraft/class_5579;. Lookup a field of the specified name while matching the specified signature
  • methodName(Lnet/minecraft/server/MinecraftServer;)V. Look up a method which takes a MinecraftServer as a parameter and the return type is a void.
  • (Lnet/minecraft/server/MinecraftServer;)V. Look up a method which matches the specified signature, regardless of method name.

The following syntax would be added for lookup using classes:

  • Lnet/minecraft/.../Class;. JVM style signature lookup for a class.
  • net/minecraft/.../Class. Similar to above, without the L prefix

Feedback on the issue is welcome for suggestions or arguing whether a specific syntax is needed or not.

Case-insensitive tag searching

?tags search is great, but it'd be better if it could ignore case - so ?tags search Mixin would find mixin or MIXIN as well as Mixin

Mappings Command does not give intermediary names as the first suggestion when searching for a number

This is not really a big issue, but when you run something like ?ym 4964 the bot doesn't actually look for ?ym method_4964 and looks for something else instead. An example that probably makes more sense is in the picture below. Thought this might be a nice feature so you wouldn't need to type out method_ or class_ .
image

Edit: Looks like the bot does pick it up, but displays it on the very last page, could it just be moved to the first page?

Github spam detection and deletion

This issue is made up of 2 parts:

  1. A command to close and lock all issues and pull requests by a certain user. Not sure if it should be specific to a repo or the whole org?

  2. Some form of auto detection and blocking (for 24 hours?). Could check for 3 issues opened by a new user in a limited amount of a time. It should report any actions back into the moderation log discord channel. We will need to be careful with this as I wouldnt want any false postives.

Allow Infracting Multiple Users

Would be helpful for when a conversation's getting heated, without giving any of the involved parties the opportunity for a "last word". Something like a simple comma-separated list of user IDs would probably work.

Add mixin target selector to mappings command lookup

This would simply also include a JVM style signature for use in mixin with a mapping query/lookup.

Example lookup for TradeOffers.Factory#create would yield the following in the response:

Lnet/minecraft/village/TradeOffers$Factory;create(Lnet/minecraft/entity/Entity;Ljava/util/Random;)Lnet/minecraft/village/TradeOffer;

Make mappings commands inheirtience aware

This is definitely a longer term feature. Simply allowing the bot to be aware of inheritance to allow for example ServerPlayerEntity.getHealth to resolve the proper method on lookup.

Evidence attachment system

Our infractions system should include a way to attach evidence to infractions. After #13 is implemented, action logs will be rotated automatically - which means we need to attach offending content to infractions before the context for those infractions is lost.

Ideally, this system should meet the following requirements:

  • Allow attachment of screenshots and other files to infractions
  • Allow for the attachment of on-server data (for example, messages)
  • Optionally, allow attaching an action log message (for example, a deleted message log) - we don't store these in the database so they will have to be parsed from the message on Discord directly

Concern count

Count the number of :concern:/:concerned_tater: emotes a user has recieved through reactions
image

Self-Assignment of Roles for Users

This could be done in a couple of different ways:

  • Users could react to a message and be given roles based on these reactions. There is a precedent for this kind of thing already.
  • A bot command that allows users to self-assign roles

One potential use case for this is illustrated by jamierocks wanting to be able to hide the non-development channels in the Discord server. With this system in place, users could opt out of seeing those channels that they don't want to interact with.

Request - Bot doesn't find names that start with the query

TL;DR: Please make the bot search for names starting with the query.

When using any of the mappings functionality to search for names, the bot only searches for names that end with the query.
This does make it easier to do things like ?yc 69 to find out what it is but I would like if the bot also searched for results starting with the query.

That will make it easier to search for server-related things, for example, as they usually begin with the word Server in Yarn. ?yc Server will be able to find things like ServerPlayerEntity and ServerPlayNetworkHandler.

Add ability to toggle slowmode option on channels via commands

Since toggling slowmode on a channel requires the ability to completely modify or remove a channel, I feel a command should exist to toggle slowmode for a channel.

Was thinking of a syntax like this:

!slowmode <#channel> <time>|<off>

For example, !slowmode #general 30s would enable slowmode of 30s on #general. While !slowmode #general off would disable slowmode on #general

The time would be the valid time increments support by discord for the channel's slowmode and the off literal would disable slowmode on the channel.

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.