Compare commits

..

No commits in common. "master" and "extremely-experimental" have entirely different histories.

5 changed files with 20 additions and 40 deletions

View File

@ -1,4 +1,4 @@
[bumpversion]
current_version = 0.2.0
current_version = 0.1.1
commit = True
tag = True

View File

@ -1,5 +1,5 @@
**v0.2.0**
**unreleased v0.2.0**
- Fix: Fetch channels if not found in bot cache (error fix)
- Enhancement: command to test a channel's permissions allow for the Bot to function

View File

@ -102,7 +102,7 @@ class CommandsCog(commands.Cog):
)
@view_group.command(name="subscriptions")
async def cmd_list_subs(self, inter: Interaction, search: str = ""):
async def cmd_list_subs(self, inter: Interaction):
"""List Subscriptions from this server."""
await inter.response.defer()
@ -126,10 +126,7 @@ class CommandsCog(commands.Cog):
async with aiohttp.ClientSession() as session:
api = API(self.bot.api_token, session)
return await api.get_subscriptions(
guild_id=inter.guild.id,
page=page,
page_size=pagesize,
search=search
guild_id=inter.guild.id, page=page, page_size=pagesize
)
embed = Followup(f"Subscriptions in {inter.guild.name}").info()._embed
@ -145,7 +142,7 @@ class CommandsCog(commands.Cog):
await pagination.send()
@view_group.command(name="tracked-content")
async def cmd_list_tracked(self, inter: Interaction, search: str = ""):
async def cmd_list_tracked(self, inter: Interaction):
"""List Tracked Content from this server, or a given sub"""
await inter.response.defer()
@ -157,17 +154,14 @@ class CommandsCog(commands.Cog):
links = f"[Content Link]({item.url}) · [Message Link](https://discord.com/channels/{sub.guild_id}/{item.channel_id}/{item.message_id}/)"
description = f"Subscription: {sub.name}\n{links}"
key = f"{item.id}. {item.title}"
key = f"{index}. {item.title}"
return key, description
async def getdata(page: int, pagesize: int):
async with aiohttp.ClientSession() as session:
api = API(self.bot.api_token, session)
return await api.get_tracked_content(
subscription__guild_id=inter.guild_id,
page=page,
page_size=pagesize,
search=search
subscription__guild_id=inter.guild_id, page=page, page_size=pagesize
)
embed = Followup(f"Tracked Content in {inter.guild.name}").info()._embed

View File

@ -65,24 +65,13 @@ class TaskCog(commands.Cog):
"""
self.subscription_task.cancel()
group = app_commands.Group(
name="task",
description="Commands for tasks",
guild_only=True
)
@group.command(name="trigger")
async def cmd_trigger_task(self, inter):
@app_commands.command(name="debug-trigger-task")
async def debug_trigger_task(self, inter):
await inter.response.defer()
start_time = perf_counter()
try:
await self.subscription_task()
except Exception as error:
await inter.followup.send(str(error))
finally:
end_time = perf_counter()
await inter.followup.send(f"completed in {end_time - start_time:.4f} seconds")
await self.subscription_task()
end_time = perf_counter()
await inter.followup.send(f"completed in {end_time - start_time:.4f} seconds")
@tasks.loop(time=subscription_task_times)
async def subscription_task(self):
@ -210,7 +199,7 @@ class TaskCog(commands.Cog):
continue
blocked = any(self.filter_item(_filter, item) for _filter in filters)
mutated_item = item.create_mutated_copy(sub.mutators) if sub.mutators else None
mutated_item = item.create_mutated_copy(sub.mutators)
for channel in channels:
await self.track_and_send(sub, feed, item, mutated_item, channel, blocked)
@ -236,7 +225,7 @@ class TaskCog(commands.Cog):
log.debug("filter match found? '%s'", match_found)
return match_found
async def track_and_send(self, sub: Subscription, feed: RSSFeed, item: RSSItem, mutated_item: RSSItem | None, channel: TextChannel, blocked: bool):
async def track_and_send(self, sub: Subscription, feed: RSSFeed, item: RSSItem, mutated_item: RSSItem, channel: TextChannel, blocked: bool):
message_id = -1
log.debug("track and send func %s, %s", item.guid, item.title)
@ -254,8 +243,7 @@ class TaskCog(commands.Cog):
if not blocked:
try:
log.debug("sending '%s', exists '%s'", item.guid, result[1])
sendable_item = mutated_item or item
message = await channel.send(embed=await sendable_item.to_embed(sub, feed, self.api.session))
message = await channel.send(embed=await mutated_item.to_embed(sub, feed, self.api.session))
message_id = message.id
except Forbidden:
log.error(f"Forbidden to send to channel {channel.id}")

View File

@ -51,13 +51,13 @@ class RSSItem:
RSSItem
"""
guid = entry.get('id', None) or entry.get("guid")
link = entry.get('link', "")
title = entry.get('title', "")
description = entry.get('description', "")
guid = entry.get('id', None) or entry.get("guid", None)
link = entry.get('link', None)
title = entry.get('title', None)
description = entry.get('description', None)
pub_date = entry.get('published_parsed', None)
pub_date = datetime(*pub_date[0:6] if pub_date else None, tzinfo=timezone.utc)
pub_date = datetime(*pub_date[0:6], tzinfo=timezone.utc)
content_image_url = entry.get("media_content", [{}])[0].get("url")
thumb_image_url = entry.get("media_thumbnail", [{}])[0].get("url")
@ -128,8 +128,6 @@ class RSSItem:
discord.Embed
"""
log.debug("Creating embed of item: %s", self.guid)
# Replace HTML with Markdown, and shorten text.
title = shorten(markdownify(self.title, strip=["img", "a"]), 256)
desc = shorten(markdownify(self.description, strip=["img"]), 4096)