Skip to content

Commit

Permalink
Merge pull request #357 from TomRomeo/master
Browse files Browse the repository at this point in the history
add auto voicechannel feature
  • Loading branch information
zekroTJA authored Feb 22, 2022
2 parents b916ca5 + fefc822 commit 19cb9d2
Show file tree
Hide file tree
Showing 17 changed files with 565 additions and 54 deletions.
50 changes: 13 additions & 37 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,29 @@
[VERSION]

<!-- > **Attention**
> This is a hotfix patch for issue #332. If you want to see the changelog for release 1.26.0, please look [**here**](https://github.com/zekroTJA/shinpuru/releases/tag/1.27.0). -->
> This is a hotfix patch. If you want to see the changelog for release 1.30.0, please look [**here**](https://github.com/zekroTJA/shinpuru/releases/tag/1.30.0). -->

# Birthday Notifications [#349]
# New Login Method

shinpuru now features birthday notifications!
On the main page, when clicking on `Login`, you can now choose between logging in to the web interface via OAauth2 using your Discord account or log in via sending the code, which is displayed in the web interface, to shinpuru via DM.

![](https://user-images.githubusercontent.com/16734205/153576590-28b51ce9-e11f-4aa1-b86b-41fc7d6d6a31.gif)
![](https://user-images.githubusercontent.com/16734205/154697491-b0aa34d3-ff79-40ee-9b49-ec77cfc23cee.gif)

Simply, set your birthday using the `/birthday set` slash command. The date must be in the format `YYYY-MM-DD[+-]TIMEZONE`. You can also use `/` or `.` as separator. The timezone must be set to your local time zone in offset hours from UTC. So, for example, for `CET` this would be `+1`, for `EST`, this would be `-5` and so on.
# Deployment

It is also possible to just set a month and day if you don't want to store your birth year. If you want to show your age in the notification, you can enable it by setting `show-year` to `True`. Otherwise, your age will be hidden in the notification.
The generated frontend files are now directly embedded into the binary of shinpuru. Therefore, downloading and providing the frontend files in the same directory of the binary is no more necessary.

![](https://user-images.githubusercontent.com/16734205/153576393-73616bd2-b21d-4813-bdb8-ad146cecc542.png)

*With age hidden, it would look like this.*
![](https://user-images.githubusercontent.com/16734205/153580431-e5a0f4b9-1b51-473f-bfa4-40c3fa650c89.gif)

You can, of course, also unset your birthday at any time.

![](https://user-images.githubusercontent.com/16734205/153577075-e191e2d8-1e39-4ab4-9a24-31e5939d887f.png)

To enable birthday notifications in your guild, you need to specify a birthday channel. This requires the permission `sp.guild.config.birthday`

![](https://user-images.githubusercontent.com/16734205/153576456-9c184ae0-4408-4ded-9dce-9f69ee36f5e9.png)

To unset this setting, simply use the `/birthday unset-cannel` command.

To enable Gifs in the birthday message, the bot needs a Giphy API key. You can get one by creating a Giphy acount and going to the [Developer Dashboard](https://developers.giphy.com/dashboard/). There you can create an app. After that, copy the API key and add it ti shinpuru's config.
```yaml
giphy:
apikey: dWl3ZXF6diBzZGR0NnczNDg5NTZuZG4w
```
# Sharding [#238]
If you are running shinpuru of a lot of Guilds, you might want to split up your single instance into multiple instances to split up the load. This is now possible using Discord's Gateway sharding.
> I **strongly** recommend taking a look into [Discord's Documentation](https://discord.com/developers/docs/topics/gateway#sharding) about sharding when you want to split up your instance.
# Bug Fixes

You can simply spin up multiple instances of shinpuru behind a load balancer which all connect to the same database and redis instance. This distributes a common synced persistent state between all instances.
- The birtdhay command will now only send command responses to the user who invoked the command. [#354]
- The embed builder now only shows available text channels where the logged in user has read and write permissions. [#353]
- The embed preview now shows a placeholder title and description when empty. [#353]

If you want to set up sharding and load balancing, you can find more information on how to set up and configure shinpuru [**here**](https://github.com/zekroTJA/shinpuru/tree/dev/docs/sharding). There you can also find an example deploymet using docker swarm.
# Acknowledgements

# Bug Fixes
Big thanks to the following people who contributed to this release.

- Fix a bug where guild settings were not saved to database.
- Properly bubble up errors when setting guild settings.
- @zordem

# Docker

Expand Down
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ shinpuru mainly uses MySQL/MariaDB as database. You *can* also use SQLite3 for d
- Linux: https://opensource.com/article/20/10/mariadb-mysql-linux
- Docker: https://hub.docker.com/_/mariadb/

Redis is used as database cache. The [`RedisMiddleware`](https://github.com/zekroTJA/shinpuru/blob/master/internal/services/database/redis/redis.go) generaly inherits functionalities from the specified database middleware instance and only overwrites using the specified functions. The database cache always keeps the cache as well as the database hot and always first tries to get objects from cache and, if not available there, from database.
Redis is used as database cache. The [`RedisMiddleware`](https://github.com/zekroTJA/shinpuru/blob/master/internal/services/database/redis/redis.go) generally inherits functionalities from the specified database middleware instance and only overwrites using the specified functions. The database cache always keeps the cache as well as the database hot and always first tries to get objects from cache and, if not available there, from database.

![](https://i.imgur.com/TgkuhUY.png)

Expand All @@ -65,7 +65,7 @@ If you want to add API endpoints, just add the endpoints to one of the controlle

Also, fiber works a lot with middlewares, which can be chained anywhere into the fiber route chain. In shinpuru's implementation, there are three main types of middlewares.
1. The high level middlewares like the rate limiter, CORS or file system middleware, which are set before all incomming requests.
2. Controller specific middlewares which are defined in the router. Mainly, this is used for the authorizeation middleware, which checks for auth tokens in the requests. This middleware is required by some controllers and not required for others.
2. Controller specific middlewares which are defined in the router. Mainly, this is used for the authorization middleware, which checks for auth tokens in the requests. This middleware is required by some controllers and not required for others.
3. Endpoint specific middlewares which are defined for specific endpoints only. Mainly, this is used for the permission middleware which checks for required user permissions to execute specific endpoints.

Here you can see a simple overview over the routing structure of the shinpuru webserver.
Expand Down Expand Up @@ -98,7 +98,7 @@ As you can see, all service identifiers are registered in the [`internal/util/st

After building the `diBuilder`, you will have a `di.Container` to work with where you can get any service registered. Because all services are registered in the `App` scope, once they are initialized, all requests are getting the same instance of the service. This makes service development very easy, because every service is getting passed the same service container and every service can grab the instance of any other registered service instance.

When you want to use a service, just take it from the passed service conatiner by the specified identifier. Let's take a look at the [`starboard` listener](https://github.com/zekroTJA/shinpuru/blob/master/internal/listeners/starboard.go) , for example:
When you want to use a service, just take it from the passed service container by the specified identifier. Let's take a look at the [`starboard` listener](https://github.com/zekroTJA/shinpuru/blob/master/internal/listeners/starboard.go), for example:

```go
func NewListenerStarboard(container di.Container) *ListenerStarboard {
Expand Down Expand Up @@ -134,7 +134,7 @@ This package is using a [crontab styled syntax](https://pkg.go.dev/github.com/ro

The shinpuru web frontend is a compiled [**Angular**](https://angular.io) SPA, which is directly hosted form the shinpuru web server. The source files are located at [`/web`](https://github.com/zekroTJA/shinpuru/blob/master/web) Stylesheets are written in [**SCSS**](https://sass-lang.com/documentation/syntax) because SCSS has huge advantages to default CSS like nesting, mixins and variables, which are widely used in stylesheets.

The Angular web app is built like a typical Angular application with reusable components, routes, services and pipes. The communication with the REST API is handled by the [`APIService`](https://github.com/zekroTJA/shinpuru/blob/master/web/src/app/api/api.service.ts). API models are specified in the [`api.models.ts`](https://github.com/zekroTJA/shinpuru/blob/master/web/src/app/api/api.models.ts) file. Also, the API stores some objects like member information in a [`CacheBucket`](https://github.com/zekroTJA/shinpuru/blob/master/web/src/app/api/api.cache.ts) for short-time caching them on the client side to reduce the load on the REST API. Also, an [interceptor](https://github.com/zekroTJA/shinpuru/blob/master/web/src/app/api/auth.interceptor.ts) is chained before the API service which adds the collected `accessToken` to each reqeust. If the `accessToken` is not existent, expired or invalid, the `accessToken` will be collected using the `refreshToken` set as cookie. The access token is then stored and the request is retried with the now existent access token.
The Angular web app is built like a typical Angular application with reusable components, routes, services and pipes. The communication with the REST API is handled by the [`APIService`](https://github.com/zekroTJA/shinpuru/blob/master/web/src/app/api/api.service.ts). API models are specified in the [`api.models.ts`](https://github.com/zekroTJA/shinpuru/blob/master/web/src/app/api/api.models.ts) file. Also, the API stores some objects like member information in a [`CacheBucket`](https://github.com/zekroTJA/shinpuru/blob/master/web/src/app/api/api.cache.ts) for short-time caching them on the client side to reduce the load on the REST API. Also, an [interceptor](https://github.com/zekroTJA/shinpuru/blob/master/web/src/app/api/auth.interceptor.ts) is chained before the API service which adds the collected `accessToken` to each request. If the `accessToken` is not existent, expired or invalid, the `accessToken` will be collected using the `refreshToken` set as cookie. The access token is then stored and the request is retried with the now existent access token.

## Preparing a Development Environment

Expand All @@ -160,4 +160,4 @@ So, you want to contribute to shinpuru but you don't know what exactly you want

## Any Questions?

If you have any questions, please hit me on my [**Dev Discord**](https://discord.zekro.de) (`zekro#0001`) or on [**Twitter**](https://twitter.com/zekrotja). You can also simply send me an [e-mail](mailto:contact@zekro.de). 😉
If you have any questions, please hit me on my [**Dev Discord**](https://discord.zekro.de) (`zekro#0001`) or on [**Twitter**](https://twitter.com/zekrotja). You can also simply send me an [e-mail](mailto:contact@zekro.de). 😉
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ The code is picked up and sent to a code execution engine, which safely executes

### Karma

shinpuru featues 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.
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.

Expand Down Expand Up @@ -147,7 +147,7 @@ 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 reate. 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 allerted 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.
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](https://user-images.githubusercontent.com/16734205/140644018-9652d8c9-2716-43ae-bf5b-c1b2c17f895a.png)

Expand Down
6 changes: 3 additions & 3 deletions bughunters.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

A list to honor all people who found some bugs, had some great ideas or contributed directly to shinpuru. ❤️

In total, **31** different wonderful people contributed a sum of **73** issues and **14** pull requests (with 631 added and 81 deleted lines of code in 46 different files)! 🎉
In total, **31** different wonderful people contributed a sum of **75** issues and **17** pull requests (with 645 added and 95 deleted lines of code in 51 different files)! 🎉

| GitHub | Issues | PRs | Points* |
|--------|--------|-----|---------|
| 🥇 [SnowJuli](https://github.com/SnowJuli) | [#129](https://github.com/zekroTJA/shinpuru/issues/129), [#145](https://github.com/zekroTJA/shinpuru/issues/145), [#169](https://github.com/zekroTJA/shinpuru/issues/169), [#202](https://github.com/zekroTJA/shinpuru/issues/202), [#231](https://github.com/zekroTJA/shinpuru/issues/231), [#276](https://github.com/zekroTJA/shinpuru/issues/276) | [#175](https://github.com/zekroTJA/shinpuru/pull/175), [#176](https://github.com/zekroTJA/shinpuru/pull/176), [#178](https://github.com/zekroTJA/shinpuru/pull/178), [#285](https://github.com/zekroTJA/shinpuru/pull/285), [#298](https://github.com/zekroTJA/shinpuru/pull/298), [#305](https://github.com/zekroTJA/shinpuru/pull/305) | `24` |
| 🥈 [voxain](https://github.com/voxain) | [#52](https://github.com/zekroTJA/shinpuru/issues/52), [#61](https://github.com/zekroTJA/shinpuru/issues/61), [#67](https://github.com/zekroTJA/shinpuru/issues/67), [#147](https://github.com/zekroTJA/shinpuru/issues/147), [#148](https://github.com/zekroTJA/shinpuru/issues/148), [#150](https://github.com/zekroTJA/shinpuru/issues/150), [#153](https://github.com/zekroTJA/shinpuru/issues/153), [#159](https://github.com/zekroTJA/shinpuru/issues/159), [#163](https://github.com/zekroTJA/shinpuru/issues/163), [#165](https://github.com/zekroTJA/shinpuru/issues/165), [#183](https://github.com/zekroTJA/shinpuru/issues/183), [#187](https://github.com/zekroTJA/shinpuru/issues/187), [#203](https://github.com/zekroTJA/shinpuru/issues/203), [#210](https://github.com/zekroTJA/shinpuru/issues/210), [#249](https://github.com/zekroTJA/shinpuru/issues/249), [#250](https://github.com/zekroTJA/shinpuru/issues/250) | | `16` |
| 🥉 [error2507](https://github.com/error2507) | [#28](https://github.com/zekroTJA/shinpuru/issues/28), [#29](https://github.com/zekroTJA/shinpuru/issues/29), [#55](https://github.com/zekroTJA/shinpuru/issues/55) | [#1](https://github.com/zekroTJA/shinpuru/pull/1), [#2](https://github.com/zekroTJA/shinpuru/pull/2) | `9` |
| [Ron31](https://github.com/Ron31) | [#197](https://github.com/zekroTJA/shinpuru/issues/197), [#224](https://github.com/zekroTJA/shinpuru/issues/224) | [#32](https://github.com/zekroTJA/shinpuru/pull/32), [#181](https://github.com/zekroTJA/shinpuru/pull/181) | `8` |
| [SCDerox](https://github.com/SCDerox) | [#280](https://github.com/zekroTJA/shinpuru/issues/280) | [#352](https://github.com/zekroTJA/shinpuru/pull/352), [#355](https://github.com/zekroTJA/shinpuru/pull/355) | `7` |
| [ShowMeYourSkil](https://github.com/ShowMeYourSkil) | [#140](https://github.com/zekroTJA/shinpuru/issues/140), [#171](https://github.com/zekroTJA/shinpuru/issues/171), [#191](https://github.com/zekroTJA/shinpuru/issues/191), [#192](https://github.com/zekroTJA/shinpuru/issues/192), [#211](https://github.com/zekroTJA/shinpuru/issues/211), [#240](https://github.com/zekroTJA/shinpuru/issues/240) | | `6` |
| [Skillkiller](https://github.com/Skillkiller) | [#180](https://github.com/zekroTJA/shinpuru/issues/180), [#270](https://github.com/zekroTJA/shinpuru/issues/270), [#284](https://github.com/zekroTJA/shinpuru/issues/284) | [#79](https://github.com/zekroTJA/shinpuru/pull/79) | `6` |
| [zordem](https://github.com/zordem) | [#346](https://github.com/zekroTJA/shinpuru/issues/346), [#353](https://github.com/zekroTJA/shinpuru/issues/353), [#354](https://github.com/zekroTJA/shinpuru/issues/354) | [#351](https://github.com/zekroTJA/shinpuru/pull/351) | `6` |
| [Not-Nik](https://github.com/Not-Nik) | [#53](https://github.com/zekroTJA/shinpuru/issues/53) | [#56](https://github.com/zekroTJA/shinpuru/pull/56) | `4` |
| [cloudybyte](https://github.com/cloudybyte) | [#179](https://github.com/zekroTJA/shinpuru/issues/179), [#195](https://github.com/zekroTJA/shinpuru/issues/195), [#219](https://github.com/zekroTJA/shinpuru/issues/219), [#241](https://github.com/zekroTJA/shinpuru/issues/241) | | `4` |
| [luxtracon](https://github.com/luxtracon) | [#248](https://github.com/zekroTJA/shinpuru/issues/248) | [#228](https://github.com/zekroTJA/shinpuru/pull/228) | `4` |
Expand All @@ -32,10 +34,8 @@ In total, **31** different wonderful people contributed a sum of **73** issues a
| [maxcutie](https://github.com/maxcutie) | [#239](https://github.com/zekroTJA/shinpuru/issues/239) | | `1` |
| [PushkarOP](https://github.com/PushkarOP) | [#269](https://github.com/zekroTJA/shinpuru/issues/269) | | `1` |
| [enkeyz](https://github.com/enkeyz) | [#279](https://github.com/zekroTJA/shinpuru/issues/279) | | `1` |
| [SCDerox](https://github.com/SCDerox) | [#280](https://github.com/zekroTJA/shinpuru/issues/280) | | `1` |
| [MeerBiene](https://github.com/MeerBiene) | [#308](https://github.com/zekroTJA/shinpuru/issues/308) | | `1` |
| [shiipou](https://github.com/shiipou) | [#317](https://github.com/zekroTJA/shinpuru/issues/317) | | `1` |
| [zordem](https://github.com/zordem) | [#346](https://github.com/zekroTJA/shinpuru/issues/346) | | `1` |
| [kindh0623](https://github.com/kindh0623) | [#348](https://github.com/zekroTJA/shinpuru/issues/348) | | `1` |


Expand Down
Loading

0 comments on commit 19cb9d2

Please sign in to comment.