"Resteemit.com" | Fix bugs & run service for better process

Words
218
Reading
1 min
Listen
Play
9y

contribution.png



This is my secend contribution to the development of resteemit.com Project by gktown@gktown


Resteemit.com is a Public Curation Project
Resteemit take any steemit article and resteem it on resteemable@resteemable, from where the post is upvoted by the resteemable trail.



Changement summary :

  • Add log for voted posts & resteemed posts.
  • Add new vote function & renew old one.
  • Add interval checker
  • Add comment functionality
  • Fix duplicated comments

- Add log for voted posts & resteemed posts.

I added log to the console for both functions :

  • vote
    if(err){console.log(err)};
  • resteem
    if(err){console.log(err)};if(result){console.log("Resteem Succes for "+user)}


    After i've add a new vote function voteAwaitingpostes , because in the last one , the log show only the first post upvoted in for methode .

var voteAwaitingpostes = function()
{
var totalAwaitPosts = awaitingPosts.length;
if( totalAwaitPosts > 1)
{
console.log("Bot is ready !!");
......................

And for the old fuction resteemable i let only time logger & line to push reblogged postes in the Array .

- Add interval checker :

for a better process , this Intervel will check if bot (awake or sleep) with condition if(SleepAt < CurrentDate) every 10s ,
if so bot sleep again and voteAwaitingpostes function called

setInterval(function() {
var CurrentDate = Date.now();
if(SleepAt < CurrentDate)
{
................

- Add comment functionality

I've add doComment function for commenting to voted postes , also to notify to users that the service is working .

var doComment = function(Vuser,Permlink){
var comment = "---------------------.";

var commentPermlink = steem.formatter.commentPermlink(voter, Permlink);
.........................

Next i implement it in voteAwaitingpostesfunction after vote function , and i set a timout to 20s betwin every (comment & vote) , because steemit allow only to comment 1 time every 20s.

doComment(u_a_p[0],u_a_p[1]);
sleep(20000);

- Fix duplicated comments

I've added Duplicated function that check if submitted posts already exist or not...

var Duplicated = function(Suser,Stitle)
{
for(var i=0; i<awaitingPosts.length; i++){
........................

then i implement it in resteemable function , the idea is befor adding post to awaiting list we call duplicated function that return true or false , so we check if true we add post to the list , if not we log to console .

if(!Duplicated(Suser,Stitle))awaitingPosts.push(Suser+"//"+Stitle);
else console.log("Duplicated Poste : " + Suser+" - " + Stitle);

Note : all changement are made in one file server.js



Project link : https://github.com/gktown/resteemit
Pull requests links :
PR #3
PR #4
PR #8

Cheers!



Posted on Utopian.io - Rewarding Open Source Contributors

"Resteemit.com" | Fix bugs & run service for better process | Ecency