Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. function wait(i, callback){
  2. i++;
  3. return callback(i);
  4. }
  5.  
  6. bot.on('message_received', function(message, session) {
  7. var i = 0;
  8. console.log("FACEBOOK MESSAGE");
  9. var userid = session.user;
  10. start_chatbot(message, userid, function(rv) {
  11. while (i < rv.lenght){
  12. if (typeof rv[i] === 'string'){
  13. //console.log(i);
  14. session.send(rv[i]);
  15. }
  16. else{
  17. //console.log(i);
  18. request.post(
  19. 'https://graph.facebook.com/v2.6/me/messages?access_token=EAACHjcJxffsBAFZBmgezxZAYJDYGDwJNnec4aMZBlyftGJMtheApDUmtzKHmGFRDG7kzY81m3WEx4ZCBlN5Ao0UfDiuWUFpHUmMa3RGfX0URQrsefZBDjspnIVLy9zTn0vT9VZCTZA5U1xoRoKyUXGUULbZC1FEFeVuw41u3isZAWeRcqwLV8HnUt',
  20. rv[i],
  21. function (error, response, body) {
  22. if (!error && response.statusCode == 200) {
  23. wait(i, function(i){
  24. console.log(i);
  25. })
  26. console.log("reussi")
  27. //sleep(4000);
  28. }else {
  29. console.log("FFFFFFFFFFFFFf");
  30. console.log(body);
  31. console.log("échec");
  32. }
  33. }
  34. )
  35. }
  36. //sleep (1000);
  37. }
  38.  
  39. })
  40. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement