forked from LuisMayo/ace-attorney-twitter-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
comment_list_brige.py
19 lines (18 loc) · 996 Bytes
/
comment_list_brige.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import requests
from objection_engine.beans.comment import Comment as obj_comment
class Comment:
def __init__(self, tweet):
self.author_name = tweet.user.name
self.author_id = tweet.user.id_str
self.body = tweet.full_text
self.evidence = None
if (hasattr(tweet,'extended_entities') and tweet.extended_entities is not None
and 'media' in tweet.extended_entities and len(tweet.extended_entities['media']) > 0):
url = tweet.extended_entities['media'][0]['media_url_https'] + '?format=png&name=small'
name = tweet.extended_entities['media'][0]['media_url_https'].split('/')[-1] + '.png'
response = requests.get(url)
with open(name, 'wb') as file:
file.write(response.content)
self.evidence = name
def to_message(self) -> obj_comment:
return obj_comment(user_id=self.author_id, user_name = self.author_name, text_content=self.body, evidence_path=self.evidence)