1 comment - 1 carrot
meaningful comments only!
Implementation scheme:
- Get a list of comments from a specific user
- Choose exactly for yesterday's comments
- Count the number of comments
- Get a list of community members
- Implement point 2 for each of the participants
- Depending on the number of comments, display the number of carrots
- Find the right carrot IMG
- Achieve beautiful formatting
- Connect to telegram bot selfdevelopmentclub_bot
- Make a report "How many carrots did you give for the rabbit" for yesterday
- 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.