Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Commit

Permalink
Added the ability to show meda as evidence
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisMayo committed Apr 22, 2021
1 parent 068627e commit ab212d4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ace-attorney-reddit-bot
10 changes: 10 additions & 0 deletions comment_list_brige.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import requests

class Comment:
def __init__(self, tweet):
self.author = Author(tweet.user.name)
self.body = tweet.full_text
if (len(self.body) == 0):
self.body = '...'
self.score = 0
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

class Author:
def __init__(self, name):
Expand Down
16 changes: 15 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,30 @@ def process_tweets():
except Exception as second_error:
print(second_error)
print(e)
os.remove(output_filename)
clean(thread, output_filename)
else:
try:
api.update_status('@' + tweet.author.screen_name + " There should be at least two people in the conversation", in_reply_to_status_id=tweet.id_str)
except Exception as e:
print(e)
time.sleep(1)
except Exception as e:
clean(thread, output_filename)
print(e)


def clean(thread, output_filename):
try:
os.remove(output_filename)
except Exception as second_e:
print(second_e)
try:
for comment in thread:
if (hasattr(comment, 'evidence')):
os.remove(comment.evidence)
except Exception as second_e:
print(second_e)

def restore_account():
global mention_queue
global next_account
Expand Down

0 comments on commit ab212d4

Please sign in to comment.