Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
coillteoir authored Mar 19, 2024
2 parents 1188871 + fb122ed commit b5e9b16
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 33 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
README.md
CONTRIBUTING.md
**/__pycache__/
.git/
token
12 changes: 12 additions & 0 deletions .github/workflows/image-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "Dev Image Build"
run-name: ${{ github.actor }} Dev Image Build
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: echo "Job triggered by ${{ github.event_name }}."
- uses: actions/checkout@v3
- run: docker --version
- run: docker build -t morningbot-dev .
- run: docker image ls | grep morningbot-dev
6 changes: 3 additions & 3 deletions .github/workflows/json-lint.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Json-Validate
run-name: ${{ github.actor }} PR being linted for code cleanliness
name: Json Validate
run-name: ${{ github.actor }} Validating JSON in config files
on: [pull_request]
jobs:
json-lint:
validate:
runs-on: ubuntu-latest
steps:
- run: echo "Job triggered by ${{ github.event_name }} event."
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-lint.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Test-Lint
name: Python Lint
run-name: ${{ github.actor }} PR being linted for code cleanliness
on: [pull_request]
jobs:
python-lint:
lint:
runs-on: ubuntu-latest
steps:
- run: echo "Job triggered by ${{ github.event_name }} event."
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
4. Write a concise title
5. Write a good description
6. Sit back and wait for review
7. Accept constructive feedback and comments
7. Build upon constructive feedback and comments
8. Get it merged :)

## General PR Guidelines
Expand Down
8 changes: 3 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
FROM python:latest

FROM gorialis/discord.py
FROM python:3.11-slim

RUN mkdir -p /usr/src/MorningBot

WORKDIR /usr/src/MorningBot

COPY . .
RUN pip install -r requirements.txt

CMD ["python3", "main.py"]
CMD ["python3", "."]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ docker build -t morningbot .
8. 🐳 Run the container.

```bash
docker run -d --name morningbot morningbot
docker run --volume=./:/usr/src/MorningBot/ -d morningbot:latest
#or
docker-compose up
```

### Supported timezones
Expand Down
31 changes: 18 additions & 13 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,29 +126,34 @@ async def on_message(message):
await message.add_reaction(BAD_MORNING_EMOJI)
return

if any(element in contents for element in GOOD_MORNING_PHRASES):
print(f'gm detected > "{message.content}" by {message.author}')
if FIRST_GM is False:
FIRST_GM_USER = message.author
FIRST_GM = True
# Use regular expressions to check for good morning phrases small changes
for pattern in GOOD_MORNING_PHRASES:
if re.search(rf'\b{re.escape(pattern)}\b', contents):
print(f'gm detected > "{message.content}" by {message.author}')
if FIRST_GM is False:
FIRST_GM_USER = message.author
FIRST_GM = True

await message.add_reaction(EARLY_EMOJI)
server_leaders.add_point(message.author)
return

# Add the earlybird role to the first user to say good morning
await FIRST_GM_USER.add_roles(EARLYBIRD_ROLE)

await message.add_reaction(EARLY_EMOJI)

server_leaders.add_point(message.author)
return
await message.add_reaction(MORNING_EMOJI)

server_leaders.add_point(message.author)
await message.add_reaction(MORNING_EMOJI)
return

# Performing regular expression checking on easter egg phrases
for egg_phrase, reaction in configuration_data["easter_egg_phrases"].items():
if re.search(egg_phrase, contents):
await message.add_reaction(reaction)
return

for egg_phrase in configuration_data["easter_egg_phrases"].keys():
if egg_phrase in contents:
await message.add_reaction(
configuration_data["easter_egg_phrases"][egg_phrase]
)

if DEBUG_MODE:
if re.match(PATTERN, contents.lower()): # debug block >1
Expand Down
17 changes: 9 additions & 8 deletions config/configuration_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,18 @@
"https://media.giphy.com/media/hUEtOkI8ntRtBLyMfb/giphy.gif",
"https://media.giphy.com/media/TKXMVRt5uvV8OYErao/giphy.gif",
"https://media.giphy.com/media/mxjzBpyu8DDLIcEKVC/giphy.gif",
"https://tenor.com/view/доброе-утро-кофе-coffee-gif-15999509",
"https://tenor.com/bfimL.gif",
"https://media.giphy.com/media/hHifLbLhEloqfDwWs0/giphy.gif",
"https://tenor.com/view/早安-早上好-goodmorning-flowers-sunflowers-gif-21233714",
"https://tenor.com/view/おはようございます-good-morning-morning-in-japanese-gif-4722997724943366125",
"https://tenor.com/bBf1q.gif",
"https://tenor.com/fM3xHGl6Ng9.gif",
"https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExZ2o4amxqNnhsd3E4amIzN2VhZmhoOWdmdGV0a2VubG44MjE4ZjVvayZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/JSw3ivlumEKZWrxdwp/giphy.gif",
"https://media.giphy.com/media/E3qMYDlq0YIb0qXFug/giphy.gif",
"https://tenor.com/view/suprabhat-good-morning-holidays-good-morning-hindi-good-morning-good-morning-happy-sunday-gif-19862051",
"https://giphy.com/clips/greetings-holiday-kwanzaa-5yBrQnoPsjLaCo80fy",
"https://tenor.com/bvvbP.gif",
"https://media.giphy.com/media/lckQGTmmQYdjnXerK2/giphy.gif",
"https://tenor.com/view/good-morning-günaydın-gif-25596075",
"https://tenor.com/bTyR5.gif",
"https://media0.giphy.com/media/f66sq76KfkDCKoxYSV/giphy.gif",
"https://i.pinimg.com/originals/16/27/71/162771b373fc94042ec3e0e3615c0db1.gif",
"https://tenor.com/view/good-morning-gif-25798053"
"https://tenor.com/bUppN.gif"
],
"easter_egg_phrases": {
"cheesed to meet you": "🧀",
Expand All @@ -82,8 +81,10 @@
"with the boys": "🍻",
"keithmas": "🎅",
"santanuts":"🎅",
"good night": "🫖",
"happy halloween": "🎃",
"boo": "😨",
"spooktober": "👻"
"spooktober": "👻",
"\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b": "📧"
}
}
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: '3'
services:
morningbot:
image: morningbot:latest
volumes:
- ./:/usr/src/MorningBot/
3 changes: 3 additions & 0 deletions leaderboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def __init__(self, channel):
self.path = f"config/leaderboards/{self.channel}-leaderboard.json"
print(self.path)

if os.path.isdir("config/leaderboards/") is not True:
os.mkdir("config/leaderboards/")

self.members = []
if os.path.isfile(self.path):
with open(self.path, "r", encoding="utf-8") as leader_file:
Expand Down

0 comments on commit b5e9b16

Please sign in to comment.