How to ignore replies #1373
-
I'm doing a bot that replies mentions. The problem is that, if someone replies its tweet, tweepy consider it a mention. For example: To get mentions I'm using the following code: Is possible to make tweepy doesn't consider replies as a mention? Or maybe use a statement or method to filter replies and mentions properly? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
Use
|
Beta Was this translation helpful? Give feedback.
-
I've already done it. The bot is replying fine. The problem is that if someone replies its reply, it replies again. For example if you answer the bot, its will answer you. I want it to give just one reply, ignoring the next answers of it. I was thinking in change the way to find tweets, searching for the mentions using a keyword '@mybotname', instead api.mentions. But I don't know if it will change something. |
Beta Was this translation helpful? Give feedback.
-
Oh I see. Assuming someone else always initiates why not check on the incoming tweet that the in_reply_to_user is not set and only then reply. When someone tweets at your bot, the value will not be set as it's an original message. Then your bot replies. Then they reply to your reply and the reply status and reply user fields are set and have values therefore you ignore. |
Beta Was this translation helpful? Give feedback.
-
If their first message to you is a reply to your bots original tweet then it's harder but maybe less likely case. Then you have to lookup your original bot's tweet which is set as in reply to ID on their tweet and check if your tweet's in reply to field is not set i.e. it is an original tweet and then its fine to reply to the user as it is their first message to you |
Beta Was this translation helpful? Give feedback.
-
I see it. But it will work only if the mention is a tweet, right? Let's suppose, if person X do a tweet, and person Y mention my bot as a reply to X tweet. The in_reply_to_status will be already defined right? So my bot won't answer, will it? |
Beta Was this translation helpful? Give feedback.
-
I don't understand. All messages are tweets. Some tweets are mentions of users. Some are replies with have reply field set and normally include a mention unless someone removes it If someone mentions your bot in reply to someone else's tweet as you say then reply to status will be as to person's X tweet and "in reply to user" will be set person X. So you'll have to figure out if you want to reply or not. |
Beta Was this translation helpful? Give feedback.
-
You can use the |
Beta Was this translation helpful? Give feedback.
You can use the
in_reply_to_status_id
,in_reply_to_status_id_str
,in_reply_to_user_id
,in_reply_to_user_id_str
, and/orin_reply_to_screen_name
attributes of a Status/Tweet object to determine if a Tweet is a reply and what Tweet and who it's in reply to.