Containerize it

This commit is contained in:
askiiart 2023-08-28 21:00:35 -05:00
parent 8372d56c80
commit 973d9ee7cf
No known key found for this signature in database
GPG key ID: 85505F3A2264FA01
6 changed files with 97 additions and 25 deletions

16
.env.example Normal file
View file

@ -0,0 +1,16 @@
BOT_TOKEN=9198675309
NEURAL=Bearer v3498347598347523983497
POE_TOKEN=023423840823
OPENAI_EMAIL=email@example.com
OPENAI_PASS=password1234
GUILD_ID=1234567890
BOT_ID=1234567890
MAGIC_ITEM_FORUM=1234567890
RACE_FORUM=1234567890
SUBCLASS_FORUM=1234567890
LOCATION_FORUM=1234567890
MONSTER_FORUM=1234567890
NPC_FORUM=1234567890
OTHER_FORUM=1234567890
LOG_CHANNEL=1234567890
AUTOGEN=true

9
Dockerfile Normal file
View file

@ -0,0 +1,9 @@
FROM python:alpine
WORKDIR /data
COPY ./requirements.txt /data/
RUN pip3 install -r requirements.txt
COPY ./neural.py /data/
COPY ./generate.py /data/
COPY ./itemname.py /data/
COPY ./main.py /data/
CMD python3 main.py

View file

@ -1,18 +1,27 @@
# AlwaysDungeons # AlwaysDungeons
24-hour AI DND generation. 24-hour AI DND generation.
## Environment Variables ## Environment Variables
| KEY | DESCRIPTION | | KEY | DESCRIPTION |
|--|--| | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|DISCORDBOT|The discord bot's token.| | BOT_TOKEN | The discord bot's token. |
| NEURAL | Your NeuralLove api key. Should look like "Bearer v...." | | NEURAL | Your NeuralLove api key. Should look like "Bearer v...." |
|PB|Your Quora api key. You'll sign into Quora on your browser, go into your Inspect Element -> Storage -> Quora.com cookies, and copy the m-b cookie. Used to access poe.com's ChatGPT bot.| | POE_TOKEN | Your Quora api key. You'll sign into Quora on your browser, go into your Inspect Element -> Storage -> Quora.com cookies, and copy the m-b cookie. Used to access poe.com's ChatGPT bot. |
|EMAIL|The email used with your ChatGPT account. Used as a fallback to poe.com, and not required to fill in.| | OPENAI_EMAIL | OPTIONAL, currently not implemented. The email used with your ChatGPT account. Used as a fallback to poe.com, and not required to fill in. |
|PASS|The password used with your ChatGPT account. Used as a fallback to poe.com, and not required to fill in. | OPENAI_PASS | OPTIONAL, currently not implemented. The password used with your ChatGPT account. Used as a fallback to poe.com, and not required to fill in. |
| | GUILD_ID | The ID of the server the bot is in. |
| BOT_ID | The ID of the bot itself. |
| MAGIC_ITEM_FORUM | The channel ID of the magic item forum |
| RACE_FORUM | The channel ID of the race forum |
| SUBCLASS_FORUM | The channel ID of the subclass forum |
| LOCATION_FORUM | The channel ID of the location forum |
| MONSTER_FORUM | The channel ID of the monster forum |
| NPC_FORUM | The channel ID of the NPC forum |
| OTHER_FORUM | The channel ID of the other forum |
| LOG_CHANNEL | The channel ID of the log channel |
| AUTOGEN | Whether or not the bot should automatically generate content. (true/false) |
## Functionality ## Functionality
@ -33,3 +42,30 @@ magicForum, raceForum, subclassForum, locationForum, monsterForum, npcForum, and
logChannel is the channel that error messages and other announcements from the bot are posted in. Be sure to put this channel in a publicly visible place; it announces when a user's request is being fulfilled. logChannel is the channel that error messages and other announcements from the bot are posted in. Be sure to put this channel in a publicly visible place; it announces when a user's request is being fulfilled.
autogen enables or disables the bot's automatic production of homebrew content. If this is not desired, change autogen to False. autogen enables or disables the bot's automatic production of homebrew content. If this is not desired, change autogen to False.
## Running the bot
### Docker
Example `docker run`:
```bash
docker run -d -v /path/to/.env:/data/.env docker.askiiart.net/askiiart/createrepo_c
```
Example `docker-compose.yml`:
```yaml
version: '3.7'
services:
hugo:
image: docker.askiiart.net/askiiart/discord-always-dungeons
volumes:
- /path/to/.env:/data/.env
```
## Build the Docker image
Just run `docker build .`
Alternatively, you can just run `./build-and-push.sh`, which will build the image and push it to the registry. Just make sure to fix the variables before running it.

9
build-and-push.sh Normal file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -e
ORG="askiiart"
NAME="discord-always-dungeons"
ID=$(docker build . -q)
# Could just do -t on the build, but this makes it easier to expand if needed.
docker tag ${ID} ${ORG}/${NAME}:latest
docker push ${ORG}/${NAME}:latest

View file

@ -1,6 +1,6 @@
from poe_api_wrapper import PoeApi from poe_api_wrapper import PoeApi
import os import os
client = PoeApi(os.environ['PB']) client = PoeApi(os.environ['POE_TOKEN'])
import asyncio import asyncio
#from revChatGPT.V1 import AsyncChatbot #from revChatGPT.V1 import AsyncChatbot

30
main.py
View file

@ -1,5 +1,5 @@
import os import os
from dotenv import load_dotenv
import discord import discord
import generate import generate
import neural import neural
@ -11,22 +11,24 @@ from discord.ext import tasks
import keep_alive import keep_alive
from keep_alive import keep_alive from keep_alive import keep_alive
load_dotenv()
client = discord.Client(intents=discord.Intents.all()) client = discord.Client(intents=discord.Intents.all())
tree = app_commands.CommandTree(client) tree = app_commands.CommandTree(client)
queue = [] queue = []
guildID = 1081397933276155977 guildID = os.environ['GUILD_ID']
botID = 1144041248303366314 botID = os.environ['BOT_ID']
magicForum = 1144040531240964256 magicForum = os.environ['MAGIC_ITEM_FORUM']
raceForum = 1144075835217825868 raceForum = os.environ['RACE_FORUM']
subclassForum = 1144075898870579290 subclassForum = os.environ['SUBCLASS_FORUM']
locationForum = 1144075950749925457 locationForum = os.environ['LOCATION_FORUM']
monsterForum = 1144081512724176947 monsterForum = os.environ['MONSTER_FORUM']
npcForum = 1144425240018034878 npcForum = os.environ['NPC_FORUM']
otherForum = 1144426051720724602 otherForum = os.environ['OTHER_FORUM']
logChannel = 1144064721922834582 logChannel = os.environ['LOG_CHANNEL']
autogen = True autogen = True if os.environ('AUTOGEN') == 'true' else False
@client.event @client.event
async def on_message(message): async def on_message(message):
@ -177,5 +179,5 @@ async def on_ready():
keep_alive() keep_alive()
my_secret = os.environ['DISCORDBOT'] bot_token = os.environ['BOT_TOKEN']
client.run(my_secret) client.run(bot_token)