Steemit & Discord bot - Built on Steem-Python and discord.py
Introducing Dorabot
Dear Steemit friends,
I have recently released my Steemit & Discord bot which I now present to you.
Please welcome @dorabot!
She might not look like much 😉 but she has some usable features which I hope you will enjoy. Features to view stats and perform various actions and searches on Steemit.
It all started out as a number of standalone scripts, created in python and running on a Linux Ubuntu machine. I created the python scripts utilizing the official steem python library, steem-python (https://github.com/steemit/steem-python).
One of my first scripts was built to help me keep track and stay in touch with my most important followers.
The Steemit feed page can quickly be cluttered, both with resteems and non-important posts. Even if you try to clean up in your follwers list, you might feel like myself, that some followers are more important, followers that would fit on a VIP list. For me, these are followers that consistently comments and upvotes my posts. And I want to make sure I stay in touch with them, to send some love back.
This script allowed me to input a list of my VIP followers and it returned a list of their most recent posts. Running this a few times every week I made sure I kept up a frequent contact without being forced to look through my Steemit feed.
As I became active in the Minnow Support Project and started to engage with other community members via Discord, via MSP's own server, PALnet, I thought these scripts would be a nice addition for our Discord server. So that was how the idea of @dorabot came to life, a Steemit & Discord bot, ready to serve and promote Peace, Abundance & Liberty(PAL). 😉
Are you new to Minnow Support Project (MSP) and never heard of PALnet?
At the end of this post you will find a link with additional info about MSP and a link to connect to PALnet, MSP's Discord server.
See below screenshot to get an overview of @dorabot's Discord interface. The bot is active in most channels, but it is recommended to keep usage to the playingwithbots channel. Output in the general channel is prohibited to avoid spam and flooding of messages.
Activate with: ?help
Below I will give you a rundown of the feature described above, the feature that returns recent posts from your VIP followers.
Access it by running the ?curate command.
As described in ?help, the list of users should be separated with space or new line. So prepare a list of users and just paste it in after the ?curate command. At the end, you can add an optional number to indicate the number of posts to be fetched. You can return a maximum of 5 posts.
In the example below, you see me running the command, getting the 3 latest posts from: minnowsupport, danielsaori, aggroed and ausbitbank. I have also added a non-existing account, which will return an error message. So in case of a spelling mistake in your list, you can easily spot it. In this example, I have combined separating the names with both spaces and new lines.
Find below the extract of the python code for the main function. This is the function definition:
def getposts(user : str, postnr = 1):
It accepts a string for the username and an integer for the number of posts. In my main Discord bot, I'm looping through the list of users and calling this for each one. It is the also the code part of the Discord bot that limits the output to 5 posts. So there is no limit to the output in the code below.
Uncomment the last line in the code below if you want to try it out in a standalone python file. Just save it, for example: test.py, and execute it. Of course you need to have the steem-python library installed.
from steem import Steem
from steem.post import Post
from steem.account import Account
#Call function with a Steemit-username(string) and the number-of-posts(integer).
#The postnr variable is optional with a default value of 1.
def getposts(user : str, postnr = 1):
#Check if user is a real Steemit account.
try:
account = Account(user)
except Exception:
res = 0
else:
res = 1
#if real account.
if(res == 1):
s = Steem()
#Initiate an empty list.
postlist = ""
#Get 50 latest blog entries from the user. We fetch 50 as this will include reblogs.
posts = s.steemd.get_blog_entries(user,0, 50)
#Loop through all 50 posts.
for post in posts:
#Check that it is not a reblogged post.
if post['author'] == user:
#Fetch the Post object itself.
p = Post(post['author'] + '/' + post['permlink'])
#Format the url and add a timestamp.
url = "*https://steemit.com/@" + post['author'] + "/" + post['permlink'] + "* - " + p.created.ctime() + "\n"
#Add the url to the list.
postlist += url
postnr -= 1
#Stop the loop if we reached the wanted number of posts.
if postnr == 0:
break
return str(postlist)
#if fake account.
else:
return "Doesn't seem to be a valid Steemit account."
#Added it here for testing of the function.
#print(getposts("danielsaori", 3))
Thank you for reading!
Stayed tune for future updates.
Please let me know if you have any questions.
And please ping me (@danielsaori) if you connect to Discord.
Proud member of #minnowsupportproject & #teamaustralia
Thank you @aggroed, @ausbitbank, @teamsteem,
@theprophet0, @someguy123, @canadian-coconut and @sirknight
Click HERE to learn more about Minnow Support Project.
Click HERE to connect to our Discord chat server.
Wow!! Great work!! I love Discord bots that can interact with Steemit 😃
Great to have you here and thanks for your comment!
In the future I might add ways to interact via comments as well. But at the moment I wanted to avoid causing Steemit spam :) so I decided to keep it a pure Discord interface.
Awesome! Looking forward to seeing what you can all add to this bot too 😎
Thanks for sharing and showing us the code behind the product, I hope this get the traction it deserves.
Thank you for your support buddy!
And as I checked the comments I just noticed a massive upvote.
Super excited!! :)
Very good job @danielsaori. I am glad that i had the chance to try it. The ?curate feature that allows to see the latest posts of selected users is very useful. Thanks for posting the code. Gongratulations and keep up the good work !
Thx! You made me a better bot!
Thank you for helping out with the testing. I will keep you posted on future developments.
You've received a FULL upvote from #TheUnmentionables - a SteemIt community full of members who like to kick ass, take names, and occasionally do it wearing (or forgetting to wear) our unmentionables...
Click the Image to Join Our Discord Server:
Please upvote this comment so we can help our members grow faster!
Awesome! Thanks @fatpandadesign & @unmentionable
Looks really well done. Congrats!
Might give it a try soon :)
Thank you for passing by and for the nice comment!
Great job! This is so much faster than searching every individual profile!
Thank you for dropping by.
How is it going with your music? Any plans for more Open Mic contests?
Yep! Just posted one today!!
I've got today off, so I'm going to try and get another song done... Any suggestions?
This is great! Right on the money with the wanting to keep up with certain people more than others.
I don't understand the code, but I can grasp the functionality! Thank you for all of your hard work and effort in putting dora together for us!!
Thank you, Mike!!
The important thing is to understand the functionality. Leave the code for @dorabot. ;)
SteemOn!
Another useful feature for a newbie like me thanks @danielsaori for new introduction
Thank you @aleahsan! Are you part of MSP and did you try to "play" with @dorabot on Discord?
This is a wonderful idea and we really need a way to be able to separate resteems from blog posts. I love the graphic, too!
Yes, this way it is easy to get an overview of important users you are following. I will modify it a bit later so it will highlight all posts already upvoted. Thank you for the comment!
Awesome man! I am also planning to built one such bot in the future. This post would be very helpful for me in achieving that goal :)! Followed and resteemed!
That sounds great! Wish you all the best of luck. Which language are you thinking of using?
Thank you for your support!
Python of course :)