fundamental progression, fixes
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
*Twitter bot that follows interactions between Nijisanji EN/ID and hololive EN/ID members.*
|
||||
...because some folks are that desperate. Like me!
|
||||
|
||||
**This project is intended to run [this account](https://twitter.com/NijiHoloEN_Msgs).**
|
||||
**This project is intended to run [this account](https://twitter.com/NijiHolo_EN_ID).**
|
||||
|
||||
## Roadmap
|
||||
* Read past tweets of members from both companies
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
|
||||
# --- [Myth] ---
|
||||
gawrgura 1283657064410017793
|
||||
watsonameliaen 283656034305769472
|
||||
watsonameliaen 1283656034305769472
|
||||
moricalliope 1283653858510598144
|
||||
ninomaeinanis 1283650008835743744
|
||||
takanashikiara 1283646922406760448
|
||||
|
||||
+43
-6
@@ -11,10 +11,12 @@ import twint
|
||||
|
||||
from util import *
|
||||
from talent_lists import *
|
||||
from api import TwAPI
|
||||
from twapi import TwAPI
|
||||
import talenttweet as tt
|
||||
|
||||
## Returns list of tweets present in queue.txt
|
||||
def get_queue_file():
|
||||
return f'{util.get_project_dir()}/queue.txt'
|
||||
|
||||
def get_local_queue():
|
||||
# f = open(os.path.join(get_project_dir(), 'queue.txt'))
|
||||
pass
|
||||
@@ -29,10 +31,17 @@ def get_user_tweet_ids(id, limit=None):
|
||||
c.Store_object_tweets_list = tweets
|
||||
c.Hide_output = True
|
||||
|
||||
twint.run.Search(c)
|
||||
return [x.id for x in tweets]
|
||||
user_str = f'{id} ({util.get_username(id)})'
|
||||
print(f'Finding tweets from {user_str})')
|
||||
try:
|
||||
twint.run.Search(c)
|
||||
return [x.id for x in tweets]
|
||||
except:
|
||||
print(f'Had trouble getting tweets from {user_str}')
|
||||
return list()
|
||||
|
||||
def work_on_queue():
|
||||
def work_on_queue(file):
|
||||
print('TODO: implement work_on_queue')
|
||||
# while Queue.txt has lines present
|
||||
# attempt to deserialize first line of Queue.txt
|
||||
# exit program if failed, stating error
|
||||
@@ -43,8 +52,31 @@ def work_on_queue():
|
||||
# we're done! post tweet announcing done with archives
|
||||
pass
|
||||
|
||||
# If queue.txt doesn't exist, creates and populates it.
|
||||
# Returns a list of sorted and filtered TalentTweets (should
|
||||
# be equivalent to queue.txt)
|
||||
def create_ttweets_queue(path) -> list:
|
||||
print('Creating ttweets queue')
|
||||
if not os.path.exists(path):
|
||||
ttweets = list()
|
||||
with open(path, 'x') as f:
|
||||
for talent_id in talents.keys():
|
||||
tweet_ids = get_user_tweet_ids(talent_id)
|
||||
print(f'retrieved {len(tweet_ids)} tweets')
|
||||
for tweet_id in tweet_ids:
|
||||
ttweet = tt.TalentAPITweet(tweet_id)
|
||||
if ttweet.is_cross_company():
|
||||
ttweets.append(ttweet)
|
||||
|
||||
ttweets.sort(key=lambda ttweet: ttweet.tweet_id)
|
||||
for ttweet in ttweets:
|
||||
f.write(f'{ttweet.serialize()}\n')
|
||||
return ttweets
|
||||
else:
|
||||
return list()
|
||||
|
||||
|
||||
async def run():
|
||||
pass
|
||||
# if Queue.txt exists
|
||||
# work through the tweets in Queue.txt
|
||||
# else
|
||||
@@ -53,3 +85,8 @@ async def run():
|
||||
# create Queue.txt and save all tweets through there
|
||||
# post a tweet announcing archival intent
|
||||
# work through the tweets in Queue.txt
|
||||
queue_path = get_queue_file()
|
||||
if os.path.exists(queue_path):
|
||||
work_on_queue(queue_path)
|
||||
else:
|
||||
ttweets = create_ttweets_queue(queue_path)
|
||||
+1
-1
@@ -9,7 +9,7 @@ import talent_lists
|
||||
import api_secrets
|
||||
import catchup
|
||||
import listen
|
||||
from api import TwAPI
|
||||
from twapi import TwAPI
|
||||
|
||||
MODES_HELP_STR = '''mode to run the bot at:
|
||||
l,listen: listen for new tweets from all accounts; will not terminate unless error occurs
|
||||
|
||||
+4
-1
@@ -7,14 +7,17 @@ niji_exid = dict()
|
||||
talents = dict()
|
||||
|
||||
def __create_dict(file, _dict):
|
||||
print(f'Initializing talents\' account list from {file}...')
|
||||
global talents
|
||||
with open(file, 'r') as f:
|
||||
for line in f:
|
||||
words = line.split()
|
||||
if len(words) == 2 and line[0] != '#':
|
||||
name, id = line.split()
|
||||
_dict[int(id)] = name
|
||||
talents[int(id)] = name
|
||||
name = util.get_username_online(id) # attempt to get updated name
|
||||
talents[int(id)] = name
|
||||
_dict[int(id)] = name
|
||||
def init():
|
||||
global holo_en
|
||||
global holo_id
|
||||
|
||||
+2
-1
@@ -3,7 +3,7 @@ import platform
|
||||
|
||||
import pytz
|
||||
|
||||
from api import *
|
||||
from twapi import *
|
||||
import talent_lists
|
||||
|
||||
class TalentTweet:
|
||||
@@ -121,6 +121,7 @@ class TalentAPITweet(TalentTweet):
|
||||
if tweet and mrq:
|
||||
self.tweet = tweet
|
||||
elif tweet_id:
|
||||
tweet_id = int(tweet_id)
|
||||
resp = TwAPI.instance.get_tweet_response(tweet_id)
|
||||
self.tweet = resp.data
|
||||
mrq = TwAPI.get_mrq(self.tweet, resp)
|
||||
|
||||
+7
-3
@@ -5,11 +5,11 @@ import os
|
||||
import twint
|
||||
from tweetcapture import TweetCapture
|
||||
|
||||
from talent_lists import *
|
||||
import talent_lists
|
||||
import talenttweet as tt
|
||||
|
||||
# returns system path to this project, which is
|
||||
# up one level from this file's directory (src).
|
||||
# up one level from this file's directory (effective path: ..../src/../).
|
||||
def get_project_dir():
|
||||
return os.path.join(os.path.dirname(__file__), os.pardir)
|
||||
|
||||
@@ -43,6 +43,9 @@ def ttweet_to_url(ttweet):
|
||||
return f'https://twitter.com/{username}/status/{ttweet.tweet_id}'
|
||||
|
||||
def get_username(user_id):
|
||||
return talent_lists.talents.get(user_id, f'#{id}')
|
||||
|
||||
def get_username_online(user_id):
|
||||
c = twint.Config()
|
||||
c.User_id = user_id
|
||||
c.Store_object = True
|
||||
@@ -50,6 +53,7 @@ def get_username(user_id):
|
||||
try:
|
||||
twint.run.Lookup(c)
|
||||
user = twint.output.users_list[0]
|
||||
twint.output.users_list.clear()
|
||||
return user.username
|
||||
except:
|
||||
return talents.get(user_id, f'#{user_id}')
|
||||
return f'#{user_id}'
|
||||
Reference in New Issue
Block a user