From 81189993430a8420a14f98419fc83d13f52e23a1 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Fri, 13 Apr 2018 10:02:07 -0700 Subject: [PATCH] Adding text to speech module and updating pip in the container --- .gitlab-ci.yml | 1 + Dockerfile | 1 + Dockerfile-test-env | 1 + app/dragon-bot.py | 16 ++++++++++++++++ app/requirements.txt | 1 + 5 files changed, 20 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 235bd2c7..3c07b31d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,6 +4,7 @@ services: before_script: - apk add --no-cache python3 + - pip install -U pip - pip3 install -r app/requirements.txt stages: diff --git a/Dockerfile b/Dockerfile index ffbadaf3..05fb076c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,7 @@ FROM python:3.6.2-alpine3.6 ADD app/requirements.txt /requirements.txt RUN apk update && \ apk add --no-cache docker && \ + pip install -U pip && \ pip install -r requirements.txt ADD app /app CMD python /app/dragon-bot.py diff --git a/Dockerfile-test-env b/Dockerfile-test-env index 969b2ed5..48408c6c 100644 --- a/Dockerfile-test-env +++ b/Dockerfile-test-env @@ -2,6 +2,7 @@ FROM python:3.6.2-alpine3.6 ADD app/requirements.txt /requirements.txt RUN apk update && \ apk add --no-cache vim docker && \ + pip install -U pip && \ pip install -r requirements.txt ADD app /app diff --git a/app/dragon-bot.py b/app/dragon-bot.py index b27fe17b..0140c03b 100644 --- a/app/dragon-bot.py +++ b/app/dragon-bot.py @@ -7,6 +7,7 @@ then imported into the main bot import os import requests +from gtts import gTTS import core_utils import decide @@ -311,6 +312,21 @@ async def on_message(message): "```{}```".format(' '.join(list(map(lambda x: x.name, message.author.roles)))) ) + if message.content.startswith('!tts'): + myobj = gTTS( + text=' '.join(message.content.split()[1:]), + lang='en', + slow=False + ) + file_path = '/tmp/memes.mp3' + myobj.save(file_path) + + await client.send_file( + message.channel, + file_path, + ) + os.remove(file_path) + if message.content.startswith('!wallpaper'): await client.send_message( message.channel, diff --git a/app/requirements.txt b/app/requirements.txt index 2d8258ce..573ca728 100644 --- a/app/requirements.txt +++ b/app/requirements.txt @@ -1,6 +1,7 @@ beautifulsoup4 discord.py docker +gTTS pylint pyowm requests