Releases: Dan6erbond/Banhammer.py
Releases · Dan6erbond/Banhammer.py
v2.5.4-beta
Change Log
- Add
RedditItem.to_dict()
includingurl
,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:
v2.5.3-beta
Hotfix
Fix reverse logic of event filters. (#52)
v2.5.2-beta
v2.5.1-beta
Change Log
- Catching handler errors, forwarded to
on_handler_error()
and converting timestamps properly. (#48)
2.5.0-beta
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
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()
andget_subreddits_embed()
. (#42)- Add
Subreddit.get_reactions_embed()
extension toMessageBuilder.get_subreddit_reactions_embed()
.
- Add
- Make
Subreddit.get_contact_url()
auto-propertycontact_url
. (#42) - Add
embed_template
argument toclass MessageBuilder
methods that return embeds. (#43)- Make use of
*args
and**kwargs
in extension methods.
- Make use of
- Make
class ReactionPayload
serializable withto_dict()
method and includeperformed_utc
attribute asdatetime
. (#44) - Add
Reaction.SCHEMA
andschema
argument inReaction.__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
inreddit_helper
. (#35) - Fix missing/cyclic imports. (#42)
Other:
- Update docstrings and typing.
v2.3.4-beta
Change Log
- Add
MessageBuilder.get_payload_message()
andget_payload_embed()
.- Add extension methods in
class ReactionPayload
.
- Add extension methods in
- Use RegEx in
reddit_helper.get_item_from_url()
.
Fixes:
- Fix usage of
author_name
inclass MessageBuilder
. - Fix
reddit_helper.get_item_from_url()
returning comments instead of submissions.
v2.3.3-beta
Hotfix
- Fix usage of
subreddit
inMessageBuilder.get_item_embed()
and replace withitem.subreddit
. (#28)
v2.3.2-beta
Hotfix
- Remove redundant markdown escaping from embed author fields. (#26)
v2.3.1-beta
Hotfix
- Fixes usage of
discord.utils.escape_markdown
.