Skip to content

Commit

Permalink
feat(parsing.utils): support chat-specific hashtags by allowing '@'
Browse files Browse the repository at this point in the history
Telegram recently added a feature called "chat-specific hashtags,"
formatting as `#hashtag@username`. However, '@' was escaped, resulting
in these hashtags being broken.

Properly supports such hashtags by allowing '@' in hashtags.

Signed-off-by: Rongrong <[email protected]>
  • Loading branch information
Rongronggg9 committed Nov 6, 2024
1 parent 067606b commit 37d8c96
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/parsing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,15 @@
)
INVALID_CHARACTERS_IN_HASHTAG: Final[str] = ''.join(
sorted(
# Known characters that break hashtags. Though '・' breaks hashtags, it is not the case of '·'.
set(chain(SPACES, INVALID_CHARACTERS, string.punctuation, string.whitespace, '・'))
# Known characters that break hashtags.
set(chain(
SPACES, INVALID_CHARACTERS, string.punctuation, string.whitespace,
'・', # Though '・' breaks hashtags, it is not the case of '·'.
))
# Characters included in `string.punctuation` but valid in hashtags.
- set(
'@' # Used in "chat-specific hashtags".
)
)
)

Expand Down

0 comments on commit 37d8c96

Please sign in to comment.