Giter VIP home page Giter VIP logo

graim's Introduction

graim

matrix <=> discord moderation with the power of matrix-appservice-discord

Social

graim's website is viewable at gra.im. You can join the graim Matrix space as well as the Discord server. *the main matrix room is @ #general:gra.im

Configure/Install

Check out the configuration guide.

TODOs

  • Bug fixing
  • Better guides

Features

  • moderation syncs across rooms
  • Kick, ban + unban
  • Mute
  • Strike system
  • Automatically attribute moderation history to graimdb
  • Discord moderators may use whosent to discover what matrix user is behind a Discord message
  • Userinfo command
  • Database management commands (add/remove user, add/remove moderator)

How

graim is built with the intention of being Matrix-first. There are a few reasons for this:

  • Discord API sucks
  • Discord webhooks have incredibly little data attributed to them
  • I <3 Matrix

Every Discord user, via matrix-appservice-discord, is given its own user (i.e. @_discord_<discord_id>:matrix.org. So, graim listens for commands only from Matrix users - because Discord users are Matrix users by proxy. Simply tie a server to a group of rooms, then tie each Matrix user to a Discord account packaged in one "graim user" :D

Credits

The bot itself - luphoria

Any other contributors

Built with major help from turt2live/matrix-bot-sdk-bot-template by Travis Ralston

Uses the dependencies:

Special thanks:

graim's People

Contributors

dependabot[bot] avatar luphoria avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

alexfag hiran6

graim's Issues

[BUG] Incorrectly parsing very newly generated user IDs

Describe the bug
Because newly generated user IDs are a character longer than they used to be, graim will get confused and fail trying to understand them.

Additional context
This should just be an issue to fix in user_discordId, but it probably creeps around random other parts of the program.
I also can't simply just add another character to my current system, because then the old IDs are broken.

[FEATURE] auto-delete styled URLs

Describe the bug
You can use markdown to make links look different than they are. This could be a security issue.
Ex: [https://www.google.com](this could link to a phishing page)

To Reproduce
Steps to reproduce the behavior:

  1. Go to any room that is bridged.
  2. Do the markdown magic(e.g., https://github.com/)

Expected behavior
Graim should delete message or there should be a config option to auto-delete these messages.

[FEATURE] Lint setup

Basically, just a feature within the bot which will check all of the configurations for the Discord server, Matrix rooms, and bot, to ensure that everything is correctly set up. This would allow people to much more quickly figure out exactly what they need to do.

Reqs

  • Error if not capable of role mgmt, kick, ban, mute on Discord
  • Warn if no moderator in graimdb.json
  • Warn if power level is not high enough to kick/ban/mod powerlevels in n room
  • Warn if autojoin is on in config
  • Warn for rooms not bridged directly to channel via graimdb
  • Warn if no channel mgmt permissions on Discord
  • Info if no logging room set

Some things are probably missing from this list, but that's the general idea. None of these will cause fatal errors in graim itself, but they WILL cause graim to not work.

[CRASH] mute.ts: `val is not a non-empty string or a valid number. val=undefined`

To Reproduce
Steps to reproduce the behavior:

  1. run graim @ latest
  2. ;mute
  3. crash

Logs

/home/hi/graim/node_modules/ms/index.js:33                                                                                throw new Error(                                                                                                              ^                                                                                                                                                                                                                                       Error: val is not a non-empty string or a valid number. val=undefined                                                       at module.exports (/home/hi/graim/node_modules/ms/index.js:33:9)                                                        at /home/hi/graim/lib/commands/mute.js:52:26                                                                            at Generator.next (<anonymous>)                                                                                         at /home/hi/graim/lib/commands/mute.js:8:71                                                                             at new Promise (<anonymous>)                                                                                            at __awaiter (/home/hi/graim/lib/commands/mute.js:4:12)                                                                 at runMuteCommand (/home/hi/graim/lib/commands/mute.js:22:12)                                                           at CommandHandler.<anonymous> (/home/hi/graim/lib/commands/handler.js:103:51)                                           at Generator.next (<anonymous>)                                                                                         at /home/hi/graim/lib/commands/handler.js:8:71 

Desktop (please complete the following information):

  • Node.js version

Additional context
the issue is that I had assumed ms was okay with undefined i.e. bad data, and simply returned 0 (as it does for other strings). however, if there is NO argument, undefined is passed, which crashes ms.

[BUG] Unban unsuccessful on Discord end

Describe the bug
When you run unban on a banned user bridged from Discord to Matrix, the unban doesn't go through on the Discord end.

To Reproduce
Steps to reproduce the behavior:

  1. Run ;unban on user that already is banned
  2. Note that the user is not unbanned on Discord

Expected behavior
User is unbanned from both Matrix and Discord

Logs
N/A

Desktop (please complete the following information):

  • Node.js version - 18

Additional context
It makes sense that it didn't work, because I have done minimal testing on the ban and unban commands (Discord banned my testing accounts from the platform for suspicious activity).

[FEATURE] configure logging level in default.yaml

Currently it is only possible to change the logging level for graim through editing the bot's code. Obviously this is not ideal for most, and it would be easier to have a config for it as some admins would rather not have verbose logging.

[FEATURE] More receptive responses on non-fatal failures

graim currently essentially ALWAYS tells you that the operation was completed successfully. While this is fine 90% of the time (usually, any non-fatal errors are not really errors but simply non-issues), I think it would be a lot more useful for the bot to at least warn you in the situation that something has gone wrong partially.

For example - when a user is banned, graim will attempt to ban them from discord and matrix. As long as the command isn't improperly formatted, graim ALWAYS responds with a success - even if there was not actually a success in the action. For example, if graim's power level isn't high enough in every room, then it will not be able to ban the user - however, there is no way for the end user to know the interaction failed, without logging on Matrix themselves and seeing the ban event in the log.

Mostly I am using this issue to track a long-term implementation of more reception from graim, because this is a big design issue that I am currently completely ignoring. First, I need to figure exactly how I want output to show (should I log in every room/channel individually that it failed in? Should I print out another message after the ban success showing any warns?)

Any outsider input is greatly appreciated!

I am going to be tracking this development in the commit names, so it should be easy to follow progress on this specific development.

[BUG] `deleteuser` doesn't work

Describe the bug
The deleteuser command does not actually remove the user from the database

To Reproduce
Steps to reproduce the behavior:

  1. Run deleteuser <graim_name>
  2. See the success message
  3. Run userinfo <graim_name>
  4. See the user is not deleted

Expected behavior
No user in db

Logs
N/A

Desktop (please complete the following information):

  • Node.js version 18

Additional context
N/A

[FEATURE] Remove strikes from user

Currently, the only way to remove strikes from a user is by completely deleting and re-adding the user, or by manually editing the JSON. This feature (clearstrikes?) would simply clear all of the strikes from the user.

If I'm not too lazy, it would be preferable to number strikes in order, so that you could also have a clearstrike <n> command to revoke specific events.

[FEATURE] Lock, unlock

Would change room/channel settings, preventing users from speaking.

Primarily, this would be a challenge due to its existence on both Discord and Matrix side. I don't want to have to implement another part of the database where entries must be manually considered, so I am thinking about it.

My best idea so far - verbosity in syntax. User is expected to write ;lock <discord channel>, to lock whatever room the message was sent in on Matrix, and the room specified.

The main issue is that this is not good on the M=>D side of things, because they are unable to specify a specific channel.

This is a logic thing, for the most part, and I will update the issue as progress moves forward

[FEATURE] `adduser`: no more mentionpill requirements

Fairly self-explanatory. Currently, graim simply quits if you don't provide a MentionPill for adduser, to avoid bad data from getting added in. But, there really isn't anything preventing me now from letting people input the info in plain-text.

This is additionally important for accessibility to the command - many clients simply don't let you create MentionPills.

[FEATURE] Logging channel/room for actions

Most extensive moderation bots will have a room in which it logs all moderation actions (i.e.: kicks, mutes, strikes, bans). This makes it much, much easier to keep track of moderation that a team is doing, as well as keeps a significantly more reliable and accessible log than Discord's audit log.
The reason I didn't think to implement this already, is because Matrix already logs all moderation events right in chat - but this absolutely is a must-have feature for large moderation teams

[FEATURE] Content filter

This feature would simply catch any messages that include content which is specified by the moderators (regex, i'm thinking). That way, you could auto moderate things like slurs, spam, or whatever else you'd like

[FEATURE] `whosent` Improvements

Right now, whosent relies entirely on the search api for whosent. This has realistically a pretty bad turnout, given search's restrictions, as well as the approach as a whole.

Direct goal: have whosent index all users in the room by displayname before hitting search at all. If there is only one result with the equivalent displayname, we've found our guy.

More planning needed: sanitize the search query better. Right now, search is shit: it returns nothing, if you have really any special character in it, rather than ignoring it. But we have to be careful on OUR end, because stripping special characters = potentially askewing the data we are searching with in the first place. The most obvious example is the : character, as if we remove it then we immediately run into other issues in the search, breaking the entire thing.

[BUG] Doesn't find user if Discord ID supplied (no mention)

Describe the bug
If you attempt to perform any action on a bridged user, based on their Discord ID (snowflake id), then it will work, but only on Discord. It will fail at the lookup in the database, but correctly interacts with the user

To Reproduce
Steps to reproduce the behavior:

  1. Use any moderation command (;mute) on a bridged user, via their Discord user ID
  2. See that the bridge only worked on Discord

Expected behavior
The mute command works on both Discord and Matrix

Logs
n/a

Desktop (please complete the following information):

  • Node.js version 18

Additional context
n/a

[FEATURE] Purge by user/graim user

I think a good feature to implement to graim would be purging by user/graim user. this is a pretty common feature of moderation bots and is super super useful in the event of, say, a raider. with one command you can then delete ALL of one user's messages

[CRASH] `DiscordAPIError: Missing Permissions`

To Reproduce
Steps to reproduce the behavior:

  1. Fire up the bot
  2. Then on Disocrd/Matrix type ;mute @ UserExample (must be an admin)
  3. See error

Logs

/home/tuckerj/Documents/graim/node_modules/discord.js/src/rest/RequestHandler.js:350
throw new DiscordAPIError(data, res.status, request);
^

DiscordAPIError: Missing Permissions
at RequestHandler.execute (/home/tuckerj/Documents/graim/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/home/tuckerj/Documents/graim/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
at async GuildMemberRoleManager.add (/home/tuckerj/Documents/graim/node_modules/discord.js/src/managers/GuildMemberRoleManager.js:124:7) {
method: 'put',
path: '/guilds/968319055717085184/members/818995901791207454/roles/969439573912453120',
code: 50013,
httpStatus: 403,
requestData: { json: undefined, files: [] }
}

Desktop (please complete the following information):

  • Node.js v18.0

Additional context
Add any other context about the problem here.

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.