Skip to content

Commit

Permalink
add: reddit comment tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
MagicTheDev committed Jul 14, 2024
1 parent 5e4d10a commit a0d17eb
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions bot/reddit/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ async def comment_stream(reddit: asyncpraw.Reddit):
try:
sub = await reddit.subreddit(subreddit)
async for comment in sub.stream.comments(skip_existing=True):
await comment.author.load()
json_data = {"type": "redditcomment",
"data" : {"author" : comment.author.name,
"body" : comment.body,
"url" : comment.permalink,
"score" : comment.score,
"submission_author" : comment.link_author,
"submission_title" : comment.link_title
}}
"data" : {"author" : comment.author.name,
"avatar" : comment.author.icon_img,
"body" : comment.body,
"url" : comment.permalink,
"score" : comment.score,
"submission_author" : comment.link_author,
"submission_title" : comment.link_title
}}
producer.send(topic="reddit", value=orjson.dumps(json_data), timestamp_ms=int(pend.now(tz=pend.UTC).timestamp()) * 1000)
except Exception as e:
logger.error(traceback.format_exc())
Expand Down

0 comments on commit a0d17eb

Please sign in to comment.