nateraw commited on
Commit
d512690
1 Parent(s): 7a7b4e7

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +24 -11
main.py CHANGED
@@ -85,17 +85,30 @@ def reply_to_mentions():
85
  return
86
 
87
  for mention in reversed(mentions.data):
88
- tweet_to_roast_id = mention.referenced_tweets[0].id
89
- tweet_to_roast = client.get_tweet(id=tweet_to_roast_id)
90
- text_to_roast = tweet_to_roast.data.text
91
-
92
- text_out = None
93
- if "roast" in mention.text.lower():
94
- text_out = roast(text_to_roast)
95
- elif "toast" in mention.text.lower():
96
- text_out = toast(text_to_roast)
97
-
98
- if text_out is None:
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  continue
100
 
101
  try:
 
85
  return
86
 
87
  for mention in reversed(mentions.data):
88
+ try:
89
+ if mention.author_id == 1612106815096999936:
90
+ continue
91
+
92
+ if mention.referenced_tweets is None:
93
+ logger.info(f"Skipping {mention.id} as it is not a reply")
94
+ tweet_to_roast_id = mention.referenced_tweets[0].id
95
+ tweet_to_roast = client.get_tweet(id=tweet_to_roast_id)
96
+ text_to_roast = tweet_to_roast.data.text
97
+
98
+ text_out = None
99
+ text_in = mention.text.lower()
100
+ text_in.replace('@roastortoastgpt', '')
101
+ text_in.replace('roastortoastgpt','')
102
+
103
+ if "roast" in text_in:
104
+ text_out = roast(text_to_roast)
105
+ elif "toast" in text_in:
106
+ text_out = toast(text_to_roast)
107
+
108
+ if text_out is None:
109
+ continue
110
+ except Exception as e:
111
+ logger.error(e)
112
  continue
113
 
114
  try: