Skip to content

Commit

Permalink
- More logging
Browse files Browse the repository at this point in the history
- Setup the same timezone in a docker container as on a host
  • Loading branch information
soksanichenko committed Feb 8, 2024
1 parent b8ff7ce commit b0e55de
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
15 changes: 10 additions & 5 deletions deploy/roles/deploy_bot_container/tasks/docker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---
- name: Get current timezone
ansible.builtin.command: timedatectl show --property=Timezone --value
register: timezone_output
changed_when: false

- name: Prepare Dockerfile
template:
dest: "/tmp/Dockerfile"
Expand Down Expand Up @@ -51,8 +56,8 @@
type: bind
become: yes

- name: Remove Dockerfile
file:
path: "/tmp/Dockerfile"
state: absent
...
#- name: Remove Dockerfile
# file:
# path: "/tmp/Dockerfile"
# state: absent
#...
1 change: 1 addition & 0 deletions deploy/roles/deploy_bot_container/templates/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM almalinux:9
ENV TZ="{{ timezone_output.stdout }}"
RUN dnf install python39 -y
RUN mkdir -p /code/sources
WORKDIR /code
Expand Down
3 changes: 3 additions & 0 deletions sources/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ async def on_message(message: discord.Message):

logger.info('Get message from %s', message.author.name)
if message.author == bot.user:
logger.info('That message is mine')
return
if not message.embeds:
logger.info('The message does not contain embeds')
return
processed_urls = (
replace_domain(urlparse(embed.url)) for embed in message.embeds
Expand All @@ -88,6 +90,7 @@ async def on_message(message: discord.Message):
# So you need to compare replaced content and original one
# and do nothing if they are identical.
if message.content == content:
logger.info('The original message already fixed')
return
content += f'\nOriginal message posted by {message.author.mention}'
await message.channel.send(content=content)
Expand Down

0 comments on commit b0e55de

Please sign in to comment.