Advertisement
Guest User

Untitled

a guest
Apr 13th, 2018
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.28 KB | None | 0 0
  1. const Client = require('instagram-private-api').V1;
  2. const delay = require('delay');
  3. const chalk = require('chalk');
  4. const _ = require('lodash');
  5. const rp = require('request-promise');
  6. const inquirer = require('inquirer');
  7.  
  8. const User = [
  9. {
  10. type:'input',
  11. name:'username',
  12. message:'Insert Username',
  13. validate: function(value){
  14. if(!value) return 'Can\'t Empty';
  15. return true;
  16. }
  17. },
  18. {
  19. type:'password',
  20. name:'password',
  21. message:'Insert Password',
  22. mask:'*',
  23. validate: function(value){
  24. if(!value) return 'Can\'t Empty';
  25. return true;
  26. }
  27. },
  28. {
  29. type:'input',
  30. name:'target',
  31. message:'Insert Link Media',
  32. validate: function(value){
  33. if(!value) return 'Can\'t Empty';
  34. return true;
  35. }
  36. },
  37. {
  38. type:'input',
  39. name:'text',
  40. message:'Insert Text Comment 1 (Gunakan Pemisah [|] bila lebih dari 1)',
  41. validate: function(value){
  42. if(!value) return 'Can\'t Empty';
  43. return true;
  44. }
  45. },
  46. {
  47. type:'input',
  48. name:'sleep',
  49. message:'Insert Sleep (In MiliSeconds)',
  50. validate: function(value){
  51. value = value.match(/[0-9]/);
  52. if (value) return true;
  53. return 'Delay is number';
  54. }
  55. }
  56. ]
  57.  
  58. const Login = async function(User){
  59.  
  60. const Device = new Client.Device(User.username);
  61. const Storage = new Client.CookieMemoryStorage();
  62. const session = new Client.Session(Device, Storage);
  63.  
  64. try {
  65. await Client.Session.create(Device, Storage, User.username, User.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.  
  74. const Target = async function(link){
  75. const url = link+'?__a=1'
  76. const option = {
  77. url: url,
  78. method: 'GET',
  79. json:true
  80. }
  81. try{
  82. const account = await rp(option);
  83. return Promise.resolve(account.graphql.shortcode_media.id);
  84. } catch (err){
  85. return Promise.reject(err);
  86. }
  87.  
  88. }
  89.  
  90. async function ngefollow(session,accountId){
  91. try {
  92. await Client.Relationship.create(session, accountId);
  93. return true
  94. } catch (e) {
  95. return false
  96. }
  97. }
  98.  
  99. async function ngeComment(session, id, text){
  100. try {
  101. await Client.Comment.create(session, id, text);
  102. return true;
  103. } catch(e){
  104. return false;
  105. }
  106. }
  107.  
  108. async function ngeLike(session, id){
  109. try{
  110. await Client.Like.create(session, id)
  111. return true;
  112. } catch(e) {
  113. return false;
  114. }
  115. }
  116.  
  117. const CommentAndLike = async function(session, accountId, text){
  118. var result;
  119.  
  120. const feed = new Client.Feed.UserMedia(session, accountId);
  121.  
  122. try {
  123. result = await feed.get();
  124. } catch (err) {
  125. return chalk`{bold.red ${err}}`;
  126. }
  127.  
  128. if (result.length > 0) {
  129. const task = [
  130. ngefollow(session, accountId),
  131. ngeComment(session, result[0].params.id, text),
  132. ]
  133. const [Follow,Comment,Like] = await Promise.all(task);
  134. const printFollow = Follow ? chalk`{green Follow}` : chalk`{red Follow}`;
  135. const printComment = Comment ? chalk`{green Comment}` : chalk`{red Comment}`;
  136. return chalk`{bold.green ${printFollow},${printComment}, [${text}]}`;
  137. }
  138. return chalk`{bold.cyan Timeline Kosong (SKIPPED)}`
  139. };
  140.  
  141. const Followers = async function(session, id){
  142. const feed = new Client.Feed.AccountFollowers(session, id);
  143. try{
  144. const Pollowers = [];
  145. var cursor;
  146. do {
  147. if (cursor) feed.setCursor(cursor);
  148. const getPollowers = await feed.get();
  149. await Promise.all(getPollowers.map(async(akun) => {
  150. Pollowers.push(akun.id);
  151. }))
  152. cursor = await feed.getCursor();
  153. } while(feed.isMoreAvailable());
  154. return Promise.resolve(Pollowers);
  155. } catch(err){
  156. return Promise.reject(err);
  157. }
  158. }
  159.  
  160. const Excute = async function(User, TargetUsername, Text, Sleep){
  161. try {
  162. console.log(chalk`{yellow \n | Try to Login .....}`)
  163. const doLogin = await Login(User);
  164. console.log(chalk`{green | Login Succsess, try to get Followers Target ....}`)
  165. const getTarget = await Target(TargetUsername);
  166. console.log(chalk`{green | ${TargetUsername} [${getTarget}]}`);
  167. const getFollowers = await Followers(doLogin.session, doLogin.account.id);
  168. console.log(chalk`{cyan | Try to Follow, Comment, and Like Followers Target ... \n}`)
  169. var TargetResult = await Client.Media.likers(doLogin.session, getTarget);
  170. TargetResult = _.chunk(TargetResult, 10);
  171. for (var i = 0; i < TargetResult.length; i++) {
  172. await Promise.all(TargetResult[i].map(async(akun) => {
  173. if (!getFollowers.includes(akun.id) && akun.params.isPrivate === false) {
  174. var ranText = Text[Math.floor(Math.random() * Text.length)];
  175. const ngeDo = await CommentAndLike(doLogin.session, akun.id, ranText)
  176. console.log(chalk`{bold.green [>]} @${akun.params.username} => ${ngeDo}`)
  177. } else {
  178. console.log(chalk`{bold.yellow [SKIPPED]}${akun.params.username} => PRIVATE OR ALREADY FOLLOWED`)
  179. }
  180. }));
  181. console.log(chalk`{yellow Delay For ${Sleep} MiliSeconds}`);
  182. await delay(Sleep);
  183. }
  184. } catch (err) {
  185. console.log(err);
  186. }
  187. }
  188.  
  189. console.log(chalk`
  190. {bold Instagram FLMT Auto Comment, Auto Like, Auto Follow}
  191. {green BC0DE.NET - NAONLAH.NET - WingKocoli}
  192. {bold.red Code By Ccocot | ccocot@bc0de.net}
  193. `);
  194.  
  195. inquirer.prompt(User)
  196. .then(answers => {
  197. var text = answers.text.split('|');
  198. Excute({
  199. username:answers.username,
  200. password:answers.password
  201. },answers.target,text,answers.sleep);
  202. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement