Skip to content

Commit

Permalink
Support x.com
Browse files Browse the repository at this point in the history
  • Loading branch information
joinemm committed Aug 17, 2023
1 parent 0e452f7 commit 2769672
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cogs/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ async def instagram(self, ctx: commands.Context, *, links: str):
await InstagramEmbedder(self.bot).process(ctx, links)

@commands.command(
aliases=["twt"],
aliases=["twt", "x"],
usage="[OPTIONS] <links...>",
)
async def twitter(self, ctx: commands.Context, *, links: str):
Expand Down
10 changes: 6 additions & 4 deletions modules/media_embedders.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ async def create_message(


class TwitterEmbedder(BaseEmbedder):
EMOJI = "<:twitter:937425165241946162>"
NO_RESULTS_ERROR = "Found no Twitter links to embed!"
EMOJI = "<:x_:1135484782642466897>"
NO_RESULTS_ERROR = "Found no Twitter/X links to embed!"

@staticmethod
def remove_tco(text: str) -> str:
Expand All @@ -369,7 +369,7 @@ def extract_links(text: str, include_id_only=True):
results = [
int(match.group(2))
for match in regex.finditer(
r"(?:https?:\/\/)?(?:www.)?twitter.com/(\w+)/status/(\d+)", text
r"(?:https?:\/\/)?(?:www.)?(?:twitter|x).com/(\w+)/status/(\d+)", text
)
]

Expand Down Expand Up @@ -447,7 +447,9 @@ async def create_message(
return {
"content": caption,
"files": files,
"view": MediaUI("View on Twitter", tweet["tweetURL"]),
"view": MediaUI(
"View on X", f"https://x.com/{screen_name}/status/{tweet_id}"
),
}


Expand Down

0 comments on commit 2769672

Please sign in to comment.