Skip to content

Commit

Permalink
Release 4.11.1
Browse files Browse the repository at this point in the history
  • Loading branch information
LewisHobden committed Jun 29, 2021
1 parent 4cc9ccc commit ef84bd3
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [4.11.1] - 2021-06-29
### Tweaks
- Made tweaks to the audit log behaviour for booster roles.
- Performed maintenance on server logs.
- Message events now also respond to message edits, presuming they were not already responded to.

## [4.11.0] - 2021-06-22
### Message Events (Beta Testing)
- Message events can be added/listed/deleted.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
![Migaga](https://dobercorgi.fra1.cdn.digitaloceanspaces.com/discord/Assets/Migaga.webp)
# Migaga (Version 4)
[![Discord](https://img.shields.io/discord/750683930549551164)](https://discord.gg/QEwYcsKSrs)
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/LewisHobden/migaga)
---

## What's this?
This is the repo for my passion project Discord bot. I don't know exactly how many servers it is in - nor how many users it interacts with on a regular basis. I would estimate that it's in the 1000s. It was primarily built as a helper for some of the servers I was in personally. This was before bots were as accessible as they are now, or before the mobile app was as advanced as it is currently.
I figured I would make the source code public as exposure therapy for my fear of "imperfect" code being made public with my name against it. We're all progressing professionally and personally, chronicling that only helps accelerate the process.. I hope!
Expand All @@ -20,4 +19,5 @@ I figured I would make the source code public as exposure therapy for my fear of
To get started contributing, copy `example_config.ini` to `config.ini` and update the ClientId and token to your test bot and you're good to go!
Schema can be imported from the `storage` directory. I'm working on making that easier.

![Ecologi (Trees)](https://img.shields.io/ecologi/trees/lewis)
![Ecologi (Trees)](https://img.shields.io/ecologi/trees/lewis)
[![Discord](https://img.shields.io/discord/750683930549551164)](https://discord.gg/QEwYcsKSrs)
7 changes: 5 additions & 2 deletions cogs/booster.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,11 @@ async def _on_member_updated(member_before: Member, member_after: Member):
if assigned_role is None:
return

await member_after.remove_roles(assigned_role)
await assigned_role.delete()
reason = "This person is no longer boosting the server. Role name: {}. Colour: {}".format(assigned_role.name,
assigned_role.colour)

await member_after.remove_roles(assigned_role, reason=reason)
await assigned_role.delete(reason=reason)


class BoosterRoleCog(commands.Cog, name="Booster Roles"):
Expand Down
22 changes: 22 additions & 0 deletions cogs/message_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def __init__(self, client: commands.Bot):
self._events = dict()

self.client.add_listener(self._on_message, "on_message")
self.client.add_listener(self._on_message_edit, "on_message_edit")
self._cache_events.start()

def cog_unload(self):
Expand All @@ -68,6 +69,27 @@ async def _cache_events(self):
for event in MessageEvent.select():
self.add_event(event)

async def _on_message_edit(self, message_before: Message, message_after: Message):
# Ignore ourselves, bots, etc.
if message_after.author.bot:
return

for event in self.get_events(message_after.guild):
controller = MessageMatchingController(event.contains, event.is_strict)

# If the message matched before, then we shouldn't reply to it a second time.
if controller.check_match(message_before.clean_content):
continue

# Todo, should we keep track of our messages and delete a reply if the user edits it to no longer match?
if not controller.check_match(message_after.clean_content):
continue

if event.response is None:
await message_after.delete()
else:
await message_after.reply(event.response)

async def _on_message(self, message: Message):
# Ignore ourselves, bots, etc.
if message.author.bot:
Expand Down
5 changes: 4 additions & 1 deletion cogs/serverlogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, client):
client.add_listener(self._on_message_delete, "on_message_delete")
client.add_listener(self._on_message_edit, "on_message_edit")
client.add_listener(self._on_member_join, "on_member_join")
client.add_listener(self._on_member_leave, "on_member_leave")
client.add_listener(self._on_member_leave, "on_member_remove")
client.add_listener(self._on_member_banned, "on_member_ban")
client.add_listener(self._on_member_unbanned, "on_member_unban")
client.add_listener(self._on_member_updated, "on_member_update")
Expand Down Expand Up @@ -139,6 +139,9 @@ async def _on_user_updated(self, before: discord.User, after: discord.User):
except discord.errors.NotFound:
return

if len(e.fields) == 0:
return

for guild in self.client.guilds:
member = discord.utils.find(lambda m: m.id == after.id, guild.members)

Expand Down

0 comments on commit ef84bd3

Please sign in to comment.