Skip to content

Commit

Permalink
[SNSConverter] Rename cog from VxTwitConverter (#659)
Browse files Browse the repository at this point in the history
* [SNSConverter] Rename cog from VxTwit

Since the cog now replaces Twitter and Instagram embeds, rename the cog
to SNSConverter.

* [SNSConverter] Replace VxTwitConverter with SNSConverter

This commit is a breaking change!

It does the following sed replacements:
- `s/vxtwitconverter/snsconverter/g`
- `s/VxTwitConverter/SNSConverter/g`
- `s/VxTwitter/SNSConverter/g`
- `s/VxTwit /SNSConverter /g`

It also renames vxtwitconverter.py file to snsconverter.py.

Since the cog name changes, the config directory changes. No attempts to
reconcile the previous config file will be made here.

Please reconfigure the cog.

* [SNSConverter] Replace remaining references of old cog

This commit replaces the remaining references of vxtwit from generic
function names and decorators to reflect the new cog name.

* [SNSConverter] Update info.json

* [SNSConverter] Reformat with black
  • Loading branch information
Injabie3 authored Oct 24, 2023
1 parent fe2de32 commit 861ba9a
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 49 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from redbot.core.bot import Red

from .vxtwitconverter import VxTwitConverter
from .snsconverter import SNSConverter


async def setup(bot: Red):
"""Add the cog to the bot."""
await bot.add_cog(VxTwitConverter(bot))
await bot.add_cog(SNSConverter(bot))
20 changes: 20 additions & 0 deletions cogs/snsconverter/commandHandlers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from redbot.core import checks, commands
from redbot.core.commands.context import Context

from .commandsCore import CommandsCore


class CommandHandlers(CommandsCore):
@commands.group(name="snsconverter", aliases=["sns"])
@checks.is_owner()
async def _grpSns(self, ctx: Context):
"""SNSConverter settings"""

@_grpSns.command(name="toggle")
async def _cmdToggle(self, ctx: Context):
"""Toggle SNSConverter replacements on the server
This will toggle the auto-reply of any Twitter or Instagram links with
embeds, and replace them with vxtwitter or ddinstagram, respectively.
"""
await self.cmdToggle(ctx)
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ async def cmdToggle(self, ctx: Context):
await enabledCfg.set(enabled)

status = "enabled" if enabled else "disabled"
await ctx.send(f"VxTwitter replacements are now {status}.")
await ctx.send(f"SNSConverter replacements are now {status}.")
File renamed without changes.
2 changes: 1 addition & 1 deletion cogs/vxtwitconverter/core.py → cogs/snsconverter/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, bot: Red):

# Initialize logger, and save to cog folder.
save_folder = data_manager.cog_data_path(cog_instance=self)
self.logger = logging.getLogger("red.luicogs.vxtwitconverter")
self.logger = logging.getLogger("red.luicogs.snsconverter")
if not self.logger.handlers:
log_path = os.path.join(save_folder, "info.log")
handler = logging.FileHandler(filename=log_path, encoding="utf-8", mode="a")
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ async def _on_message_insta_replacer(self, message: Message):

if not await self.config.guild(message.guild).get_attr(KEY_ENABLED)():
self.logger.debug(
"VxTwit disabled for guild %s (%s), skipping", message.guild.name, message.guild.id
"SNSConverter disabled for guild %s (%s), skipping",
message.guild.name,
message.guild.id,
)
return

Expand All @@ -34,7 +36,7 @@ async def _on_edit_insta_replacer(self, message_before: Message, message_after:

if not await self.config.guild(message_after.guild).get_attr(KEY_ENABLED)():
self.logger.debug(
"VxTwit disabled for guild %s (%s), skipping",
"SNSConverter disabled for guild %s (%s), skipping",
message_after.guild.name,
message_after.guild.id,
)
Expand Down Expand Up @@ -66,7 +68,9 @@ async def _on_message_twit_replacer(self, message: Message):

if not await self.config.guild(message.guild).get_attr(KEY_ENABLED)():
self.logger.debug(
"VxTwit disabled for guild %s (%s), skipping", message.guild.name, message.guild.id
"SNSConverter disabled for guild %s (%s), skipping",
message.guild.name,
message.guild.id,
)
return

Expand All @@ -91,7 +95,7 @@ async def _on_edit_twit_replacer(self, message_before: Message, message_after: M

if not await self.config.guild(message_after.guild).get_attr(KEY_ENABLED)():
self.logger.debug(
"VxTwit disabled for guild %s (%s), skipping",
"SNSConverter disabled for guild %s (%s), skipping",
message_after.guild.name,
message_after.guild.id,
)
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions cogs/snsconverter/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name" : "SNSConverter",
"author" : ["j4d3r48817", "injabie3", "quachtridat"],
"short" : "Replace Twitter/Instagram embeds with better embeds",
"description" : "Converts Twitter/Instagram links to vxtwitter/ddinstagram for better video embeds",
"install_msg" : "SNSConverter installed",
"requirements" : [],
"tags" : ["server"],
"permissions" : ["manage_messages"],
"end_user_data_statement": "no data is stored"
}
10 changes: 10 additions & 0 deletions cogs/snsconverter/snsconverter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from redbot.core import commands

from .commandHandlers import CommandHandlers
from .eventHandlers import EventHandlers


class SNSConverter(commands.Cog, CommandHandlers, EventHandlers):
"""Converts Twitter link to SNSConverter for better video embeds"""

pass
20 changes: 0 additions & 20 deletions cogs/vxtwitconverter/commandHandlers.py

This file was deleted.

11 changes: 0 additions & 11 deletions cogs/vxtwitconverter/info.json

This file was deleted.

10 changes: 0 additions & 10 deletions cogs/vxtwitconverter/vxtwitconverter.py

This file was deleted.

0 comments on commit 861ba9a

Please sign in to comment.