Compare commits
6 Commits
9f2c6ba7c5
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| e26857f269 | |||
| 03922e8849 | |||
| f2df4c9b43 | |||
|
|
839c0ca7b6 | ||
|
|
f81b407b4c | ||
|
|
6d7cbd15f2 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
guptoken.py
|
*.pyc
|
||||||
|
gupbot/guptoken.py
|
||||||
|
|||||||
17
Dockerfile
Normal file
17
Dockerfile
Normal 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
22
build_gupbot.sh
Executable 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
|
||||||
|
|
||||||
@@ -8,6 +8,7 @@ import insult_generator
|
|||||||
TOKEN = guptoken.getToken()
|
TOKEN = guptoken.getToken()
|
||||||
|
|
||||||
intents = discord.Intents.default()
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
intents.members = True
|
intents.members = True
|
||||||
client = discord.Client(intents=intents)
|
client = discord.Client(intents=intents)
|
||||||
|
|
||||||
@@ -23,22 +24,22 @@ async def on_message(message):
|
|||||||
if message.content.startswith("!insult"):
|
if message.content.startswith("!insult"):
|
||||||
print(f'Message: {message.content}')
|
print(f'Message: {message.content}')
|
||||||
l = message.content.split(" ")
|
l = message.content.split(" ")
|
||||||
if (len(l) <= 1):
|
|
||||||
return
|
|
||||||
|
|
||||||
id = 0
|
target = message.author
|
||||||
|
|
||||||
|
if (len(l) > 1):
|
||||||
|
# Associate given name with online discord target
|
||||||
if (l[1].startswith("<@")):
|
if (l[1].startswith("<@")):
|
||||||
id = int(l[1][2:-1])
|
target_id = int(l[1][2:-1])
|
||||||
print(f'{id}')
|
print(f'{target_id}')
|
||||||
|
|
||||||
m = message.channel.members
|
m = message.channel.members
|
||||||
print(f'Terrrgetted user: {l[1]}')
|
|
||||||
|
|
||||||
print(f'Members: {m}')
|
|
||||||
for member in 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):
|
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)}!'
|
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)
|
await message.channel.send(response)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -54,12 +55,24 @@ async def on_message(message):
|
|||||||
await message.channel.send(response)
|
await message.channel.send(response)
|
||||||
return
|
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("!")):
|
if (message.content.startswith("!")):
|
||||||
response = f'{message.author.mention} uh, *wat*? For a list of commands, type !help.'
|
response = f'{message.author.mention} uh, *wat*? For a list of commands, type !help.'
|
||||||
await message.channel.send(response)
|
await message.channel.send(response)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
client.run(TOKEN)
|
client.run(TOKEN)
|
||||||
Reference in New Issue
Block a user