Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lucapasquale/botchini
Discord bot with Twitch integration
https://github.com/lucapasquale/botchini
discord discord-bot elixir twitch youtube
Last synced: about 2 months ago
JSON representation
Discord bot with Twitch integration
- Host: GitHub
- URL: https://github.com/lucapasquale/botchini
- Owner: lucapasquale
- Created: 2021-02-26T23:14:09.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-20T20:27:43.000Z (3 months ago)
- Last Synced: 2024-10-22T10:26:03.977Z (3 months ago)
- Topics: discord, discord-bot, elixir, twitch, youtube
- Language: Elixir
- Homepage: https://botchini.luca.codes
- Size: 1020 KB
- Stars: 10
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Botchini
Discord Bot with Twitch and YouTube integrations for creator notifications!
Get messages when a Twitch user starts streaming, or when a YouTube channel posts a new video or starts a live.
Uses modern features like [Slash Commands](https://blog.discord.com/slash-commands-are-here-8db0a385d9e6?gi=cb5c18566e7) and [Message Components](https://discord.com/developers/docs/interactions/message-components)
## [Add it to your server](https://discord.com/api/oauth2/authorize?client_id=814896826569195561&permissions=2048&scope=bot%20applications.commands)
![image](https://user-images.githubusercontent.com/15659967/121437344-89bb7180-c958-11eb-9d2f-034cf8b5f179.png)
## Slash Commands
- Common
- `/about` : Bot status with uptime, memory usage and more
- Creators
- `/info ` : Information about a Twitch user or YouTube channel
- `/follow ` : Follow a creator and get notified when it starts streaming or uploads a video
- `/unfollow ` : Stops following a creator
- `/list` : Lists all creators being followed on the server
- Music
- `/play `: Play a song from YouTube
- `/pause`: Pauses current song
- `/resume`: Resumes current song
- `/skip`: Skips current song
- `/stop`: Stops playing and clears the queue
- `/queue`: Lists current songs in queue## Installation
Copy the sample environment sample file into a secrets file:
```bash
cat config/dev.secret-sample.exs > config/dev.secret.exs
```Run `mix setup` to install all dependencies and run the database migrations
### Host
For receiving and registering to webhooks locally, you need a public url that can reach your machine. You can use start a proxy with [ngrok http $PORT](https://ngrok.com/), then copy the url generated into the `:host` config.
### Discord
Grab your bot's token from [Discord Applications](https://discord.com/developers/applications) on `Your application > Bot > Click to reveal token`
### YouTube
Create an account on [Google Cloud Platform](https://console.cloud.google.com), and create a new API Key for your bot. You can limit the key to only have access to `YouTube Data API v3`
Example webhook payload
```xml
YouTube video feed
2024-05-17T01:37:49.636216015+00:00
yt:video:TBXAlFqn93E
TBXAlFqn93E
UCHDxYLv8iovIbhrfl16CNyg
I wish this wasn’t an Ubisoft game
GameLinked
https://www.youtube.com/channel/UCHDxYLv8iovIbhrfl16CNyg
2024-05-17T01:37:38+00:00
2024-05-17T01:37:49.636216015+00:00
```### Twitch
To be able to search and receive webhooks from streams, you need to register an application on the [Twitch Applications](https://dev.twitch.tv/console/apps). After that, you'll be able to get the `client_id` and `client_secret` tokens.
Example webhook payload
```json
{
"challenge":"6gepqopldUA-K7p_CJDK3gmndD6mxyxjWSS7wCTFxZ8",
"subscription":{
"id":"3ce498e8-44d4-446f-886c-66bc256af5d9",
"status":"webhook_callback_verification_pending",
"type":"stream.online",
"version":"1",
"condition":{
"broadcaster_user_id":"35958947"
},
"transport":{
"method":"webhook",
"callback":"https://botchini.lucapasquale.dev/api/twitch/webhooks/callback"
},
"created_at":"2024-05-17T01:46:52.47828845Z",
"cost":1
}
}
```## Running locally
After all necessary values are on `config/dev.secret.exs`, run the bot with: `mix phx.server`. It will reload automatically when you update a file.
## Running in production
The bot needs the following env_vars:
- `PORT` : Port to run on. Defaults to 4000
- `PHX_HOST` : The endpoint your bot is running on, without `https://`
- `DATABASE_URL` : The url to connect to your postgres db
- `DISCORD_TOKEN` : Token for your Discord Bot
- `YOUTUBE_API_KEY` : YouTube API key
- `YOUTUBE_WEBHOOK_SECRET` : Secret string to be used for validating YouTube webhooks
- `TWITCH_CLIENT_ID` : Client ID for your Twitch application
- `TWITCH_CLIENT_SECRET` : Client Secret for your Twitch application
- `TWITCH_WEBHOOK_SECRET` : Secret string to be used for validating Twitch webhooks