Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
a071a8d71a | |||
77e4ad91ed |
1
.gitignore
vendored
1
.gitignore
vendored
@ -162,3 +162,4 @@ app/run_venv.sh
|
|||||||
# Local History for Visual Studio Code
|
# Local History for Visual Studio Code
|
||||||
.history/
|
.history/
|
||||||
|
|
||||||
|
/reference config/
|
||||||
|
13
README.md
13
README.md
@ -222,3 +222,16 @@ This should also mean that the sign-up prompts should persist over reboots.
|
|||||||
Other developers for Discord Components recommended the use of dynamic call-backs, however these do not persist after reboots so are not suitable for this purpose.
|
Other developers for Discord Components recommended the use of dynamic call-backs, however these do not persist after reboots so are not suitable for this purpose.
|
||||||
Discord will need to make substantial API updates in the future for rolling out the Threads feature.
|
Discord will need to make substantial API updates in the future for rolling out the Threads feature.
|
||||||
The bot will need updating again then.
|
The bot will need updating again then.
|
||||||
|
|
||||||
|
|
||||||
|
## Remote Deployment to docker server
|
||||||
|
|
||||||
|
Configure local env to know about the server
|
||||||
|
- ` docker context create remote --docker "host=tcp://<hostname>:2376,ca=<full path>/ca.pem,cert=<full path>/cert.pem,key=<full path>/key.pem"`
|
||||||
|
- create a folder on the server to use for the config
|
||||||
|
- create/amend a docker compose for that env (eg docker-compose-nas)
|
||||||
|
- put the config in that folder
|
||||||
|
- deploy using that config `docker compose -f docker-compose-nas.yml up -d`
|
||||||
|
- hope
|
||||||
|
- if its a QNAP nas, manually copy the docker compose file to `/share/CACHEDEV1_DATA/VMs/container-station-data/application/geas-bot` because its stupid
|
||||||
|
-
|
@ -1,7 +1,10 @@
|
|||||||
FROM python:3.9.6-slim
|
FROM python:slim
|
||||||
COPY . /usr/src/app
|
COPY . /app
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /app
|
||||||
RUN apt-get update -y && apt-get upgrade -y && apt-get install libopus0 -y && \
|
RUN apt-get update -y
|
||||||
pip install --upgrade pip setuptools wheel && pip install -r requirements.txt && \
|
RUN apt-get upgrade -y
|
||||||
apt-get autoremove -y
|
RUN apt-get install libopus0 -y
|
||||||
|
RUN pip install --upgrade pip
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
RUN apt-get autoremove -y
|
||||||
CMD python3 -u ./bot.py
|
CMD python3 -u ./bot.py
|
@ -25,9 +25,13 @@ def yaml_dump(data:dict, filepath:str):
|
|||||||
yaml.dump(data, file)
|
yaml.dump(data, file)
|
||||||
|
|
||||||
# Locate or create config file. Read from environment variables to locate file, and if missing or not valid then use default location.
|
# Locate or create config file. Read from environment variables to locate file, and if missing or not valid then use default location.
|
||||||
configFile = os.getenv('CONFIG') if ((os.getenv('CONFIG').endswith('.yml') or os.getenv('CONFIG').endswith('.yaml')) and not os.getenv('CONFIG').endswith('config_blueprint.yml')) else './data/config.yml'
|
configFile = './data/config.yml'
|
||||||
|
if os.getenv('CONFIG'):
|
||||||
|
if os.getenv('CONFIG').endswith(('.yml','.yaml')) and not os.getenv('CONFIG').endswith('config_blueprint.yml'):
|
||||||
|
configFile = os.getenv('CONFIG')
|
||||||
|
|
||||||
if not os.path.exists(configFile): yaml_dump({},configFile)
|
if not os.path.exists(configFile):
|
||||||
|
yaml_dump({},configFile)
|
||||||
|
|
||||||
# Locate or create data file. Same as above.
|
# Locate or create data file. Same as above.
|
||||||
dataFile = os.getenv('DATA') if ((os.getenv('DATA').endswith('.yml') or os.getenv('DATA').endswith('.yaml')) and not os.getenv('DATA').endswith('data_blueprint.yml')) else './data/data.yml'
|
dataFile = os.getenv('DATA') if ((os.getenv('DATA').endswith('.yml') or os.getenv('DATA').endswith('.yaml')) and not os.getenv('DATA').endswith('data_blueprint.yml')) else './data/data.yml'
|
||||||
|
@ -17,15 +17,6 @@ class PitchListener(commands.Cog, name='Pitch Listener'):
|
|||||||
def __init__(self, client):
|
def __init__(self, client):
|
||||||
self.client = client
|
self.client = client
|
||||||
|
|
||||||
@commands.Cog.listener(name='on_component')
|
|
||||||
async def _response_defer(self, ctx:ComponentContext):
|
|
||||||
pitches = yaml_load(pitchesFile)
|
|
||||||
guildStr = str(ctx.guild.id)
|
|
||||||
if not pitches.get(guildStr, {}): return # If no pitches for current guild, ignore.
|
|
||||||
[timeslot] = [*pitches[guildStr]]
|
|
||||||
if ctx.origin_message.id not in pitches[guildStr][timeslot]['messages'] + [pitches[guildStr][timeslot]['control']]: return # If the context id is not in the pitch menu, ignore
|
|
||||||
await ctx.defer(hidden = True)
|
|
||||||
|
|
||||||
@commands.Cog.listener(name='on_component')
|
@commands.Cog.listener(name='on_component')
|
||||||
async def _pitch_listener(self, ctx:ComponentContext):
|
async def _pitch_listener(self, ctx:ComponentContext):
|
||||||
conf = yaml_load(configFile)
|
conf = yaml_load(configFile)
|
||||||
|
@ -23,8 +23,7 @@ class RestrictionListener(commands.Cog, name='Membership Restriction Listener'):
|
|||||||
lookup = yaml_load(lookupFile)
|
lookup = yaml_load(lookupFile)
|
||||||
if not conf[guildStr].get('restrict',False): return
|
if not conf[guildStr].get('restrict',False): return
|
||||||
if message.author.bot: return
|
if message.author.bot: return
|
||||||
if message.channel.category is None: return
|
if str(message.channel.category) in categories[guildStr]: return
|
||||||
if str(message.channel.category.id) not in categories[guildStr]: return
|
|
||||||
if (set(message.author.roles) & set([message.guild.get_role(x) for x in conf[guildStr]['roles']['admin']]) or message.author == message.guild.owner): return
|
if (set(message.author.roles) & set([message.guild.get_role(x) for x in conf[guildStr]['roles']['admin']]) or message.author == message.guild.owner): return
|
||||||
if set(message.author.roles) & set([message.guild.get_role(x) for x in conf[guildStr]['membership']]): return
|
if set(message.author.roles) & set([message.guild.get_role(x) for x in conf[guildStr]['membership']]): return
|
||||||
if message.channel.overwrites_for(message.author).manage_channels: return
|
if message.channel.overwrites_for(message.author).manage_channels: return
|
||||||
|
9
docker-compose-nas.yml
Normal file
9
docker-compose-nas.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
version: '3.5'
|
||||||
|
|
||||||
|
services:
|
||||||
|
geasbot-app:
|
||||||
|
build: ./app
|
||||||
|
container_name: geas_bot
|
||||||
|
volumes:
|
||||||
|
- /share/Public/geasbot/data:/app/data
|
||||||
|
restart: unless-stopped
|
@ -5,5 +5,5 @@ services:
|
|||||||
build: ./app
|
build: ./app
|
||||||
container_name: geas_bot
|
container_name: geas_bot
|
||||||
volumes:
|
volumes:
|
||||||
- ./app:/usr/src/app
|
- ./app:/app
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
Loading…
Reference in New Issue
Block a user