fix rule adding, (some) random crashing

This commit is contained in:
muskit
2023-01-23 22:37:21 -08:00
parent f4abde0c3b
commit 7bf33bdc4c
4 changed files with 11 additions and 3 deletions
+6 -1
View File
@@ -16,6 +16,11 @@ errors_encountered = 0
def on_response(resp):
ttweet = TalentTweet.create_from_v2api_response(resp)
if ttweet is None:
print('Couldn\'t create ttweet from the response:')
print(resp)
return
tweet_username = util.get_username(ttweet.author_id)
if ttweet.is_cross_company():
@@ -67,4 +72,4 @@ def run():
else:
print('API stream exited gracefully.')
print('Re-running listen mode...')
print(f'(Had {errors_encountered} errors so far.)')
print(f'(Had {errors_encountered} errors so far.)')
+2 -1
View File
@@ -54,4 +54,5 @@ def get_twitter_rules():
curr_rule = f'from:{name}'
else:
curr_rule = test_rule
return rules
rules.append(curr_rule)
return rules
+2 -1
View File
@@ -80,6 +80,7 @@ class TalentTweet:
@staticmethod
def create_from_v2api_response(resp):
tweet = resp.data
if tweet is None: return None
mrq = twapi.TwAPI.get_mrq(resp)
rt_target = None
@@ -181,4 +182,4 @@ class TalentTweet:
def get_datetime_str(self):
unpad = '#' if platform.system() == 'Windows' else '-'
return self.date_time.strftime(f'%b %{unpad}d %Y, %{unpad}I:%M%p (%Z)')
return self.date_time.strftime(f'%b %{unpad}d %Y, %{unpad}I:%M%p (%Z)')
+1
View File
@@ -248,6 +248,7 @@ class TwAPI:
print('done')
except:
print('error occurred trying to create main tweet, falling back to URL-main + reply screencap format')
traceback.print_exc()
text += f"\n{ttweet_url}"
try:
print('posting main tweet...', end='')