Code Monkey home page Code Monkey logo

zekrotja / shinpuru Goto Github PK

View Code? Open in Web Editor NEW
180.0 6.0 38.0 85.3 MB

シンプル - Discord Bot with role selection, moderation, karma ranking, a starboard, code execution, raid alerting, backups, a web interface, twitch notifications and more!

Home Page: https://shnp.de

License: MIT License

Go 74.92% Shell 0.21% Dockerfile 0.18% JavaScript 0.09% TypeScript 23.06% HTML 0.04% PLpgSQL 0.05% Python 1.00% SCSS 0.04% HCL 0.42%
discord discord-bot discordbot discordgo golang webinterface hacktoberfest angular

shinpuru's Introduction


~ シンプル ~

A simple multi purpose discord bot written in Go (discord.go)
with focus on stability and reliability


    Docker Cloud Automated build 

Branch Tests CI Docker CD Releases CD
master (stable)
dev (canary)

Invite

Here you can choose between the stable or canary version of shinpuru:

Intro

シンプル (shinpuru), a simple (as the name says), multi-purpose Discord Bot written in Go, using bwmarrin's package discord.go as API and gateway wrapper and ken as slash command and interaction framework. The focus on this bot is to provide general purpose, administration and security tools while keeping stability, reliability and maintainability in focus.

shinpuru is mainly used as administration and security tool on my development discord. Feel free to drop by to see shinpuru in action! 😉


Features

Slash Commands

shinpuru mainly uses slash commands to interact with the bot. In the wiki, you can find an automatically generated list of commands, their descriptions and how to use them (or here you can find a more interactive list in the web interface).

You can also find a searchable list in the web interface of shinpuru.

poek6z96T9.mp4

Web Interface

If you are sick of using commands, you can also use the web interface of shinpuru. Simply log in with your Discord Account (alternatively, you can also use the /login command).

Most features of shinpuru available via slash commands are also accessible in the web interface with additional visualization and information provided.

firefox_GCcqUWkYER.mp4

REST API

The web interface simply connects to the REST API exposed by the web server of shinpuru. You can also acquire an API token linked to your account to access the REST API directly, if you want.

Here you can read more about how to connect to shinpuru's REST API and which endpoints are available.

Chat Features

Code Execution

When someone posts code inside a code block, shinpuru can extract the code and language and execute it outputting the result into chat.

The code is picked up and sent to a code execution engine, which safely executes the code and sends back the result via a REST API. Therefore, you can chose between ranna or JDoodle in the config.

Karma

shinpuru features a Karma system which is inspired by Reddit. You can define specific emotes which, when attached to a message, increase or reduce the karma points of a member. You can also specify the amount of "tokens" which can be spent each hour as well as a penalty for giving negative karma, which also takes karma from the executor to prevent downvote spam.

It is also possible to execute actions when passing specific amounts of karma. For example, you can add or remove roles, send messages or even kick/ban members depending on their karma points.

Color Reactions

Another unique feature of shinpuru are color reactions. When enabled (see /colorreaction), shinpuru can fetch colors from chat messages and display them into a reaction. When clicked on the reaction, more information about the color is then posted into chat.

Votes

You can simply create votes using the /vote slash command where users can pseudo anonymously vote using reactions.

Twitch Notifications

You can add names of twitch streamers to a watchlist (see /twitchnotify) and when they go live, a notification message in sent into the specified channel.

Quote Messages

You can use the /quote command to quote messages by ID or link (even cross-channel).

image

Starboard

As literally any other bot, shinpuru also features a starboard! You can even specify an amount of karma members get when their message get into the starboard.

Channel Statistics

You can use the /channelstats command to analyze contribution statistics for specific text channels.

Guild Security & Moderation

Report System

shinpuru features a deeply integrated reporting and moderation system. You can create reports for members who violate guild rules which then are posted into a modlog channel (if specified). Also, all reports of a member can be viewed on their user profiles as well as in the web interface.

Of course, you can also kick and ban members with shinpuru, which also creates a report record in the modlog. It is even possible to create so called "ghost reports". It allows to report or ban members by ID which are no more part of the server.

When a member wants to request an unban, this can be done via the web interface when navigating to <webAddress>/unbanme.

vRPSl97B9Z.mp4

Guild Backups

When enabled, shinpuru will create a backup of your guild's infrastructure every 12 hours. This includes guild settings, channels (names, positions and groups), roles (names, positions and permissions) and members (nicknames and applied roles).

When your guild gets raided or an admin goes rouge, you can simply choose one of the created backups and reset the guilds state.

The last 10 backups are stored and can be reviewed in the web interface.

Raid Alerting

This system allows you to set a threshold of new user ingress rate. When this rate exceeds, for example when a lot of (bot) accounts flush in to your guild (aka raiding), all admins of the guild will be alerted via DM. Also, the guilds moderation setting will be raised to Highest so that only users with roles or a valid phone number can chat.

image

Additionally, all joined users after the event triggered are logged in a list which can be viewed in the web interface. You can also use this list to bulk kick or ban users captured in the antiraid join list.


Docker

Read about how to host shinpuru using the provided Docker image in the wiki article.


Compiling

Read about self-compiling in the wiki article.


Public Packages


Third party dependencies

Back End

Web Front End

Assets

The mascot artwork is created by the wonderful artist Kuglu. Please feel free to give them a visit. 💖


Copyright © 2018-present zekro Development (Ringo Hoffmann).
Covered by the MIT License.

shinpuru's People

Contributors

awsdcrafting avatar callmeagi avatar dodo1213 avatar error2507 avatar github-actions[bot] avatar luxtracon avatar nanderlp avatar not-nik avatar ron31 avatar scderox avatar skillkiller avatar snowjuli avatar tomromeo avatar vbe0201 avatar voxain avatar zekrotja avatar zordem avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

shinpuru's Issues

[BUG] Unable to set leave message channel

Type of Bug

  • Spelling
  • Minor
  • Major
  • Crash

Description

It's not possible to set the leave message channel. (See picture below)

Steps to Reproduce

Try to set a leave message channel

Images & Logs

[prefix]leavemsg channel #join-log

image

[BUG] explicit command permission check fails

Type of Bug

  • Spelling
  • Minor
  • Major
  • Crash

Type of Host

  • Public Canary
  • Public Stable
  • Self Hosted

Description

Explicit permission check does not work.

Steps to Reproduce

  1. Set explicit permission for command to role, for example +sp.chat.tag.create
  2. Assign the role with the permission to yourself
  3. Execute the command sp!tag create test test

[FEATURE] DM-commands-support

Type of Feature Request

  • New feature
  • Enhancement

Description

Allow commands in DMs that aren't guild specific (like the help command)

[BUG] Missing default values on database creation using MySQL driver

Type of Bug

  • Spelling
  • Minor
  • Major
  • Crash

Type of Host

  • Public Canary
  • Public Stable
  • Self Hosted

Description

Describe the bug as clear and concise as possible.

When using the MySQL database driver, the scheme defined to create the nessecary databases does define all columns as 'NOT NULL' without setting a default value used instead which throws errors on insertions when not passing a value for a column.

[BUG] logout does not redirect to /login

Type of Bug

  • Spelling
  • Minor
  • Major
  • Crash

Type of Host

  • Public Canary
  • Public Stable
  • Self Hosted

Description

Redirection to /guilds instead of to /login afetr logout.

Steps to Reproduce

  1. Log in
  2. Log out

[BUG] leavemsg is not being sent to the defined channel

Type of Bug

  • Spelling
  • Minor
  • Major
  • Crash

Type of Host

  • Public Canary
  • Public Stable
  • Self Hosted

Description

The message set in the leavemsg command won't be sent to the defined channel

Steps to Reproduce

  1. Set leavemsg channel !leavemsg channel <channel>
  2. Set leavemsg msg !leavemsg msg <msg>
  3. Let another user leave, the leave message won't be sent

[BUG] reports which should have an attachment dont have one in embeds

Type of Bug

  • Spelling
  • Minor
  • Major
  • Crash

Type of Host

  • Public Canary
  • Public Stable
  • Self Hosted

Description

Reports with attachments don't have an image attachment in the embeds in modlog.

Steps to Reproduce

  1. Set mod log channel
  2. Create a report with an attachment

Images & Logs

Report embed w/o attachment
image

Report in web interface w/ attachment
image

[FEATURE] Language Name in inline execution embeds

Type of Feature Request

  • New feature
  • Enhancement

Description

When executing code from a codeblock, make the name of the language to be displayed somewhere within the embed. e.g. in the footer (see attached image)

Images & Sketches

image

[FEATURE] Add unmute command

Type of Feature Request

  • New feature
  • Enhancement

Type of Host

  • Public Canary
  • Public Stable
  • Self Hosted

Description

Add an unmate command, so a proper entry in the modlog is produced, so we can track mod actions even better

Images & Sketches

It should produce the same embed as a mute command, just with changed text

[BUG] creating docs directory with wrong permissions

Type of Bug

  • Spelling
  • Minor
  • Major
  • Crash

Description

The directory docs which is created on startup is created with permission setting 000, which does not allow accessing the directory to create the command manual (see logs).

Steps to Reproduce

  1. Start the bot

Images & Logs

console log

2019/01/21 16:06:05 ▶  ERRO 00008 Failed creating command manual:  open docs/commandsManual.md: permission denied

permissions

$ ls -lisah
total 14M
2494917 4.0K drwxr-xr-x  3 mgr mgr 4.0K Jan 21 16:06 .
2359310 4.0K drwxr-xr-x 30 mgr mgr 4.0K Jan 21 15:55 ..
2494920 4.0K -rw-r--r--  1 mgr mgr  337 Jan 21 15:58 config.yml
2494949 4.0K d---------  2 mgr mgr 4.0K Jan 21 16:06 docs
2494950  32K -rw-r--r--  1 mgr mgr  28K Jan 21 16:03 shinpuru.sqlite3.db
9443243  13M -rwxr-xr-x  1 mgr mgr  13M Jan 21 15:55 shinpuruCanary

[BUG] limit users in channel stats list and chart

Type of Bug

  • Spelling
  • Minor
  • Major
  • Crash

Type of Host

  • Public Canary
  • Public Stable
  • Self Hosted

Description

When too many users contributed to a channel, no details embed message is displayed and the chart is rendered useless.

Steps to Reproduce

Use the !chanstats command in a highly used channel.

Images & Logs

image

[BUG] no invite link recognition in edited messages

Type of Bug

  • Spelling
  • Minor
  • Major
  • Crash

Description

Describe the bug as clear and concise as possible.
Invite links embeded into messages tha twere send without an invite link and then edited with an invite link inside of the content, the message will not be removed.

[BUG] runtime panic on polling user permissions

Type of Bug

  • Spelling
  • Minor
  • Major
  • Crash

Type of Host

  • Public Canary
  • Public Stable
  • Self Hosted

Description

The runtime panic, as shown below, is caused when accessing the permission state of a specific user with no particular reason why it causes only for this specific user.

Steps to Reproduce

  1. Call https://sp.zekro.de/api/guilds/<GuildID>/<UserId>/permissions with valid credentials and access permissions
  2. Crash

It's also caused by using the command:

!info <UserId>

Images & Logs

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x7a4ed6]

goroutine 415 [running]:
github.com/zekroTJA/shinpuru/internal/util.sortRoleArray.func1(0x1, 0x0, 0xc000adb5a0)
 /build/internal/util/roles.go:48 +0x36
sort.insertionSort_func(0xc000adb628, 0xc00038cde0, 0x0, 0x2)
 /usr/local/go/src/sort/zfuncversion.go:12 +0xb1
sort.quickSort_func(0xc000adb628, 0xc00038cde0, 0x0, 0x2, 0x4)
 /usr/local/go/src/sort/zfuncversion.go:158 +0x1f3
sort.Slice(0xa85040, 0xc00038cdc0, 0xc000adb628)
 /usr/local/go/src/sort/slice.go:17 +0xf1
github.com/zekroTJA/shinpuru/internal/util.sortRoleArray(0xc00011f620, 0x2, 0x2, 0x0)
 /build/internal/util/roles.go:57 +0xd0
github.com/zekroTJA/shinpuru/internal/util.GetSortedMemberRoles(0xc0000c9040, 0xc00024710c, 0x12, 0xc00024711f, 0x12, 0x0, 0x7a2f6d, 0xc0003925e0, 0xc0010859e0, 0x12, ...)
 /build/internal/util/roles.go:30 +0x2bd
github.com/zekroTJA/shinpuru/internal/core/database.(*MySQL).GetMemberPermission(0xc0000a25c8, 0xc0000c9040, 0xc00024710c, 0x12, 0xc00024711f, 0x12, 0x0, 0x0, 0x40, 0xc000776e00, ...)
 /build/internal/core/database/mysql.go:261 +0xc4
github.com/zekroTJA/shinpuru/internal/commands.(*CmdHandler).GetPermissions(0xc0001fe240, 0xc0000c9040, 0xc00024710c, 0x12, 0xc00024711f, 0x12, 0x0, 0x0, 0xc000210120, 0x30, ...)
 /build/internal/commands/handler.go:120 +0xb6
github.com/zekroTJA/shinpuru/internal/webserver.(*WebServer).handlerGetPermissions(0xc0000ac1e0, 0xc0008caaf0, 0xc100000000b4d3e0, 0xc000d75a01)
 /build/internal/webserver/handlers.go:176 +0x1aa
github.com/qiangxue/fasthttp-routing.(*Context).Next(0xc0008caaf0, 0xb780de, 0x4)
 /go/pkg/mod/github.com/qiangxue/[email protected]/context.go:67 +0x69
github.com/zekroTJA/shinpuru/internal/webserver.(*WebServer).handlerFiles(0xc0000ac1e0, 0xc0008caaf0, 0x0, 0x0)
 /build/internal/webserver/helper.go:118 +0x28d
github.com/qiangxue/fasthttp-routing.(*Context).Next(0xc0008caaf0, 0xc000d75ba0, 0x3)
 /go/pkg/mod/github.com/qiangxue/[email protected]/context.go:67 +0x69
github.com/qiangxue/fasthttp-routing.(*Router).HandleRequest(0xc000357040, 0xc0007fef00)
 /go/pkg/mod/github.com/qiangxue/[email protected]/router.go:75 +0x262
github.com/valyala/fasthttp.(*Server).serveConn(0xc000244000, 0xc61b60, 0xc0000a2e08, 0x0, 0x0)
 /go/pkg/mod/github.com/valyala/[email protected]/server.go:2018 +0x6ab
github.com/valyala/fasthttp.(*workerPool).workerFunc(0xc0003a8fa0, 0xc0003123c0)
 /go/pkg/mod/github.com/valyala/[email protected]/workerpool.go:223 +0xc0
github.com/valyala/fasthttp.(*workerPool).getCh.func1(0xc0003a8fa0, 0xc0003123c0, 0xa78bc0, 0xc0003123c0)
 /go/pkg/mod/github.com/valyala/[email protected]/workerpool.go:195 +0x35
created by github.com/valyala/fasthttp.(*workerPool).getCh
 /go/pkg/mod/github.com/valyala/[email protected]/workerpool.go:194 +0x101

Potential Makefile typo?

firing 'make' on current git clone (per the instructions for self hosting) returns

'dep mod tidy
dep: mod: no such command
Dep is a tool for managing dependencies for Go projects

Usage: "dep [command]"
'

Should the line in the makefile calling '$DEP mod tidy' read '$GO mod tidy'?

cheers,

SM

[FEATURE] Switch from dep to go mod as dependency manager

Type of Feature Request

  • New feature
  • Enhancement

Description

Please describe your feature request as clear and concise as possible.

Go mod wil lbe the defautl dependency management for go projects in the next upcomming go versions, so this project should be converted from using dep to go mod to guarantee a smooth migration to later go versions.

[BACKSTAGE] refactor message embed api

Currently, embed messages which are shown and then being deleted automatically are implemented like this:

msg, err := util.SendEmbedError(args.Session, args.Channel.ID,
    "Sorry, but the entered role could not be fetched :(")
util.DeleteMessageLater(args.Session, msg, 5*time.Second)

This produces a lot of code duplication and can be simplified by using one endpoint function for self-deleting embeds.

[BUG] ghostping: check if the message was deleted by the bot

Type of Bug

  • Spelling
  • Minor
  • Major
  • Crash

Description

The bot sends a ghostping warning on deleting a mentioned message when the bot deleted the message.

Steps to Reproduce

Let the bot delete your mentioned message for example using the say command;

sp!say @zekro this will be warned also if not should be ;)

Say command runtime exception

If you pass an invalid JSON formated raw text on using say -raw <JSON>, the bot will exit with an runtime exception:

0|shinpuru  | panic: runtime error: invalid memory address or nil pointer dereference
0|shinpuru  | [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x734aa4]
0|shinpuru  | goroutine 99 [running]:
0|shinpuru  | github.com/zekroTJA/shinpuru/commands.(*CmdSay).Exec(0xc000022fc0, 0xc0000988c0, 0x12, 0xc000402b20)
0|shinpuru  |   /home/mgr/src/github.com/zekroTJA/shinpuru/commands/cmdsay.go:89 +0x364
0|shinpuru  | github.com/zekroTJA/shinpuru/listeners.(*ListenerCmds).Handler(0xc00000d000, 0xc0000a37a0, 0xc00000f5a0)
0|shinpuru  |   /home/mgr/src/github.com/zekroTJA/shinpuru/listeners/cmds.go:95 +0x653
0|shinpuru  | github.com/zekroTJA/shinpuru/listeners.(*ListenerCmds).Handler-fm(0xc0000a37a0, 0xc00000f5a0)
0|shinpuru  |   /home/mgr/src/github.com/zekroTJA/shinpuru/main.go:133 +0x3e
0|shinpuru  | github.com/bwmarrin/discordgo.messageCreateEventHandler.Handle(0xc000134550, 0xc0000a37a0, 0x79f080, 0xc00000f5a0)
0|shinpuru  |   /home/mgr/src/github.com/bwmarrin/discordgo/eventhandlers.go:497 +0x57
0|shinpuru  | created by github.com/bwmarrin/discordgo.(*Session).handle
0|shinpuru  |   /home/mgr/src/github.com/bwmarrin/discordgo/event.go:171 +0x111

[FEATURE] Code execution doesn't recognize edited messages

Type of Bug

  • Spelling
  • Minor
  • Major
  • Crash

Description

Describe the bug as clear and concise as possible.
When you send a message in a code block shinpuru adds a reaction to this message. All good until now. When you then edit the code inside the message and click the reaction the bot executes the old code as it was before the message was edited

Steps to Reproduce

Enter stepwise how to reproduce the bug.

  • Go to a chat shinpuru has access to (obviously)
  • Send a simple code block
  • Edit that code block in a noticeable way
  • Click on the reaction shinpuru added
  • Profit

Images & Logs

Here you can embed images or crash logs or command lines.
Please use embedded markdown images and code blocks for that.
Picture that is showing the bug

[BUG] I can mute my self

Type of Bug

  • [X ] Minor

Description

It is not checked whether the person who is muted has the same rights and whether the person is himself. Or short: I can mute my self.

Steps to Reproduce

spc!mute @Yourusername

Images & Logs

image

[BUG/ENHANCEMENT] Hide Moderation Buttons for Admins

Type of Bug

  • Spelling
  • Minor
  • Major
  • Crash

Description

Users with admin rights are not bannable for the bot. You'd have to remove the permissions in order to kick/ban the user. That's why on the webinterface, the "Kick" and "Ban" buttons should be hidden for users that can't be kicked/banned.

Images & Logs

image

user command date issue

Using the user <userResolvable> command to some users results to following error message:

[FEATURE] Codeblock Execution Ratelimit and/or check

Type of Feature Request

  • New feature
  • Enhancement

Description

Since there were recent abuses with the inline Discord Code blocks execution and you got a rate limit of 200 executions/mo., I suggest limiting the executions for each user to a certain number, e.g. 10.
Another good thing to have would be a command, whith which Moderators and Admins can see, who had the most executions for this month.

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.