Skip to content

Releases: Dan6erbond/Banhammer.py

v2.5.4-beta

08 Aug 09:00
Compare
Choose a tag to compare
v2.5.4-beta Pre-release
Pre-release

Change Log

  • Add RedditItem.to_dict() including url, author, type, source, body. (#59)
  • Make ReactionPayload.to_dict() async method. (#59)
  • Include first comment in reaction YAMLs as name in embed, or surround emoji with ``. (#58)
  • Only include first paragraph of reaction replies in embeds. (#58)
  • Only add reports if present; include mod reports in separate embed field. (#57)
  • Handle individual event handlers for more detailed logs. (#57)

Breaking Changes:

  • RedditItem.get_reactions() has been refactored to RedditItem.reactions. (#60)
  • ReactionPayload.to_dict() serializes class RedditItem manually; schema has been changed. (#59)

v2.5.3-beta

30 Jul 04:12
Compare
Choose a tag to compare
v2.5.3-beta Pre-release
Pre-release

Hotfix

Fix reverse logic of event filters. (#52)

v2.5.2-beta

29 Jul 17:00
Compare
Choose a tag to compare
v2.5.2-beta Pre-release
Pre-release

Change Log

  • Fix reverse event filters and simplify evaluation of valid items. (#50)
  • Use existing Discord.py event loop if available. (#50)

v2.5.1-beta

29 Jul 13:58
Compare
Choose a tag to compare
v2.5.1-beta Pre-release
Pre-release

Change Log

  • Catching handler errors, forwarded to on_handler_error() and converting timestamps properly. (#48)

2.5.0-beta

29 Jul 13:07
Compare
Choose a tag to compare
2.5.0-beta Pre-release
Pre-release

This update allows users to create a class-based Banhammer bot which can be integrated with the commands.Bot extension from Discord.py. Resulting in much cleaner code than standalone functions that cannot access internal properties and methods the way one might be used to. For more information see #46.

Such a bot could look as follows:

class Banhacker(Bot, Banhammer):

    def __init__(self, **options):
        super().__init__(
            bh_config["command_prefix"],
            description="The Banhacker bot built for Discord's Hack-Week based on the Banhammer framework.",
            **options)
        Banhammer.__init__(self, reddit, bot=self, change_presence=bh_config["change_presence"])

    @property
    def embed(self):
        embed = discord.Embed(colour=self.embed_color)
        embed.set_footer(text=self.user.name, icon_url=self.user.avatar_url)
        embed.timestamp = datetime.now()
        return embed

    async def on_command_error(self, ctx: commands.Context, error):
        print(error)

    async def on_ready(self):
        print(str(self.user) + ' is running.')

        for sub in bh_config["subreddits"]:
            s = Subreddit(self, **sub)
            await s.load_reactions()
            await self.add_subreddits(s)

        Banhammer.start(self)

    @EventHandler.new()
    @EventHandler.comments()
    async def handle_new(self, p: RedditItem):
        msg = await self.get_channel(bh_config["new_channel"]).send(embed=await p.get_embed(embed_template=self.embed))
        await p.add_reactions(msg)

    @EventHandler.mod_actions()
    @EventHandler.filter(ItemAttribute.MOD, "Anti-Evil Operations", "Dan6erbond")
    async def handle_actions(self, p: RedditItem):
        msg = await self.get_channel(bh_config["actions_channel"]).send(embed=await p.get_embed(embed_template=self.embed))
        await p.add_reactions(msg)

Note: Bot using the old decorators such as bot.new() will continue to work, as this change only modifies the framework internally and enables the creation of classes inheriting from class Banhammer. Filters can be applied to the old-style callbacks simply by adding @EventHandler.filter() to the decorator list.

v2.4.0-beta

29 Jul 12:59
Compare
Choose a tag to compare
v2.4.0-beta Pre-release
Pre-release

Change Log

  • Add richer embeds; support for image galleries, polls, third-party image sites and more. (#41)
  • Add MessageBuilder.get_reactions_embed(), get_subreddit_reactions_embed() and get_subreddits_embed(). (#42)
    • Add Subreddit.get_reactions_embed() extension to MessageBuilder.get_subreddit_reactions_embed().
  • Make Subreddit.get_contact_url() auto-property contact_url. (#42)
  • Add embed_template argument to class MessageBuilder methods that return embeds. (#43)
    • Make use of *args and **kwargs in extension methods.
  • Make class ReactionPayload serializable with to_dict() method and include performed_utc attribute as datetime. (#44)
  • Add Reaction.SCHEMA and schema argument in Reaction.__init__() for default values and easier usage. (#45)
  • Add Reaction.copy() creating an identical copy for easier modification of reactions in e.g. class ReactionHandler without changing base. (#45)

Fixes:

  • Fix local variable 'item' referenced before assignment in reddit_helper. (#35)
  • Fix missing/cyclic imports. (#42)

Other:

  • Update docstrings and typing.

v2.3.4-beta

26 Jul 14:54
Compare
Choose a tag to compare
v2.3.4-beta Pre-release
Pre-release

Change Log

  • Add MessageBuilder.get_payload_message() and get_payload_embed().
    • Add extension methods in class ReactionPayload.
  • Use RegEx in reddit_helper.get_item_from_url().

Fixes:

  • Fix usage of author_name in class MessageBuilder.
  • Fix reddit_helper.get_item_from_url() returning comments instead of submissions.

v2.3.3-beta

26 Jul 11:16
Compare
Choose a tag to compare
v2.3.3-beta Pre-release
Pre-release

Hotfix

  • Fix usage of subreddit in MessageBuilder.get_item_embed() and replace with item.subreddit. (#28)

v2.3.2-beta

26 Jul 08:52
Compare
Choose a tag to compare
v2.3.2-beta Pre-release
Pre-release

Hotfix

  • Remove redundant markdown escaping from embed author fields. (#26)

v2.3.1-beta

26 Jul 08:38
Compare
Choose a tag to compare
v2.3.1-beta Pre-release
Pre-release

Hotfix

  • Fixes usage of discord.utils.escape_markdown.