Devblog #1: first thoughts

in #blog7 years ago (edited)

Postheader Logo

This blog post will be about a little gaming project I came up with. You can read in more detail what it's all about in the introduction post.

lets begin

So I came up with this little idea and have no clue what I am doing here and where to start. But I have a RaspberryPi lying around and setting one up never is a bad idea, right? Well haven't worked on Linux for quite a while and getting steem-python running has been tedious. When you solve an error to get more errors multiple times in a row for something trivial like package installation you just start to wonder if its worth the effort.

I can't remember having anything done in Python yet and it most likely wouldn't have changed if I had a choice. But Steem Developers Portal gives me the choice between JavaScript and Python. So I chose Python because I want a script running on a Server and JavaScript is for client, right?

So I want to have this bot that does stuff on steem when people do stuff on steem. I needed a Bot for Steem to learn how things are done and found deutschbot. It has discord support and could do what I want in some minor changes. Still needed some functions that weren't used in the bot so I had to crawl through everything on the python-steem documentation which was annoyingly boring and I think their page is really inconvenient to use. Had to lookup some argument descriptions on post()-function a couple of times. You should try and maybe tell me what I'm doing wrong.

first goal

For starters I want a bot that does the following:

  1. create a post on command
  2. catch upvotes on this post and create a comment with upvoters name
  3. create another comment after a given time displaying upvote informations of comments created in the last step

1. create a post

Pretty straight forward post(title, body, author, permlink=None, ...). What bugged me with this was I expected to get a new unique identifier when creating a post and it's not that easy. A post can be identified by @author/permlink. Permlink will be build from title. Two posts with the same title will have the same permlink. When someone creates a new post with a permlink he already uses this older post will be "edited" and only the new one will be shown on steemit. Meaning I'll have to do some sort of permlink creation if I want unique handles for my posts and be sure nothing gets mixed up.

2. catch upvotes and create comments

The function get_active_votes() gives me all the votes on a post. Creating a comment just takes the post() function with an additional reply_identifier which is @author/permlink from first step.

3. summary post

Nothing new here, get_active_votes() on the comments and write everything in a new comment.

So I'll end up doing something like this

var permlink = create_unique_permlink();
post(title, body, author, permlink);

var postid = "@" + autor + "/" + permlink;
var start = now;
var duration = x;

var limit = y;
var voters = array();
var permlinks = array();

while(now < start + duration)
{
    var votes = get_active_votes(author, permlink);
    if(voters.size < limit)
    {
        foreach(votes as vote)
        {
            if(vote['voter'] not in voters)
            {
                voters[] = vote['voter'];
                permlinks[vote['voter']] = create_unique_permlink();
                post(title, body, author, permlink, postid);
            }
        }
    }
    wait(zZzzZZZ);
}

var results = array();
foreach(voters as voter)
{
    var votes = get_active_votes(author, permlinks[voter]);
    results[voter] = get_score(votes);
}

var bodyResult = evaluate(results);
post(title, bodyResult, author, create_unique_permlink());

This doesn't look too complicated. I guess I'll do that and report back when it's up and running.

See you on steem.

Sort:  

Congratulations @derasmo! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You got a First Reply

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

sehr nice! werde ich auf jedenfall weiter verfolgen! :3 Ist immer ganz interessant projekte von anfang an zu verfolgen! vorallem wenn das ein so tolles projekt ist :D

Kann ich dir nur zustimmen :)

Coin Marketplace

STEEM 0.17
TRX 0.16
JST 0.029
BTC 74993.05
ETH 2818.21
USDT 1.00
SBD 2.50