Comment rating. How many carrots did you give the rabbit? Part 1

How many carrots did you give the rabbit Part 1.png

1 comment - 1 carrot
meaningful comments only!

Implementation scheme:

  1. Get a list of comments from a specific user
  2. Choose exactly for yesterday's comments
  3. Count the number of comments
  4. Get a list of community members
  5. Implement point 2 for each of the participants
  6. Depending on the number of comments, display the number of carrots
  7. Find the right carrot IMG
  8. Achieve beautiful formatting
  9. Connect to telegram bot selfdevelopmentclub_bot
  10. Make a report "How many carrots did you give for the rabbit" for yesterday
  11. Enjoy the result and draw up the next action plan.

Well, for all tasks - a maximum of 5 hours, including breaks and rest. Those. I'm taking 5 hours to write this script, including significant breaks.

And how long will it actually take? And in general, will something distract me, will I be able to finish it today? Let's find out today!

And even more so, because now humanity already exists - AI, neural networks and specifically chatGPT. It's some kind of magic wand.

I write AI: Please write a python code that gets all the comments of a specific STEEMIT user for yesterday. Comments in the code please write in English

And yes, he writes!

To fetch all comments from a specific user on Steemit for yesterday using Python, we need to use the Steem library, which allows us to interact with the Steem blockchain. Here is the code:

from steem import Steem
from datetime import datetime, timedelta

# initialize the Steem instance
s = Steem()

# define the username and the start and end time for the query
username = "username"
end_time = datetime.utcnow() - timedelta(days=1)
start_time = end_time - timedelta(days=1)

# query the comments
comments = s.get_discussions_by_comments({"author": username, "start_time": start_time, "end_time": end_time})

# print the comments
for comment in comments:
    print(comment["author"], ":", comment["body"])
    

If everything goes so fast, then I can do it in two hours! However, as there is such a joke - a programmer writes code for an hour, and debugs for a week. Everything is in the details!

I get errors, send them to chatGPT and he tells me what to do and how to fix them.

As a result, it did not work on the local computer.

The code does not work, I remembered that I already have a working code.

As a result, several hours have already passed, at 16:45, but the code of points 0,1,2 is ready.

#community = "hive-146361"

Step 4 - get the list of participants

# Import the required libraries
from steem import Steem
from datetime import datetime, timedelta

# Initialize Steem class with the node of your choice
s = Steem(nodes=["https://api.steemit.com"])

# Define the name of the community to get the user list from
community_name = "hive-146361"

# Get the community object
community_obj = s.get_community(community_name)

# Calculate the date for 24 hours ago
time_24_hours_ago = datetime.utcnow() - timedelta(hours=24)

# Get the posts that were created in the last 24 hours in the community
posts = s.get_discussions_by_created({"tag": community_name, "limit": 100, "truncate_body": 0, "start_author": "", "start_permlink": "", "before_date": time_24_hours_ago})

# Create a set to store the users that created the posts
users_set = set()

# Loop through the posts and add the author of each post to the set
for post in posts:
    users_set.add(post["author"])

# Get the community members
members = community_obj["members"]

# Loop through the community members and print out the username if they have created a post in the last 24 hours
for member in members:
    if member["name"] in users_set:
        print(member["name"])


50% done from today's task list!
Let's move on to the next post.

Coin Marketplace

STEEM 0.17
TRX 0.13
JST 0.027
BTC 58309.71
ETH 2617.30
USDT 1.00
SBD 2.42