Skip to content

Commit 537c07d

Browse files
Update main.py
v1.1.7 (11/28/2024) 🛠️ Enhancements - Removed TikTok Support - Removed support for TikTok links as Discord has officially added native support for TikTok. This simplifies the codebase and leverages Discord's improved handling. 🗒️ Documentation - Updated Documentation - Updated documentation to reflect the removal of TikTok support. All references to the TikTok service have been removed. 🚷 Bug Fixes - Updated Deprecated Function - Replaced commands.AutoShardBot with commands.Bot, which is the non-deprecated function, ensuring compatibility with the latest API changes.
1 parent 0d3f252 commit 537c07d

File tree

1 file changed

+16
-45
lines changed

1 file changed

+16
-45
lines changed

main.py

Lines changed: 16 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
from collections import deque
1515

1616
# Version number
17-
VERSION = "1.1.6"
17+
VERSION = "1.1.7"
1818

1919
# Initialize logging
2020
logging.basicConfig(level=logging.INFO)
2121

2222
# Bot configuration
2323
intents = discord.Intents.default()
2424
intents.message_content = True
25-
client = commands.AutoShardedBot(shard_count=10, command_prefix='/', intents=intents)
25+
client = commands.Bot(command_prefix='/', intents=intents, shard_count=10)
2626

2727
# In-memory storage for channel states and settings
2828
channel_states = {}
@@ -87,7 +87,7 @@ async def load_settings(db):
8787
async with db.execute('SELECT guild_id, enabled_services, mention_users, delete_original FROM guild_settings') as cursor:
8888
async for row in cursor:
8989
guild_id, enabled_services, mention_users, delete_original = row
90-
enabled_services_list = eval(enabled_services) if enabled_services else ["Twitter", "TikTok", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"]
90+
enabled_services_list = eval(enabled_services) if enabled_services else ["Twitter", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"]
9191
bot_settings[guild_id] = {
9292
"enabled_services": enabled_services_list,
9393
"mention_users": mention_users if mention_users is not None else True,
@@ -138,7 +138,7 @@ async def on_ready():
138138
client.launch_time = discord.utils.utcnow()
139139

140140
statuses = itertools.cycle([
141-
"for Twitter links", "for Reddit links", "for TikTok links", "for Instagram links", "for Threads links", "for Pixiv links", "for Bluesky links"
141+
"for Twitter links", "for Reddit links", "for Instagram links", "for Threads links", "for Pixiv links", "for Bluesky links"
142142
])
143143

144144
@tasks.loop(seconds=60)
@@ -208,7 +208,6 @@ async def about(interaction: discord.Interaction):
208208
"- [FxTwitter](https://github.com/FixTweet/FxTwitter), created by FixTweet\n"
209209
"- [InstaFix](https://github.com/Wikidepia/InstaFix), created by Wikidepia\n"
210210
"- [vxReddit](https://github.com/dylanpdx/vxReddit), created by dylanpdx\n"
211-
"- [vxtiktok](https://github.com/dylanpdx/vxtiktok), created by dylanpdx\n"
212211
"- [fixthreads](https://github.com/milanmdev/fixthreads), created by milanmdev\n"
213212
"- [phixiv](https://github.com/thelaao/phixiv), created by thelaao\n"
214213
"- [VixBluesky](https://github.com/Rapougnac/VixBluesky), created by Rapougnac"
@@ -259,7 +258,7 @@ async def debug_info(interaction: discord.Interaction, channel: Optional[discord
259258
)
260259

261260
create_footer(embed, client)
262-
await interaction.response.send_message(embed=embed, view=SettingsView(interaction, bot_settings.get(interaction.guild.id, {"enabled_services": ["Twitter", "TikTok", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"], "mention_users": True, "delete_original": True})))
261+
await interaction.response.send_message(embed=embed, view=SettingsView(interaction, bot_settings.get(interaction.guild.id, {"enabled_services": ["Twitter", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"], "mention_users": True, "delete_original": True})))
263262

264263
class SettingsDropdown(ui.Select):
265264

@@ -334,10 +333,10 @@ async def callback(self, interaction: discord.Interaction):
334333
view = MentionUsersSettingsView(mention_users, self.interaction, self.settings)
335334
await interaction.response.send_message(embed=embed, view=view, ephemeral=True)
336335
elif self.values[0] == "Service Settings":
337-
enabled_services = self.settings.get("enabled_services", ["Twitter", "TikTok", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"])
336+
enabled_services = self.settings.get("enabled_services", ["Twitter", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"])
338337
service_status_list = "\n".join([
339338
f"{'🟢' if service in enabled_services else '🔴'} {service}"
340-
for service in ["Twitter", "TikTok", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"]
339+
for service in ["Twitter", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"]
341340
])
342341
embed = discord.Embed(
343342
title="Service Settings",
@@ -355,13 +354,13 @@ def __init__(self, interaction, parent_view, settings):
355354
self.interaction = interaction
356355
self.parent_view = parent_view
357356
self.settings = settings
358-
enabled_services = settings.get("enabled_services", ["Twitter", "TikTok", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"])
357+
enabled_services = settings.get("enabled_services", ["Twitter", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"])
359358
options = [
360359
discord.SelectOption(
361360
label=service,
362361
description=f"Activate or deactivate {service} links",
363362
emoji="✅" if service in enabled_services else "❌")
364-
for service in ["Twitter", "TikTok", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"]
363+
for service in ["Twitter", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"]
365364
]
366365
super().__init__(placeholder="Select services to activate...",
367366
min_values=1,
@@ -381,7 +380,7 @@ async def callback(self, interaction: discord.Interaction):
381380

382381
service_status_list = "\n".join([
383382
f"{'🟢' if service in selected_services else '🔴'} {service}"
384-
for service in ["Twitter", "TikTok", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"]
383+
for service in ["Twitter", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"]
385384
])
386385
embed = discord.Embed(
387386
title="Service Settings",
@@ -563,7 +562,7 @@ async def on_timeout(self):
563562
@client.tree.command(name='settings', description="Configure FixEmbed's settings")
564563
async def settings(interaction: discord.Interaction):
565564
guild_id = interaction.guild.id
566-
guild_settings = bot_settings.get(guild_id, {"enabled_services": ["Twitter", "TikTok", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"], "mention_users": True, "delete_original": True})
565+
guild_settings = bot_settings.get(guild_id, {"enabled_services": ["Twitter", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"], "mention_users": True, "delete_original": True})
567566

568567
embed = discord.Embed(title="Settings",
569568
description="Configure FixEmbed's settings",
@@ -578,22 +577,22 @@ async def on_message(message):
578577

579578
guild_id = message.guild.id
580579
guild_settings = bot_settings.get(guild_id, {
581-
"enabled_services": ["Twitter", "TikTok", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"],
580+
"enabled_services": ["Twitter", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"],
582581
"mention_users": True,
583582
"delete_original": True
584583
})
585-
enabled_services = guild_settings.get("enabled_services", ["Twitter", "TikTok", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"])
584+
enabled_services = guild_settings.get("enabled_services", ["Twitter", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"])
586585
mention_users = guild_settings.get("mention_users", True)
587586
delete_original = guild_settings.get("delete_original", True)
588587

589588
if channel_states.get(message.channel.id, True):
590589
try:
591590
# Standard link pattern to capture all the relevant links
592-
link_pattern = r"https?://(?:www\.)?(twitter\.com/\w+/status/\d+|x\.com/\w+/status/\d+|tiktok\.com/@[^/]+/video/\d+|tiktok\.com/t/\w+|instagram\.com/(?:p|reel)/[\w-]+|reddit\.com/r/\w+/s/\w+|reddit\.com/r/\w+/comments/\w+/\w+|old\.reddit\.com/r/\w+/comments/\w+/\w+|pixiv\.net/(?:en/)?artworks/\d+|vm\.tiktok\.com/\w+|threads\.net/@[^/]+/post/[\w-]+|bsky\.app/profile/[^/]+/post/[\w-]+)"
591+
link_pattern = r"https?://(?:www\.)?(twitter\.com/\w+/status/\d+|x\.com/\w+/status/\d+|instagram\.com/(?:p|reel)/[\w-]+|reddit\.com/r/\w+/s/\w+|reddit\.com/r/\w+/comments/\w+/\w+|old\.reddit\.com/r/\w+/comments/\w+/\w+|pixiv\.net/(?:en/)?artworks/\d+|threads\.net/@[^/]+/post/[\w-]+|bsky\.app/profile/[^/]+/post/[\w-]+)"
593592
matches = re.findall(link_pattern, message.content)
594593

595594
# Regex pattern to detect links surrounded by < >
596-
surrounded_link_pattern = r"<https?://(?:www\.)?(twitter\.com/\w+/status/\d+|x\.com/\w+/status/\d+|tiktok\.com/@[^/]+/video/\d+|tiktok\.com/t/\w+|instagram\.com/(?:p|reel)/[\w-]+|reddit\.com/r/\w+/s/\w+|reddit\.com/r/\w+/comments/\w+/\w+|old\.reddit\.com/r/\w+/comments/\w+/\w+|pixiv\.net/(?:en/)?artworks/\d+|vm\.tiktok\.com/\w+|threads\.net/@[^/]+/post/[\w-]+|bsky\.app/profile/[^/]+/post/[\w-]+)>"
595+
surrounded_link_pattern = r"<https?://(?:www\.)?(twitter\.com/\w+/status/\d+|x\.com/\w+/status/\d+|instagram\.com/(?:p|reel)/[\w-]+|reddit\.com/r/\w+/s/\w+|reddit\.com/r/\w+/comments/\w+/\w+|old\.reddit\.com/r/\w+/comments/\w+/\w+|pixiv\.net/(?:en/)?artworks/\d+|threads\.net/@[^/]+/post/[\w-]+|bsky\.app/profile/[^/]+/post/[\w-]+)>"
597596

598597
valid_link_found = False
599598

@@ -615,33 +614,6 @@ async def on_message(message):
615614
user_or_community = user_match[
616615
0] if user_match else "Unknown"
617616

618-
elif 'tiktok.com/@' in original_link:
619-
service = "TikTok"
620-
tiktok_match = re.search(
621-
r"tiktok\.com/@([^/]+)/video/(\d+)", original_link)
622-
if tiktok_match:
623-
user_or_community = tiktok_match.group(1)
624-
video_id = tiktok_match.group(2)
625-
modified_link = f"vxtiktok.com/@{user_or_community}/video/{video_id}"
626-
display_text = f"TikTok • @{user_or_community}"
627-
628-
elif 'tiktok.com/t/' in original_link:
629-
service = "TikTok"
630-
tiktok_match = re.search(r"tiktok\.com/t/(\w+)",
631-
original_link)
632-
if tiktok_match:
633-
user_or_community = tiktok_match.group(1)
634-
modified_link = f"vxtiktok.com/t/{user_or_community}"
635-
display_text = f"TikTok • {user_or_community}"
636-
637-
elif 'vm.tiktok.com' in original_link:
638-
service = "TikTok"
639-
tiktok_match = re.search(r"vm\.tiktok\.com/(\w+)", original_link)
640-
if tiktok_match:
641-
user_or_community = tiktok_match.group(1)
642-
modified_link = f"vxtiktok.com/{user_or_community}"
643-
display_text = f"TikTok • {user_or_community}"
644-
645617
elif 'instagram.com' in original_link:
646618
service = "Instagram"
647619
user_match = re.findall(r"instagram\.com/(?:p|reel)/([\w-]+)",
@@ -683,7 +655,6 @@ async def on_message(message):
683655
display_text = f"{service}{user_or_community}"
684656
modified_link = original_link.replace("twitter.com", "fxtwitter.com")\
685657
.replace("x.com", "fixupx.com")\
686-
.replace("tiktok.com", "vxtiktok.com")\
687658
.replace("instagram.com", "g.ddinstagram.com")\
688659
.replace("reddit.com", "vxreddit.com")\
689660
.replace("old.reddit.com", "vxreddit.com")\
@@ -716,7 +687,7 @@ async def on_guild_join(guild):
716687
guild_id = guild.id
717688
if guild_id not in bot_settings:
718689
bot_settings[guild_id] = {
719-
"enabled_services": ["Twitter", "TikTok", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"],
690+
"enabled_services": ["Twitter", "Instagram", "Reddit", "Threads", "Pixiv", "Bluesky"],
720691
"mention_users": True,
721692
"delete_original": True
722693
}

0 commit comments

Comments
 (0)