Jan-14-2018, 06:09 AM
Really need some help, been stuck on this for hours. So I'm working on a small Twitter bot that is using Tweepy.
I have it working so that when my Twitter account gets mentioned in a Tweet I grab what the tweet says and run it through a function that will determine what my reply is. The big issue I have is that when I get a copy of the tweet that I was in, it includes my Twitter username which will make my reply not work. For example: "@mytwitteraccount their message" I only need the "their message" part of it.
I thought the best way to remove my username from the output with there tweet was to do
Heres my code for what I'm doing to get the tweet.
I have it working so that when my Twitter account gets mentioned in a Tweet I grab what the tweet says and run it through a function that will determine what my reply is. The big issue I have is that when I get a copy of the tweet that I was in, it includes my Twitter username which will make my reply not work. For example: "@mytwitteraccount their message" I only need the "their message" part of it.
I thought the best way to remove my username from the output with there tweet was to do
s = "@mytwitter their message" ' '.join(s.split()[1:])the problem I've been having is since the output isn't a String It won't work. I've tried str() no luck.
Heres my code for what I'm doing to get the tweet.
tweets = api.search(q="@myaccount",count=100,include_entities=True) t = ['@myaccount', '@MyAccount'] for s in tweets: sn = s.user.screen_name m = "@%s my reply" % (sn) s = api.update_status(m, s.id) for result in tweets: print (result.text)Any help would be great, I looked over the Tweepy Documentation and couldn't find anything.