Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Its commenting nearly some time 5 or some time 10 or working fine don't know whats Wrong #15

Open
tomriddle54 opened this issue Apr 2, 2018 · 8 comments

Comments

@tomriddle54
Copy link

I have Created a Bot for an introduction but sometimes its working fine and some time commenting more than 1 time and he has done 10 comments in one post don't know whats wrong here can any one help here is the code

// No need for the line below if your environment already supports ES6 with JavaScript import/export
require('babel-register');

// change the line below to:
// const SteemBot = require('steem-bot').default
// or:
// import SteemBot from 'steem-bot';
const SteemBot = require('../src/loader').default;


const username = '';
const postingKey = ''; 

const targetUsers = ['kamesh']; rs
const bot = new SteemBot({username, postingKey});

//bot.onComment(handleComment);
bot.onPost(handlePost);

function handlePost(data, responder) 
{
	tagg=data.json_metadata;
	obj = JSON.parse(tagg);


if (obj.tags.indexOf("introduceyourself") > -1)
 {
	console.log("did it ");
	
     responder.comment('Hi Thank you for #introducingyourself. Im myself quite new in steemit community but I realized that there are few things you could do to have a better start: \n Mostly I invested a little bit in STEEM in order to purchase STEEM POWER and STEEM DOLLARS. Why? Its simply important. Without initial investment it will be very hard for you to build reach here and be noticed.\n \n Im not sure if you ever heard about this site: \n http://steemd.com/@your_username \n Example: https://steemd.com/@example \n Perhaps you know it already :) \n If you will reply to this message (that would allow me to believe that we may develop mutual engagement and help each other) then I will follow you and upvote some of your future posts. \n Cheers and good luck.').catch((err) => {
    console.log('Some error happened while posting comment');
  
  });
	


 }


}



bot.start();



@TwinkieWInkie
Copy link
Collaborator

Hmm, maybe the compiler can't handel your indentation.

@TwinkieWInkie
Copy link
Collaborator

TwinkieWInkie commented Apr 15, 2018

I personally employ getAccountHistory instead of streamOperations and a database to prevent double actions.
getAccountHistory is way more reliable(and SteemJS is absolute junk)

Would this be a problem caused by 8fbbef9 ? @p0o
Lol, looking at that commit closely now, naughty naughty fix :p

@p0o
Copy link
Owner

p0o commented Apr 15, 2018

Can you send the link of the post that the code above put 10 comments?

@p0o
Copy link
Owner

p0o commented Apr 15, 2018

@TwinkieWInkie You are right, I remember that sometimes after resetting the streamOperations I would see repeated results. However, I say that moving to getAccountHistory is an overkill and would not be a general answer to all use cases.

I think we can change streamOperations to streamBlock to keep the lastest block number somewhere in SteemBot internally to avoid repeated triggers. I'm a little busy these days so if you like to submit a PR with this approach I would be more than happy.

@TwinkieWInkie
Copy link
Collaborator

@p0o
Seems like a worty challenge, I'll see if I can make some time for that :)

@TwinkieWInkie
Copy link
Collaborator

Considering implementing streamBlockNumber/getBlock.

@p0o
Copy link
Owner

p0o commented Apr 17, 2018

Isn't the blockNumber included in the data received from streamBlock?

@TwinkieWInkie
Copy link
Collaborator

Probably. But if it falls behind due to an error, we have an easier way to loop through the missing blocks with this method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants