mirror of
https://github.com/simon987/od-database.git
synced 2025-04-19 18:36:44 +00:00
Reddit comment callback is not an edit instead of a new comment
This commit is contained in:
parent
458641654c
commit
89e378ffd9
@ -52,12 +52,12 @@ class RedditCommentCallback(RedditCallback):
|
||||
def run(self, task_result: TaskResult, search: SearchEngine):
|
||||
|
||||
comment_id = self.task.callback_args["comment_id"]
|
||||
print("Replying to comment " + comment_id)
|
||||
print("Editing comment comment " + comment_id)
|
||||
|
||||
stats = search.get_stats(self.task.website_id)
|
||||
message = self.reddit_bot.get_comment(stats, self.task.website_id)
|
||||
print(message)
|
||||
self.reddit_bot.reply(self.reddit_bot.reddit.comment(comment_id), message)
|
||||
self.reddit_bot.edit(self.reddit_bot.reddit.comment(comment_id), message)
|
||||
|
||||
|
||||
class DiscordCallback(PostCrawlCallback):
|
||||
|
@ -41,17 +41,28 @@ class RedditBot:
|
||||
|
||||
while True:
|
||||
try:
|
||||
# Double check has_crawled
|
||||
if not self.has_crawled(reddit_obj.id):
|
||||
reddit_obj.reply(comment)
|
||||
reply = reddit_obj.reply(comment)
|
||||
self.log_crawl(reddit_obj.id)
|
||||
print("Reply to " + reddit_obj.id)
|
||||
return reply
|
||||
break
|
||||
except Exception as e:
|
||||
print("Waiting 5 minutes: " + str(e))
|
||||
time.sleep(300)
|
||||
continue
|
||||
|
||||
def edit(self, reddit_comment, new_message):
|
||||
|
||||
while True:
|
||||
try:
|
||||
reddit_comment.edit(new_message)
|
||||
print("Edit comment " + reddit_comment.id)
|
||||
except Exception as e:
|
||||
print("Waiting 5 minutes: " + str(e))
|
||||
time.sleep(300)
|
||||
continue
|
||||
|
||||
@staticmethod
|
||||
def get_comment(stats: dict, website_id, message: str = ""):
|
||||
comment = message + " \n" if message else ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user