v2.0--Docker-Idea #32

Merged
alex_orid merged 5 commits from v2.0--Docker-Idea into v2.0 2021-04-22 17:37:24 +00:00
8 changed files with 70 additions and 8 deletions

View File

@ -7,4 +7,4 @@ RUN pip3 install -r requirements.txt
COPY . .
CMD [ "python3", "main.py"] #Uncomment to start with the Docker Container
CMD [ "python3", "main.py"]

View File

@ -0,0 +1,10 @@
FROM python:3.8-buster
WORKDIR /Praxis
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
COPY . .
CMD [ "python3", "discord_script_standalone.py"]

View File

@ -0,0 +1,10 @@
FROM python:3.8-buster
WORKDIR /Praxis
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
COPY . .
CMD [ "python3", "twitch_script_standalone.py"]

View File

@ -0,0 +1,10 @@
FROM python:3.8-buster
WORKDIR /Praxis
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
COPY . .
CMD [ "python3", "standalone_command.py"]

View File

@ -7,12 +7,28 @@ ___
## Usage:
Run the following to enable these V2 modules.
Run the following to enable these V2 modules without Docker. (After you install requirements)</br>
`pip install -r requirements.txt`</br>
`python standalone_command.py`</br>
`python twitch_script_standalone`</br>
`python discord_script_standalone`</br>
`python twitch_script_standalone.py`</br>
`python discord_script_standalone.py`</br>
## Docker:
### Image Setup:
Use these commands to build the images.</br>
`docker build --file Dockerfile_standalone_command --tag standalone_command .`</br>
`docker build --file Dockerfile_standalone_TwitchScript --tag twitchscript_standalone .`</br>
`docker build --file Dockerfile_standalone_DiscordScript --tag discordscript_standalone .`</br>
### Docker-Compose Info:
To Start:
`docker-compose up`</br>
To Stop:
`docker-compose down`</br>
___
~~# V1 Info:~~

View File

@ -85,14 +85,14 @@ class Discord_Module(discord.Client):
async def is_command(self, word: str) -> bool:
# todo need to url-escape word
clean_param = urlencode({'name': word})
url = "http://localhost:5000/api/v1/command?%s" % clean_param
url = "http://standalone_command:5000/api/v1/command?%s" % clean_param
resp = requests.get(url)
return resp.status_code == 200
async def exec_command(self, realMessage: discord.Message, command: str, rest: str):
# todo need to url-escape command and rest
params = urlencode({'command_source': commands.command_base.AbstractCommand.CommandSource.Discord, 'user_name': realMessage.author.mention, 'command_name': command, 'rest': rest, 'bonus_data': realMessage})
url = "http://localhost:5000/api/v1/exec?%s" % params
url = "http://standalone_command:5000/api/v1/exec?%s" % params
resp = requests.get(url)
if resp.status_code == 200:
print("Got the following message: %s" % resp.text)

16
docker-compose.yaml Normal file
View File

@ -0,0 +1,16 @@
version: '3.7'
services:
standalone_command:
image: standalone_command
ports:
- 5000:5000
environment:
- ISDOCKER=cat
twitchscript_standalone:
image: twitchscript_standalone
environment:
- ISDOCKER=cat
discordscript_standalone:
image: discordscript_standalone
environment:
- ISDOCKER=cat

View File

@ -69,14 +69,14 @@ class Twitch_Module():
def is_command(self, word: str) -> bool:
# todo need to url-escape word
clean_param = urlencode({'name': word})
url = "http://localhost:5000/api/v1/command?%s" % clean_param
url = "http://standalone_command:5000/api/v1/command?%s" % clean_param
resp = requests.get(url)
return resp.status_code == 200
def exec_command(self, realMessage: twitch.chat.Message, command: str, rest: str):
# todo need to url-escape command and rest
params = urlencode({'command_source': commands.command_base.AbstractCommand.CommandSource.Twitch,'user_name': realMessage.sender, 'command_name': command, 'rest': rest, 'bonus_data': realMessage})
url = "http://localhost:5000/api/v1/exec?%s" % params
url = "http://standalone_command:5000/api/v1/exec?%s" % params
resp = requests.get(url)
if resp.status_code == 200:
print("Got the following message: %s" % resp.text)