Compare commits

..

6 Commits

Author SHA1 Message Date
e26857f269 Rename token 2025-04-23 18:21:53 +00:00
03922e8849 Remove from watchtower updates 2025-01-31 21:51:55 +00:00
f2df4c9b43 Add docker scripts 2025-01-20 20:13:01 +00:00
Dylan Smith
839c0ca7b6 Add !gamenight 2025-01-20 14:41:13 -05:00
Dylan Smith
f81b407b4c Update .gitignore 2025-01-20 13:56:43 -05:00
Dylan Smith
6d7cbd15f2 Fix insult generator 2025-01-20 13:56:28 -05:00
6 changed files with 74 additions and 21 deletions

3
.gitignore vendored
View File

@@ -1 +1,2 @@
guptoken.py
*.pyc
gupbot/guptoken.py

17
Dockerfile Normal file
View File

@@ -0,0 +1,17 @@
# Use the official Python image
FROM python:3.10-slim
LABEL com.centurylinklabs.watchtower.enable="false"
# Set the working directory in the container
WORKDIR /gupbot
# Copy the application code into the container
ADD gupbot /gupbot
# Install required Python packages
RUN pip install --no-cache-dir discord.py
# Command to run your Python script
CMD ["python", "gupbot.py"]

22
build_gupbot.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
set -e
# Check if the container is running
if [ "$(docker ps -q -f name=gupbot)" ]; then
echo "Stopping the running container..."
docker stop gupbot
fi
# Check if the container exists (stopped or running)
if [ "$(docker ps -aq -f name=gupbot)" ]; then
echo "Removing the container..."
docker rm gupbot
fi
echo "Building the Docker image..."
docker build --network=host -t nalylab/gupbot .
echo "Running the Docker container..."
docker run --network=host --name=gupbot -d nalylab/gupbot

View File

@@ -8,6 +8,7 @@ import insult_generator
TOKEN = guptoken.getToken()
intents = discord.Intents.default()
intents.message_content = True
intents.members = True
client = discord.Client(intents=intents)
@@ -23,24 +24,24 @@ async def on_message(message):
if message.content.startswith("!insult"):
print(f'Message: {message.content}')
l = message.content.split(" ")
if (len(l) <= 1):
return
id = 0
if (l[1].startswith("<@")):
id = int(l[1][2:-1])
print(f'{id}')
target = message.author
m = message.channel.members
print(f'Terrrgetted user: {l[1]}')
print(f'Members: {m}')
for member in m:
print(f'Checking {member.display_name}, {member.id}...')
if (member.display_name.lower() == l[1].lower() or member.id == id):
response = f'{member.mention} is a {insult_generator.hit_me(3, odds_of_adding_another_word=0.75)}!'
await message.channel.send(response)
return
if (len(l) > 1):
# Associate given name with online discord target
if (l[1].startswith("<@")):
target_id = int(l[1][2:-1])
print(f'{target_id}')
m = message.channel.members
for member in m:
if (member.display_name.lower() == l[1].lower() or member.id == id):
target = member
break
response = f'{target.mention} is a {insult_generator.hit_me(3, odds_of_adding_another_word=0.75)}!'
await message.channel.send(response)
return
if (message.content.startswith("!survivor")):
survivors = ["Acrid", "Artificer", "Bandit", "Captain", "Commando", "Engineer", "Huntress", "Loader", "MUL-T", "Mercenary", "REX", "Railgunner", "Void Fiend"]
@@ -54,12 +55,24 @@ async def on_message(message):
await message.channel.send(response)
return
if (message.content.startswith("!gamenight")):
members = []
for vc in message.guild.voice_channels:
for member in vc.members:
members.append(member)
if len(members) == 0:
response = f'Ain\'t nobody to choose, ya {insult_generator.hit_me(1)}!'
else:
member_idx = random.randint(0,len(members)-1)
member = members[member_idx]
response = f'I choose {member.mention} to decide tonights game!'
await message.channel.send(response)
return
if (message.content.startswith("!")):
response = f'{message.author.mention} uh, *wat*? For a list of commands, type !help.'
await message.channel.send(response)
return
client.run(TOKEN)