简体   繁体   English

如何在不提及用户的情况下在 twitter 机器人中使用“@”符号?

[英]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 @@ .以正常方式使用 twitter,您可以发布@符号,而无需使用@@标记某人。 Eg @_wurli would show as a mention, but @@_wurli , while giving the same text , would not be mention.例如@_wurli会显示为提及,但@@_wurli会给出相同的文本,但不会被提及。

I want to know how I can achieve this using a bot.我想知道如何使用机器人实现这一目标。 I am using the {rtweet} package in the R language.我正在使用 R 语言的 {rtweet} package。

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.但是,我发现一个很好的解决方法是在文本的@和 rest 之间简单地插入一个零宽度空格。 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.但是,如果您只是在每条推文中转换几个字符,这很可能不会成为问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用函数参数而不在函数体中提及它? - How can a function parameter be used without mentioning it in the function body? R数据框如何只使用列名而不每次都提到变量 - R data frame how to use only column names without mentioning variable everytime 如何获得Twitter用户名列表(按其位置)? - How can I get the list of Twitter user names by their location? 如何使用正则表达式解析 R 中的 OCC 选项符号? - How can I use regex to parse an OCC Option Symbol in R? 我有两列提到治疗前后的观察结果。 如何计算每个观察值的百分比变化? - I have two columns mentioning observations before and after treatment. How can I calculate percentage change in for each observation? 如何在没有for循环的情况下使用RStan? - How can I use RStan without for loops? R:如何在数据框的提取符号$中使用循环变量i? - R: How can I use loop variable i in the extract symbol $ of a dataframe? as.Date() 不提及“起源” - as.Date() without mentioning “origin” 如何将原子向量转换为可以在R中使用“ $”符号的递归向量? - How to convert an atomic vector to a recursive vector where I can use “$” symbol in R? 如何在R中使用子函数更改具有加号(+)的因子水平? - How can I use a sub function in R to change a factor level that has a plus (+ ) symbol?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM