Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use the `@` symbol in a twitter bot without mentioning a user?

Using twitter in the normal way, you can post an @ symbol without tagging someone by using @@. E.g. @_wurli would show as a mention, but @@_wurli, while giving the same text, would not be mention.

I want to know how I can achieve this using a bot. I am using the {rtweet} package in the R language.

like image 675
wurli Avatar asked Oct 28 '25 05:10

wurli


1 Answers

I'm not sure whether or not there's an intended approach to for dealing with these. However, a good workaround I've found is to simply insert a zero-width space between the @ and the rest of the text. This also works for hashtags:

tweets <- c("@not_a_user", "#notatag")

zero_width_space <- "\U200B"

tweets <- tweets |>
  gsub(x = _, "@", paste0("@", zero_width_space)) |>
  gsub(x = _, "#", paste0("#", zero_width_space))

The only potential issue is that this adds to the number of characters in the tweet. However if you're only transforming a few characters per tweet this is most likely not going to be an issue.

like image 177
wurli Avatar answered Oct 29 '25 19:10

wurli