Skip to content

Refactor common/linker.py #350

@CoderJoshDK

Description

@CoderJoshDK

Issue is written assuming #340 is merged

The usage pattern of hooks is one where a factory (create_edit_hook) builds the listener logic of on_message_edit:

@commands.Cog.listener()
async def on_message_edit(self, before: dc.Message, after: dc.Message) -> None:
return await create_edit_hook(
linker=self.comment_linker,
message_processor=self.comment_processor,
interactor=self.reply_with_comments,
view_type=CommentActions,
)(before, after)

However, this is funky looking logic. Besides the fact that it is highly repetitive. This section of code is very ripe for some type of refactor. Perhaps could be improved by making an abstract cog class that you plug in your various controlling functions.

Talks about this were made on the discord + #340 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    internalTooling and non-user-facing improvements

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions