Advertisement
Guest User

Untitled

a guest
Apr 15th, 2018
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.58 KB | None | 0 0
  1. 'use strict'
  2.  
  3. const Client = require('instagram-private-api').V1;
  4. const chalk = require('chalk');
  5. const delay = require('delay');
  6. const _ = require('lodash');
  7. const inquirer = require('inquirer');
  8.  
  9. const question = [
  10. {
  11. type:'input',
  12. name:'username',
  13. message:'Insert Username',
  14. validate: function(value){
  15. if(!value) return 'Can\'t Empty';
  16. return true;
  17. }
  18. },
  19. {
  20. type:'password',
  21. name:'password',
  22. message:'Insert Password',
  23. mask:'*',
  24. validate: function(value){
  25. if(!value) return 'Can\'t Empty';
  26. return true;
  27. }
  28. },
  29. {
  30. type:'input',
  31. name:'hastag',
  32. message:'Insert Hashtag (Without #)',
  33. validate: function(value){
  34. if(!value) return 'Can\'t Empty';
  35. return true;
  36. }
  37. },
  38. {
  39. type:'input',
  40. name:'text',
  41. message:'Insert Text Comment 1 (Gunakan Pemisah [|] bila lebih dari 1)',
  42. validate: function(value){
  43. if(!value) return 'Can\'t Empty';
  44. return true;
  45. }
  46. },
  47. {
  48. type:'input',
  49. name:'sleep',
  50. message:'Insert Sleep (In MiliSeconds)',
  51. validate: function(value){
  52. value = value.match(/[0-9]/);
  53. if (value) return true;
  54. return 'Delay is number';
  55. }
  56. }
  57. ]
  58.  
  59.  
  60. const doLogin = async (params) => {
  61. const Device = new Client.Device(params.username);
  62. const Storage = new Client.CookieMemoryStorage();
  63. const session = new Client.Session(Device, Storage);
  64. try {
  65. await Client.Session.create(Device, Storage, params.username, params.password)
  66. const account = await session.getAccount();
  67. return Promise.resolve({session,account});
  68. } catch (err) {
  69. return Promise.reject(err);
  70. }
  71. }
  72.  
  73. const grabFollowers = async (session, id) => {
  74. const feed = new Client.Feed.AccountFollowers(session, id);
  75. try{
  76. feed.map = item => item.params;
  77. return Promise.resolve(feed.all());
  78. }catch (e){
  79. return Promise.reject(err);
  80. }
  81. }
  82.  
  83. const doFollow = async (session, id) => {
  84. try {
  85. await Client.Relationship.create(session, id);
  86. return true;
  87. } catch (e) {
  88. return false;
  89. }
  90. }
  91.  
  92. const doComment = async (session, id, text) => {
  93. try {
  94. await Client.Comment.create(session, id, text);
  95. return true;
  96. } catch(e){
  97. return false;
  98. }
  99. }
  100.  
  101. const doLike = async (session, id) => {
  102. try{
  103. await Client.Like.create(session, id);
  104. return true;
  105. } catch(e) {
  106. return false;
  107. }
  108. }
  109.  
  110. const doAction = async (session, params, text) => {
  111. const task = [
  112. doFollow(session, params.account.id),
  113. doComment(session, params.id, text)
  114. ];
  115. var [Follow,Like,Comment] = await Promise.all(task);
  116. Follow = Follow ? chalk`{bold.green SUKSES}` : chalk`{bold.red GAGAL}`;
  117. Comment = Comment ? chalk`{bold.green SUKSES}` : chalk`{bold.red GAGAL}`;
  118. return chalk`[Follow: ${Follow}] [Comment: ${Comment} ({cyan ${text}})]`;
  119. }
  120.  
  121. const doMain = async (account, hastag, sleep, text) => {
  122. console.log(chalk`\n{green [?] Try 2 Login ....}`);
  123. account = await doLogin(account);
  124. console.log(chalk`{bold.green [!] Login success}`)
  125. const feed = new Client.Feed.TaggedMedia(account.session, hastag);
  126. console.log(chalk`{green [!] Try 2 Follow, Like and Comment All Account In Hashtag: ${hastag}\n}`);
  127. try {
  128. var cursor;
  129. var count = 0;
  130. console.log(chalk`[=== START WITH RATIO 5/${sleep} MiliSeconds ===]`)
  131. do {
  132. if (cursor) feed.setCursor(cursor);
  133. count++;
  134. var media = await feed.get();
  135. media = _.chunk(media, 5);
  136. for (media of media) {
  137. var timeNow = new Date();
  138. timeNow = `${timeNow.getHours()}:${timeNow.getMinutes()}:${timeNow.getSeconds()}`
  139. await Promise.all(media.map(async(media)=>{
  140. const ranText = text[Math.floor(Math.random() * text.length)];
  141. const resultAction = await doAction(account.session, media.params, ranText);
  142. console.log(chalk`[{magenta ${timeNow}}] ${media.id} | {cyanBright @${media.params.account.username}} => ${resultAction}`);
  143. }))
  144. console.log(chalk`[{bold.yellow <=== SLEEP FOR ${sleep} MiliSeconds ===>}]`)
  145. await delay(sleep);
  146. }
  147. cursor = await feed.getCursor();
  148. console.log(chalk`[Cursor: {bold.cyan ${cursor ? cursor : 'null'}} | Count: {bold.cyan ${count}} | Total Media: {bold.cyan ${media.length}} | Delay: ${sleep} MiliSeconds ]`);
  149. } while(feed.isMoreAvailable());
  150. } catch(e) {
  151. console.log(e);
  152. }
  153. }
  154.  
  155. console.log(chalk`
  156. ###### #####
  157. ###### #####
  158. ###### #####
  159. ########## ##########
  160. ###### ######
  161. ###### ######
  162. ###### ######
  163. ######################################
  164. ######################################
  165. ######################################
  166. ##############################################
  167. ########## #################### #########
  168. ########## #################### #########
  169. ######################################################
  170. ######################################################
  171. ######################################################
  172. ######################################################
  173. ##### ###################################### #####
  174. ##### ###################################### #####
  175. ##### ###################################### #####
  176. ##### ###### ##### #####
  177. ##### ###### ##### #####
  178. ##### ###### ##### #####
  179. ##### ################## ################# #####
  180. ############## #############
  181. ############## #############
  182. ############## #############
  183. ------------------------------------------------------
  184. Follow account in hastag Media (Auto Comment,Like)
  185. Code By Cyber Screamer Aka Ccocot
  186. CCOCOT.CO | BC0DE.NET | NAONLAH.NET | WingkoColi
  187. ccocot@bc0de.net and Thank's To SGB TEAM
  188. ------------------------------------------------------
  189. `)
  190.  
  191. inquirer.prompt(question)
  192. .then(answers => {
  193. var text = answers.text.split('|');
  194. doMain({
  195. username:answers.username,
  196. password:answers.password}, answers.hastag, answers.sleep, text);
  197. })
  198. .catch(e => {
  199. console.log(e);
  200. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement