Merge branch 'main' into cleanup
This commit is contained in:
@@ -2,4 +2,4 @@
|
||||
|
||||
mkdir -p run
|
||||
docker build -t nijiholo_bot .
|
||||
docker run -v ./run:/app/run --name bot -it nijiholo_bot
|
||||
docker run -v ./run:/app/run --name bot --rm -it nijiholo_bot
|
||||
|
||||
+1
-1
@@ -2,4 +2,4 @@
|
||||
|
||||
mkdir -p run
|
||||
docker build -t nijiholo_bot .
|
||||
docker run -v ./run:/app/run --name bot -d nijiholo_bot
|
||||
docker run -v ./run:/app/run --name bot --rm -d nijiholo_bot
|
||||
|
||||
@@ -67,6 +67,7 @@ async def get_cross_tweets_online():
|
||||
print("Unhandled error occurred while pulling tweets.")
|
||||
traceback.print_exc()
|
||||
with open(working_path(file="error_catchup.txt"), "a") as f:
|
||||
f.write(f"-------[{get_current_datetime_pretty()}]-------\n")
|
||||
f.write(f"Error getting tweets from user {dbg_curr_user}\n")
|
||||
traceback.print_exc(file=f)
|
||||
safe_to_post_tweets = False
|
||||
|
||||
+13
-7
@@ -241,7 +241,7 @@ class TalentTweet:
|
||||
"{0} quoted a tweet{1}mentioning {2}!" #########################
|
||||
)
|
||||
|
||||
author_username = f"@/{util.get_username_with_company(self.author_id)}"
|
||||
author_username = util.get_username_with_company(self.author_id)
|
||||
ret = str()
|
||||
|
||||
print_mention_ids = set(self.mentions)
|
||||
@@ -250,7 +250,7 @@ class TalentTweet:
|
||||
except:
|
||||
pass
|
||||
mention_usernames = [
|
||||
f"@/{util.get_username_with_company(x)}" for x in print_mention_ids
|
||||
util.get_username_with_company(x) for x in print_mention_ids
|
||||
]
|
||||
|
||||
def rtm_msg(TEMPLATE: str, rtm_author_username: str):
|
||||
@@ -261,13 +261,13 @@ class TalentTweet:
|
||||
or (self.reply_to is not None and self.reply_to != -1)
|
||||
): # rtm tweet is from talent; rtm should be everyone
|
||||
rtm_names = [
|
||||
f"@/{util.get_username_with_company(x)}" for x in self.rt_mentions
|
||||
util.get_username_with_company(x) for x in self.rt_mentions
|
||||
]
|
||||
between = f" from {rtm_author_username} "
|
||||
ret += TEMPLATE.format(author_username, between, ", ".join(rtm_names))
|
||||
else: # rtm tweet is not from a talent; rtm should just be cross company
|
||||
rtm_names = [
|
||||
f"@/{util.get_username_with_company(x)}"
|
||||
util.get_username_with_company(x)
|
||||
for x in self.rt_mentions
|
||||
if tl.is_cross_company(self.author_id, x)
|
||||
]
|
||||
@@ -276,10 +276,12 @@ class TalentTweet:
|
||||
# Tweet types
|
||||
if self.rt_author_id is not None: # retweet
|
||||
rt_username = (
|
||||
f"@/{util.get_username_with_company(self.rt_author_id)}"
|
||||
util.get_username_with_company(self.rt_author_id)
|
||||
if self.rt_author_id != -1
|
||||
else None
|
||||
)
|
||||
if rt_username == author_username:
|
||||
rt_username = "themselves"
|
||||
if len(self.rt_mentions) > 0:
|
||||
rtm_msg(RETWEET_MENTIONS_B, rt_username)
|
||||
else:
|
||||
@@ -287,20 +289,24 @@ class TalentTweet:
|
||||
mention_usernames.clear()
|
||||
elif self.reply_to is not None: # reply
|
||||
reply_username = (
|
||||
f"@/{util.get_username_with_company(self.reply_to)}"
|
||||
util.get_username_with_company(self.reply_to)
|
||||
if self.reply_to != -1
|
||||
else None
|
||||
)
|
||||
if reply_username == author_username:
|
||||
reply_username = "themselves"
|
||||
if len(self.rt_mentions) > 0:
|
||||
rtm_msg(REPLY_TO_MENTION_B, reply_username)
|
||||
else:
|
||||
ret += REPLY.format(author_username, reply_username)
|
||||
elif self.quote_tweeted is not None: # qrt
|
||||
quoted_username = (
|
||||
f"@/{util.get_username_with_company(self.quote_tweeted)}"
|
||||
util.get_username_with_company(self.quote_tweeted)
|
||||
if self.quote_tweeted != -1
|
||||
else None
|
||||
)
|
||||
if quoted_username == author_username:
|
||||
quoted_username = "themselves"
|
||||
if len(self.rt_mentions) > 0:
|
||||
rtm_msg(QUOTED_TWEET_MENTIONS_B, quoted_username)
|
||||
else:
|
||||
|
||||
+5
-1
@@ -61,6 +61,10 @@ def get_current_date():
|
||||
return datetime.today().strftime("%Y-%m-%d")
|
||||
|
||||
|
||||
def get_current_datetime_pretty():
|
||||
return datetime.now().strftime("%Y-%m-%d %H:%M:%S %Z")
|
||||
|
||||
|
||||
def get_key_from_value(d: dict, val):
|
||||
keys = [k for k, v in d.items() if v == val]
|
||||
if keys:
|
||||
@@ -115,7 +119,7 @@ def get_username(id):
|
||||
|
||||
def get_username_with_company(id):
|
||||
company = talent_lists.talents_company.get(id, None)
|
||||
return f'{get_username(id)} {f"({company})" if company is not None else ""}'
|
||||
return f'@/{get_username(id)} {f"({company})" if company is not None else ""}'
|
||||
|
||||
|
||||
def get_username_local(id: int):
|
||||
|
||||
Reference in New Issue
Block a user