Skip to content

Commit f75c427

Browse files
committed
fixed comment count in reply
1 parent 3dee6e1 commit f75c427

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

script.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
word_count = collections.Counter()
103103

104104
# Analyze comments for wholesome words
105+
comment_count = 0
105106
for comment in api_comments:
106107
# Clean and tokenize comment
107108
comment_text = re.sub(
@@ -113,6 +114,7 @@
113114
if token in wholesome_set:
114115
wholesome_count += 1
115116
word_count[token] += 1
117+
comment_count += 1
116118

117119
# Construct table of wholesome words and counts
118120
table_rows = [
@@ -122,9 +124,9 @@
122124

123125
# Construct reply text with wholesome count and table
124126
if '!uwucheckself' in incoming_comment.body.lower():
125-
reply_text = f'The number of wholesome occurrences in your recent 300 comments is {wholesome_count}.\n\n| Word | Count |\n| --- | --- |\n{table} |\n\nStay wholesome! \n\nWanna do something even more wholesome? Leave a \u2B50 at the [GitHub repository](https://github.com/MeowthyVoyager/wholesomebot-reddit).'
127+
reply_text = f'The number of wholesome occurrences in your recent {comment_count} comments is {wholesome_count}.\n\n| Word | Count |\n| --- | --- |\n{table} |\n\nStay wholesome! \n\nWanna do something even more wholesome? Leave a \u2B50 at the [GitHub repository](https://github.com/MeowthyVoyager/wholesomebot-reddit).'
126128
else:
127-
reply_text = f'The number of wholesome occurrences in the recent 300 comments of u/{user_name} is {wholesome_count}.\n\n| Word | Count |\n| --- | --- |\n{table} |\n\nStay wholesome! \n\nWanna do something even more wholesome? Leave a \u2B50 at the [GitHub repository](https://github.com/MeowthyVoyager/wholesomebot-reddit).'
129+
reply_text = f'The number of wholesome occurrences in the recent {comment_count} comments of u/{user_name} is {wholesome_count}.\n\n| Word | Count |\n| --- | --- |\n{table} |\n\nStay wholesome! \n\nWanna do something even more wholesome? Leave a \u2B50 at the [GitHub repository](https://github.com/MeowthyVoyager/wholesomebot-reddit).'
128130

129131
# Reply to the comment
130132
incoming_comment.reply(reply_text)

0 commit comments

Comments
 (0)