File size: 3,899 Bytes
d71f362
 
 
 
 
19d1256
d71f362
 
 
 
 
 
449b7fd
d71f362
 
449b7fd
d71f362
 
 
 
 
 
 
 
 
 
 
449b7fd
d71f362
449b7fd
 
 
d71f362
 
 
 
 
 
449b7fd
d71f362
 
449b7fd
d71f362
 
449b7fd
 
 
 
 
6d1b1bb
d71f362
6d1b1bb
 
d71f362
 
 
449b7fd
 
d71f362
 
 
 
449b7fd
d71f362
 
 
 
 
 
 
 
 
 
 
 
 
11a8339
d71f362
 
11a8339
d71f362
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19d1256
 
 
c5cb1c8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# # from git import Repo
# import os
# import streamlit as st
# import dateutil
# import datetime

# import translators as ts
# import translators.server as tss
# import random
# import tweepy
# import time
# import json

# time_now = datetime.datetime.now()
# last_minute = time_now - dateutil.relativedelta.relativedelta(minutes=1)

# # st.set_page_config(
# #     page_title="TRACING INSIGHTS",
# #     page_icon=None,
# #     layout="wide",
# #     #initial_sidebar_state="expanded",
# #     # menu_items={
# #     #     'Get Help': 'https://www.extremelycoolapp.com/help',
# #     #     'Report a bug': "https://www.extremelycoolapp.com/bug",
# #     #     'About': "# This is a header. This is an *extremely* cool app!"
# #     # }
# # )

# st.write("Hello world!")



# GITHUB_PAT = os.environ['GITHUB']
# api_key = os.environ['api_key']
# secret_api_key = os.environ['secret_api_key']
# access_token = os.environ['access_token']
# secret_access_token = os.environ['secret_access_token']
# bearer_token = os.environ['bearer_token']

# # if not os.path.exists('repo_directory'):  
# #     Repo.clone_from(f'https://tracinginsights:{GITHUB_PAT}@github.com/TracingInsights/translator.git', 'repo_directory'  )

# # from repo_directory import translator
# # translator.auth(api_key,secret_api_key,access_token,secret_access_token)






# # works with tweets and replies too


# def translate(bearer_token,api_key,secret_api_key,access_token,secret_access_token):
#     # update users when you want to include more accounts
#     users = [1568348454619070465,2755544640, 1030481714, 407048032,227265199,190632194, 149542215,127854979, 106170617]
                               
    
#     api = tweepy.Client(bearer_token=bearer_token, consumer_key=api_key,
#                     consumer_secret=secret_api_key, access_token=access_token,
#                     access_token_secret=secret_access_token,wait_on_rate_limit=True
#                     )
    
#     #loops endlessly(60 sec interval) and checks,translates,and posts tweets
#     # use this to get user id https://tweeterid.com/
#     latest_tweet_id = 1605089422533218304 # change this if error or restart
#     while True:
#         # Get the first 20 tweets on the home timeline
#         tweets = api.get_home_timeline(max_results=12,
#                                        exclude='retweets',
#                                        expansions="author_id", #since_id=latest_tweet_id
#                                       start_time=last_minute)
#         if tweets.data is not None:
#             latest_tweet_id = tweets.meta['newest_id']
#             for tweet in tweets.data:
#                 if tweet.author_id in users:                   
                                        
#                     print(f"Latest Tweet ID:{tweet.id}")
#                     print(f"Latest tweet: {tweet.text}")                   
                    
#                     try:
#                         curr = tss.google(tweet.text, to_language='en', sleep_seconds=0.051)
#                         status = f"{curr[:254]}"                        
#                         api.create_tweet(text=status, quote_tweet_id=f"{tweet.id}") 
#                         print(f"Tweet successfully sent: {status}")
#                     except:
#                         curr = tss.tencent(tweet.text, to_language='en', sleep_seconds=0.051)
#                         status = f"{curr[:254]}"                        
#                         api.create_tweet(text=status, quote_tweet_id=f"{tweet.id}") 
#                         print(f"Tweet successfully sent: {status}")
#                     else:
#                         continue
#                     print(tweet.text)
#                     print("_______________________")
#         time.sleep(60)

# translate(bearer_token,api_key,secret_api_key,access_token,secret_access_token)