Implement tweet filtering

master
Nikola Forró 4 years ago
parent 8e05b9e711
commit b502d08256

@ -64,6 +64,7 @@ class Bot(discord.Client):
super().__init__()
async def process_event(self, service, data):
await self.wait_until_ready()
action = getattr(self, 'process_{0}_event'.format(service))
await action(data)
@ -124,10 +125,31 @@ class Bot(discord.Client):
api = self.get_twitter_api(user_id)
if not api:
return
await self.wait_until_ready()
channel = self.get_channel(twitter_channel_id)
if channel:
for tweet in tweets:
if tweet.get('user', {}).get('id_str') == user_id:
retweeted = tweet.get('retweeted_status')
if retweeted:
tweet = retweeted
else:
quoted = tweet.get('quoted_status')
if quoted:
tweet = quoted
else:
reply_to = tweet.get('in_reply_to_status_id_str')
if reply_to:
original = api.get_status(reply_to)
if original:
await channel.send(embed=self.make_twitter_embed(original))
elif tweet.get('user', {}).get('verified'):
reply_to = tweet.get('in_reply_to_status_id_str')
if reply_to:
original = api.get_status(reply_to)
if original:
await channel.send(embed=self.make_twitter_embed(original))
else:
continue
await channel.send(embed=self.make_twitter_embed(tweet))
def format_remainder(self, seconds):

Loading…
Cancel
Save