Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Discord support #268

Merged
merged 1 commit into from
Oct 6, 2020
Merged

Conversation

codenio
Copy link
Contributor

@codenio codenio commented Apr 29, 2020

ISSUE TYPE

  • Feature Pull Request
SUMMARY

Add support for Discord:

This PR,

  • adds discord bot
  • adds discord notifier
  • adds required discord configurations into comm_config.yaml
  • adds discordgo module into go.mod
  • adds discord configs into all yaml files

Fixes #97

Steps For Creation and Integration:

  1. Reach https://discordapp.com/developers/applications

  2. Create New Application named Botkube and add a bot named Botkube into the Application

  3. Copy the Application CLIENT ID and place it under Dischord.botid in comm-config.yaml

  4. Copy Bot TOKEN and place it under Dischord.token in comm-config.yaml

  5. Generate the URL with suitable permissions using the OAuth2 URL Generator available under OAuth2 section to the add bot to your Discord server

https://discordapp.com/oauth2/authorize?&client_id=<YOUR_CLIENT_ID>&scope=bot&permissions=<SET_OF_PERMISSIONS>
  1. Paste the generated URL in a new tab, select the discord sever to which you want to add the bot and Authorise Bot addition.
  2. Create a new channel and/or copy the CHANNEL ID of an existing one that you want to use and place it under Dischord.channel
  # Settings for Discord
  discord:
    enabled: true
    token: 'DISCORD_TOKEN'	    # BotKube Bot Token 
    botid: 'DISCORD_BOT_ID'         # BotKube Application Client ID 
    channel: 'DISCORD_CHANNEL_ID'   # Discord Channel id for receiving BotKube alerts 
    notiftype: short                # Change notification type short/long you want to receive. notiftype is optional and Default notification type is short (if not specified)

Note: Follow the first 4 mins of this Video Tutorial to understand the process visually.

Preview:

ping
pod-create-short
pod-error-long
file-attachment

@sanketsudake sanketsudake added the enhancement New feature or request label May 1, 2020
cmd/botkube/main.go Outdated Show resolved Hide resolved
pkg/bot/discord.go Outdated Show resolved Hide resolved
pkg/notify/discord.go Outdated Show resolved Hide resolved
pkg/notify/discord.go Outdated Show resolved Hide resolved
@codenio codenio force-pushed the feature/discord-integration branch from eb04291 to a1adfee Compare May 1, 2020 05:53
pkg/bot/discord.go Show resolved Hide resolved
pkg/bot/discord.go Outdated Show resolved Hide resolved
pkg/bot/discord.go Outdated Show resolved Hide resolved
pkg/bot/discord.go Outdated Show resolved Hide resolved
pkg/bot/discord.go Outdated Show resolved Hide resolved
pkg/bot/discord.go Outdated Show resolved Hide resolved
pkg/notify/discord.go Outdated Show resolved Hide resolved
@PrasadG193
Copy link
Collaborator

@codenio can we add integration tests?

@codenio codenio force-pushed the feature/discord-integration branch 6 times, most recently from 1861b0b to 86f0612 Compare May 2, 2020 11:47
@codenio
Copy link
Contributor Author

codenio commented May 2, 2020

added discord configs into all yaml files

@PrasadG193
Copy link
Collaborator

PrasadG193 commented May 6, 2020

@codenio The CI job is failing with

Step 9/17 : RUN GOOS=${GOOS_VAL} GOARCH=${GOARCH_VAL} go build -o /go/bin/botkube ./cmd/botkube
 ---> Running in 3dcedf3fac47
# github.com/docker/docker/pkg/term
exec: "gcc": executable file not found in $PATH
The command '/bin/sh -c GOOS=${GOOS_VAL} GOARCH=${GOARCH_VAL} go build -o /go/bin/botkube ./cmd/botkube' returned a non-zero code: 2
Makefile:39: recipe for target 'container-image' failed
make: *** [container-image] Error 2
The command "make container-image" exited with 2.

I think the docker dep you added needs gcc. Can you please update travis config to add gcc dep?

@codenio codenio force-pushed the feature/discord-integration branch 5 times, most recently from c5efd84 to b7f39af Compare July 1, 2020 08:03
@codenio
Copy link
Contributor Author

codenio commented Jul 1, 2020

@PrasadG193, resolved the build issue and rebased this PR to develop.
can this be merged?

@codenio codenio force-pushed the feature/discord-integration branch from b7f39af to a3ff62f Compare July 1, 2020 13:17
@kingdevnl
Copy link
Contributor

I guess this has to be rebased again soon?

@codenio codenio force-pushed the feature/discord-integration branch 2 times, most recently from 0934042 to 4e0e433 Compare July 28, 2020 05:34
@codenio
Copy link
Contributor Author

codenio commented Jul 28, 2020

rebased and resolved issues

@unixfox
Copy link

unixfox commented Jul 28, 2020

Can this PR get reviewed again or/and merged? I'm using it on my own k8s cluster and it's working pretty well!

@codenio Seriously good job.

@unixfox
Copy link

unixfox commented Jul 28, 2020

I just found an odd bug.
I'm able to ping/send commands to the bot through the desktop Discord client but not on the Android Discord client.
Capturebotkube
The first message is from the Android Discord client and the second is from the desktop Discord client.

@codenio Could you try to replicate the bug by sending a ping to your botkube from your Android Discord client?

@kingdevnl
Copy link
Contributor

How would i install the version of the PR onto a kube cluster?

@kingdevnl
Copy link
Contributor

I tried to get it to run,

But gettings this error...

panic: http: multiple registrations for /metrics

goroutine 38 [running]:
net/http.(*ServeMux).Handle(0x3489840, 0x1d1852b, 0x8, 0x216d180, 0xc0002c71d0)
/usr/local/go/src/net/http/server.go:2391 +0x29c
net/http.Handle(...)
/usr/local/go/src/net/http/server.go:2434
github.com/infracloudio/botkube/pkg/metrics.ServeMetrics(0x1d0fdda, 0x4)
/app/pkg/metrics/metrics.go:29 +0x5f
created by main.startController
/app/cmd/botkube/main.go:81 +0x13d

@unixfox
Copy link

unixfox commented Jul 28, 2020

@kingdevnl I think something is broken in the develop branch of botkube.
If you use this commit it will work: a3ff62f

I have a docker image already built with that commit if you want to test:

@onedr0p
Copy link

onedr0p commented Aug 7, 2020

@PrasadG193 are unit tests really holding up adding new notifier integrations, specifically this one? I understand tests are important, however they can always be added later on.

@codenio codenio force-pushed the feature/discord-integration branch from 2a33846 to b5b3a25 Compare August 7, 2020 11:53
@codenio
Copy link
Contributor Author

codenio commented Aug 7, 2020

resolved it. can you check now..?

@unixfox
Copy link

unixfox commented Aug 7, 2020

Yes it's working without any error. Thank you!

@onedr0p
Copy link

onedr0p commented Aug 7, 2020

Working great on mobile now too with @unixfox docker image. Thanks you two!

@onedr0p
Copy link

onedr0p commented Sep 4, 2020

Any update here from the maintainers? I've been using a docker image built from this PR for a month now and it works great.

@PrasadG193 MS team support was merged without integration tests, can this be too, please?

@PrasadG193
Copy link
Collaborator

@codenio We can target and get this in in upcoming release. Could you please take a stab at adding documentation? We use hugo for hosting docs. The docs repo is: https://github.com/infracloudio/botkube-docs

@PrasadG193
Copy link
Collaborator

We have improved test coverage for the notifier interface. For discord bot interface tests, we can revisit this later.

@codenio codenio force-pushed the feature/discord-integration branch from b5b3a25 to f748cf2 Compare October 1, 2020 16:23
@codenio
Copy link
Contributor Author

codenio commented Oct 2, 2020

@PrasadG193 will certainly add corresponding docs, can we get this PR merged now..?

@codenio codenio force-pushed the feature/discord-integration branch from f748cf2 to a59ef56 Compare October 2, 2020 08:44
@codenio codenio mentioned this pull request Oct 2, 2020
comm_config.yaml Outdated Show resolved Hide resolved
comm_config.yaml Outdated Show resolved Hide resolved
deploy-all-in-one-tls.yaml Outdated Show resolved Hide resolved
pkg/bot/discord.go Outdated Show resolved Hide resolved
pkg/bot/discord.go Show resolved Hide resolved
@codenio codenio force-pushed the feature/discord-integration branch 3 times, most recently from 8d1e519 to dc5aeaf Compare October 5, 2020 10:07
deploy-all-in-one-tls.yaml Outdated Show resolved Hide resolved
deploy-all-in-one.yaml Outdated Show resolved Hide resolved
helm/botkube/values.yaml Outdated Show resolved Hide resolved
test/comm_config.yaml Outdated Show resolved Hide resolved
@codenio codenio force-pushed the feature/discord-integration branch 3 times, most recently from 5ed968f to d1c864b Compare October 6, 2020 02:56
This commit,
- adds discord bot
- adds discord notifier
- adds required discord configurations into comm_config.yaml
- adds discordgo module into go.mod
- adds discord configs into all yaml files
- adds apk add build-base into dockerfile Build Env
@codenio codenio force-pushed the feature/discord-integration branch from d1c864b to 80522a4 Compare October 6, 2020 03:26
@mergify mergify bot merged commit ad9a738 into kubeshop:develop Oct 6, 2020
@codenio
Copy link
Contributor Author

codenio commented Oct 6, 2020

🙏 , feeling relieved., @ALL thanks for the extended support, thanks @PrasadG193 and @sanketsudake for the reviews and feedbacks.

@PrasadG193
Copy link
Collaborator

Thanks for all the hard work and patience @codenio

@kingdevnl
Copy link
Contributor

Realy thanks man <3

@unixfox unixfox mentioned this pull request Oct 6, 2020
PrasadG193 pushed a commit to PrasadG193/botkube that referenced this pull request Aug 9, 2021
#### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Feature Pull Request

##### SUMMARY
<!--- Describe the change, including rationale and design decisions -->

**Add support for Discord:**

This PR,
- adds discord bot
- adds discord notifier
- adds required discord configurations into comm_config.yaml
- adds discordgo module into go.mod
- adds discord configs into all yaml files

<!---
If you are fixing an existing issue, please include "Fixes #nnn" in your
PR comment; and describe briefly what the change does.
-->

<!--- Please list dependencies added with your change also -->

Fixes kubeshop#97 


### Steps For Creation and Integration:

1. Reach https://discordapp.com/developers/applications 

2. Create New Application named Botkube and add a bot named **Botkube** into the Application

3. Copy the Application **CLIENT ID** and place it under _Dischord.botid_ in comm-config.yaml

4. Copy Bot **TOKEN** and place it under _Dischord.token_ in comm-config.yaml
 
5. Generate the URL with suitable permissions using the OAuth2 URL Generator available under OAuth2 section to the add bot to your Discord server
```
https://discordapp.com/oauth2/authorize?&client_id=<YOUR_CLIENT_ID>&scope=bot&permissions=<SET_OF_PERMISSIONS>
```
6. Paste the generated URL in a new tab, select the discord sever to which you want to add the bot and Authorise Bot addition.
7. Create a new channel and/or copy the  **CHANNEL ID** of an existing one that you want to use and place it under _Dischord.channel_

```yaml
  # Settings for Discord
  discord:
    enabled: true
    token: 'DISCORD_TOKEN'	    # BotKube Bot Token 
    botid: 'DISCORD_BOT_ID'         # BotKube Application Client ID 
    channel: 'DISCORD_CHANNEL_ID'   # Discord Channel id for receiving BotKube alerts 
    notiftype: short                # Change notification type short/long you want to receive. notiftype is optional and Default notification type is short (if not specified)
```

####  Note: Follow the first 4 mins of this [Video Tutorial](https://youtu.be/8o25pRbXdFw) to understand the process visually.

### Preview:

![ping](https://user-images.githubusercontent.com/30741615/80600577-3931cf00-8a4a-11ea-9215-a725a0b17256.png)
![pod-create-short](https://user-images.githubusercontent.com/30741615/80600638-55357080-8a4a-11ea-976f-b91e823c93bd.png)
![pod-error-long](https://user-images.githubusercontent.com/30741615/80600803-8dd54a00-8a4a-11ea-90e4-a205e93aba5f.png)
![file-attachment](https://user-images.githubusercontent.com/30741615/80600724-75fdc600-8a4a-11ea-9b10-1b5ac0e79548.png)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Discordapp
6 participants