p0o / steem-bot

Easy automation on top of Steem blockchain
MIT License
53 stars 40 forks source link

I want to Get all real time post with tag introduceyourself #12

Closed tomriddle54 closed 6 years ago

tomriddle54 commented 6 years ago

Hello I am new to js I was Planning To Get The All post by tag not by the user I Tryed to add this code in src/respounder.js

function getTags(author, tag) {
  return steem.api.getTrendingTags(afterTag, limit);
}

and try to use it in voter.js but bad luck its not working Any One here Can Tell me Insterd of user how can i get tags

p0o commented 6 years ago

You are not supposed to change the library for your purpose. You should just install it using npm and use it. Read the docs to know how to setup your environment.

This code upvotes all the posts sent with the tag fitness


bot.onPost(handlePost);

function handlePost(data, responder) {
  if (data.tag == 'fitness') {
    responder.upvote(); // 100% upvote
  }
}
tomriddle54 commented 6 years ago

Thank you For the Reply the above code was not working to upvote so I tried to debug it and found when printing data.tag it's showing undefined

bot.onPost(handlePost);
function handlePost(data, responder) {
    console.log(data.tag);
  if (data.tag == 'steemit') {
    console.log(data);
    //responder.upvote(); // 100% upvote
  }
}

than I tryed to get print data i got this json data

{ parent_author: '',
  parent_permlink: 'bitcoin',
  author: 'clarawina',
  permlink: 'transcodium-blockchain-based-transcoding-platform',
  title: 'Transcodium:  Blockchain based Transcoding Platform',
  body: '@@ -2220,16 +2220,59 @@\n ience.%0A%0A\n+%3Ca href=%22https://transcodi
um.com/?lang=en%22%3E\n Transcod\n@@ -2274,16 +2274,20 @@\n nscodium\n+%3C/a%3E\
n  aims to\n@@ -2667,16 +2667,59 @@\n What is \n+%3Ca href=%22https://transcodiu
m.com/?lang=en%22%3E\n Transcod\n@@ -2721,16 +2721,20 @@\n nscodium\n+%3C/a%3E\n
  (TNS) C\n@@ -4192,8 +4192,382 @@\n  ADVISOR\n+%0A%0AWebsite %7C https://transc
odium.com/?lang=en%0AWhitepaper %7C https://transcodium.com/files/whitepaper.pdf
%0ATwitter %7C https://twitter.com/transcodium%0AFacebook %7C https://www.facebo
ok.com/transcodium/%0AANN %7C https://bitcointalk.org/index.php?topic=2571769.0%
0A========================================================%0Aclara445%0Ahttps://
bitcointalk.org/index.php?action=profile;u=1178050\n',
  json_metadata: '{"tags":["bitcoin","blockchain","ico","token","cryptocurrency"
],"image":["https://img.youtube.com/vi/-Kt4W2cQFyo/0.jpg","https://steemitimages
.com/DQma6irS18AtzkEkoKiGewMf5xG8RsGExjCpsnxBH3sYFxT/Transcoding-is-the-ability.
png","https://steemitimages.com/DQma5PwpeFnL43iFmJbhHwTtugYf3DYpMu39ehztc2FEwgW/
What-is-Transcodium-coin.png"],"links":["https://youtu.be/-Kt4W2cQFyo","https://
transcodium.com/?lang=en","https://transcodium.com/files/whitepaper.pdf","https:
//twitter.com/transcodium","https://www.facebook.com/transcodium/","https://bitc
ointalk.org/index.php?topic=2571769.0","https://bitcointalk.org/index.php?action
=profile;u=1178050"],"app":"steemit/0.1","format":"markdown"}' }
{ parent_author: '',
  parent_permlink: 'fr',
  author: 'gribouille',
  permlink: 'web-2018-2-5-9-45-36',
  title: '?? # 14 - Minute citation ??',
  body: '[![92f97437-71aa-40d7-bf0d-a2a73e7afe6a.jpeg](http://steepshot.org/api/
v1/image/92f97437-71aa-40d7-bf0d-a2a73e7afe6a.jpeg)](https://alpha.steepshot.io/
post/web-2018-2-5-9-45-36)\n\n-   --  -   - ---  -- - -  -- - -   -----   --  -
 - ----  -    -   - --\n\n**Martin Luther King** était un pasteur noir américain
, leader anti-ségrégationniste\n\nIl est né à Atlanta (Géorgie) le 15 janvier 19
29. \nEt mort assassiné en  1968 à Memphis dans le Tenessee\n\nC\'est qui Martin
 Luther King ? \nRéponse en 1 minute 42 secondes dans 1jour, 1question, vidéo Yo
utube : https://lc.cx/P2n2\n\nSi vous avez le courage de le lire, vous pouvez tr
ouver ici le *manifeste pour une propagande de paix* : https://lc.cx/P2nR\n\nTex
te actuel où vous pourrez trouver des informations sur "Peace Propaganda". \n\nC
\'est un projet actuel  se concentrant sur la production de matériel audio-visue
ls de haute qualité, pouvant circuler facilement sur internet. \nEt qui cherche
l'engagement et le soutien d'acteurs passionnés unissant leurs efforts, ressourc
es et créativité pour produire ces vidéos. \n\n\nPour revenir à Martin Luther Ki
ng, j\'ai trouvé ce reportage d\'une heure : https://lc.cx/P2hE\n\net son discou
rs *I have a dream* se trouve ici, avec sous-titres en français : https://lc.cx/
P2hR\n\n****\n****\nC\'était minute-citation\nou minutecitation\nou @gribouille-
minute-citation\n(je fais un test pour voir si cette méthode peut convenir pour
retrouver les articles d\'une série)\n\n-- -   -    -  ---- -  -  --   -----   -
 - --  - - --  --- -   -  --   -\n\n###### ![Steepshot_footer2.PNG](https://stee
mitimages.com/DQmd4wyZvtAUifJDLZD9vaqek17S1cUhN3PyEbFMMMgLW8o/Steepshot_footer2.
PNG) Steepshot | [IPFS](http://steepshot.org/ipfs/QmX39r4PLSk2eiitPxHbVtaByhXPNj
BZ99bVsf1WCAbaVt) | [Google Play](https://play.google.com/store/apps/details?id=
com.droid.steepshot)',
  json_metadata: '{"tags":["fr","photography","streetphotography","citations","m
inutecitation","citation","photo","photos","culture","steepshot"],"media":[{"url
":"http://steepshot.org/api/v1/image/92f97437-71aa-40d7-bf0d-a2a73e7afe6a.jpeg",
"size":{"height":1536,"width":1536},"thumbnails":{"256":"http://steepshot.org/ap
i/v1/image/5d8260f8-24e0-4c37-82a0-d9a27b9de318.jpeg","1024":"http://steepshot.o
rg/api/v1/image/fc3340dc-79cf-439b-a034-3d5991add739.jpeg"},"ipfs_hash":"QmX39r4
PLSk2eiitPxHbVtaByhXPNjBZ99bVsf1WCAbaVt","content_type":"image/jpeg"}],"image_si
ze":{"height":1536,"width":1536},"app":"steepshot/0.1.2.14","image":["http://ste
epshot.org/api/v1/image/92f97437-71aa-40d7-bf0d-a2a73e7afe6a.jpeg"],"ipfs_photo"
:"QmX39r4PLSk2eiitPxHbVtaByhXPNjBZ99bVsf1WCAbaVt"}' }

so here tag is in json_metadata: how can we use it json_metadata: '{"tags":["bitcoin","blockchain","ico","token","cryptocurrency"

tomriddle54 commented 6 years ago

Thank you Very Much @p0o I have solved it and closing this issue

bot.onPost(handlePost);

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

    console.log(obj.tags);

if (obj.tags.indexOf("steemit") > -1)
 {
    console.log("did it ");
}
p0o commented 6 years ago

Yes sorry I don't really remember the api, just wanted to show you how it's done. Happy you found the correct path yourself.