Merge pull request #1 from Confrerie-du-Kassoulait/dev-docker
Adding DockerHub Support
This commit is contained in:
commit
9f5f37d579
7 changed files with 46 additions and 20 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,5 +1,5 @@
|
||||||
|
.vscode/
|
||||||
update/
|
update/
|
||||||
.dockerignore
|
.dockerignore
|
||||||
Dockerfile
|
src/tokens.env
|
||||||
src/tokens.py
|
|
||||||
src/cogs/music_old.py
|
src/cogs/music_old.py
|
||||||
|
|
13
Dockerfile
Normal file
13
Dockerfile
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
FROM python:3.8.6-slim
|
||||||
|
|
||||||
|
RUN apt update && \
|
||||||
|
apt install -y --no-install-recommends ffmpeg git && \
|
||||||
|
apt autoremove
|
||||||
|
RUN /usr/local/bin/python -m pip install --upgrade pip
|
||||||
|
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
|
COPY src .
|
||||||
|
|
||||||
|
CMD [ "python", "-u", "./main.py" ]
|
21
README.md
21
README.md
|
@ -4,25 +4,28 @@
|
||||||
|
|
||||||
- Python 3.8.6
|
- Python 3.8.6
|
||||||
- [requirements.txt](requirements.txt)
|
- [requirements.txt](requirements.txt)
|
||||||
|
- Docker
|
||||||
|
|
||||||
#### __Setting up__
|
#### __Setting up__
|
||||||
|
|
||||||
- A `tokens.py` file that contains:
|
You have to replace `TOKEN_DISCORD`, `TOKEN_GENIUS`, `TOKEN_REDDIT_CLIENT_ID`, `TOKEN_REDDIT_CLIENT_SECRET` and `TOKEN_REDDIT_USER_AGENT` with your desired values.
|
||||||
|
With a [docker-compose](docker-compose.yml) or in command line:
|
||||||
|
|
||||||
```py
|
```
|
||||||
token_discord = "your discord token"
|
docker run -d \
|
||||||
token_genius = "your genius token"
|
--name="kassoubot" \
|
||||||
token_reddit = {"client_id": "your client id", "client_secret": "your secret pass", "user_agent": "your reddit's username"}
|
mylloon/kassoubot \
|
||||||
|
--TOKEN_DISCORD="yourValue" \
|
||||||
|
--TOKEN_GENIUS="yourValue" \
|
||||||
|
--TOKEN_REDDIT_CLIENT_ID="yourValue" \
|
||||||
|
--TOKEN_REDDIT_CLIENT_SECRET="yourValue" \
|
||||||
|
--TOKEN_REDDIT_USER_AGENT="yourValue"
|
||||||
```
|
```
|
||||||
|
|
||||||
To find reddit tokens, go to [this site](https://www.reddit.com/prefs/apps) and here are the instructions: ![instructions](https://i.imgur.com/tEzYKDA.png)
|
To find reddit tokens, go to [this site](https://www.reddit.com/prefs/apps) and here are the instructions: ![instructions](https://i.imgur.com/tEzYKDA.png)
|
||||||
|
|
||||||
*redirection uri (for copy/paste) : http://localhost:8080*
|
*redirection uri (for copy/paste) : http://localhost:8080*
|
||||||
|
|
||||||
#### __Starting up__
|
|
||||||
|
|
||||||
- Run [main.py](main.py)
|
|
||||||
|
|
||||||
#### __Add the bot to your server__
|
#### __Add the bot to your server__
|
||||||
|
|
||||||
- [This site](https://discordapi.com/permissions.html) allows you to choose which permissions to add by default to the bot.
|
- [This site](https://discordapi.com/permissions.html) allows you to choose which permissions to add by default to the bot.
|
||||||
|
|
12
docker-compose.yml
Normal file
12
docker-compose.yml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
version: "2.1"
|
||||||
|
services:
|
||||||
|
kassoubot:
|
||||||
|
image: mylloon/kassoubot
|
||||||
|
container_name: kassoubot
|
||||||
|
environment:
|
||||||
|
- TOKEN_DISCORD=your-token-discord
|
||||||
|
- TOKEN_GENIUS=your-token-genius
|
||||||
|
- TOKEN_REDDIT_CLIENT_ID=your-reddit-client-id
|
||||||
|
- TOKEN_REDDIT_CLIENT_SECRET=your-reddit-client-secret
|
||||||
|
- TOKEN_REDDIT_USER_AGENT=your-reddit-user-agent
|
||||||
|
restart: unless-stopped
|
|
@ -1,7 +1,6 @@
|
||||||
import discord, praw, json, requests, time, feedparser
|
import discord, praw, json, requests, time, feedparser, os
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from random import randint, choice
|
from random import randint, choice
|
||||||
from tokens import token_reddit as token # à l'importation de l'extension, le fichier se retrouve dans le '/' et non dans 'cogs/', ignorez l'erreur pylint
|
|
||||||
|
|
||||||
def setup(client):
|
def setup(client):
|
||||||
client.add_cog(Internet(client))
|
client.add_cog(Internet(client))
|
||||||
|
@ -34,7 +33,7 @@ class Internet(commands.Cog):
|
||||||
async def _memes(self, ctx, *, args = ""):
|
async def _memes(self, ctx, *, args = ""):
|
||||||
"""Envois un meme de reddit.\n ➡ Syntaxe: .memes/meme [subreddit]"""
|
"""Envois un meme de reddit.\n ➡ Syntaxe: .memes/meme [subreddit]"""
|
||||||
try:
|
try:
|
||||||
reddit = praw.Reddit(client_id = token['client_id'], client_secret = token['client_secret'], user_agent = f"disreddit /u/{token['user_agent']}, http://localhost:8080")
|
reddit = praw.Reddit(client_id = os.environ['TOKEN_REDDIT_CLIENT_ID'], client_secret = os.environ['TOKEN_REDDIT_CLIENT_SECRET'], user_agent = f"disreddit /u/{os.environ['TOKEN_REDDIT_USER_AGENT']}, http://localhost:8080")
|
||||||
|
|
||||||
if args != "": # si il y a un arg différent d'un meme
|
if args != "": # si il y a un arg différent d'un meme
|
||||||
subredditchoix = args
|
subredditchoix = args
|
||||||
|
|
|
@ -20,8 +20,8 @@ from discord.ext import commands
|
||||||
# Genius API
|
# Genius API
|
||||||
import lyricsgenius
|
import lyricsgenius
|
||||||
import time
|
import time
|
||||||
from tokens import token_genius as token # à l'importation de l'extension, music.py se retrouve dans le '/' et non dans 'cogs/', ignorez l'erreur
|
import os
|
||||||
genius = lyricsgenius.Genius(token)
|
genius = lyricsgenius.Genius(os.environ['TOKEN_GENIUS'])
|
||||||
|
|
||||||
# Silence useless bug reports messages
|
# Silence useless bug reports messages
|
||||||
youtube_dl.utils.bug_reports_message = lambda: ''
|
youtube_dl.utils.bug_reports_message = lambda: ''
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
print("Connexion à Discord...")
|
print("Connexion à Discord...")
|
||||||
|
|
||||||
import discord, re, pytz
|
import discord, re, pytz, os
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from random import choice
|
from random import choice
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pytz import timezone
|
from pytz import timezone
|
||||||
from tokens import token_discord as token
|
|
||||||
|
|
||||||
client = commands.Bot(command_prefix = ".", case_insensitive = True, intents = discord.Intents.all())
|
client = commands.Bot(command_prefix = ".", case_insensitive = True, intents = discord.Intents.all())
|
||||||
|
|
||||||
|
@ -20,7 +19,7 @@ client.load_extension("cogs.autopublish")
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
async def on_connect():
|
async def on_connect():
|
||||||
print(f"Connecté avec le token : {token}.")
|
print(f"Connecté.")
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
|
@ -212,4 +211,4 @@ def user_or_nick(user):
|
||||||
else:
|
else:
|
||||||
return f"{user.name}#{user.discriminator}"
|
return f"{user.name}#{user.discriminator}"
|
||||||
|
|
||||||
client.run(token)
|
client.run(os.environ['TOKEN_DISCORD'])
|
||||||
|
|
Reference in a new issue