Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.47 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 S = require('string');
  7. const inquirer = require('inquirer');
  8.  
  9. const User = [
  10. {
  11. type:'input',
  12. name:'username',
  13. message:'Insert Usernamenya bee:',
  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 Passwordnya bee:',
  23. mask:'*',
  24. validate: function(value){
  25. if(!value) return 'Can\'t Empty';
  26. return true;
  27. }
  28. },
  29. {
  30. type:'input',
  31. name:'target',
  32. message:'Insert Username Target (Without @[at]):',
  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 (Use [|] if more than 1):',
  42. validate: function(value){
  43. if(!value) return 'Can\'t Empty';
  44. return true;
  45. }
  46. },
  47. {
  48. type:'input',
  49. name:'mysyntx',
  50. message:'Input Total of Target You Want (ITTYW):',
  51. validate: function(value){
  52. value = value.match(/[0-9]/);
  53. if (value) return true;
  54. return 'Use Number Only!';
  55. }
  56. },
  57. {
  58. type:'input',
  59. name:'sleep',
  60. message:'Insert Sleep (In MiliSeconds):',
  61. validate: function(value){
  62. value = value.match(/[0-9]/);
  63. if (value) return true;
  64. return 'Delay is number';
  65. }
  66. }
  67. ]
  68.  
  69. const Login = async function(User){
  70.  
  71. const Device = new Client.Device(User.username);
  72. const Storage = new Client.CookieMemoryStorage();
  73. const session = new Client.Session(Device, Storage);
  74.  
  75. try {
  76. await Client.Session.create(Device, Storage, User.username, User.password)
  77. const account = await session.getAccount();
  78. return Promise.resolve({session,account});
  79. } catch (err) {
  80. return Promise.reject(err);
  81. }
  82.  
  83. }
  84.  
  85. const Target = async function(username){
  86. const url = 'https://www.instagram.com/'+username+'/'
  87. const option = {
  88. url: url,
  89. method: 'GET'
  90. }
  91. try{
  92. const account = await rp(option);
  93. const data = S(account).between('<script type="text/javascript">window._sharedData = ', ';</script>').s
  94. const json = JSON.parse(data);
  95. if (json.entry_data.ProfilePage[0].graphql.user.is_private) {
  96. return Promise.reject('Target is private Account');
  97. } else {
  98. const id = json.entry_data.ProfilePage[0].graphql.user.id;
  99. const followers = json.entry_data.ProfilePage[0].graphql.user.edge_followed_by.count;
  100. return Promise.resolve({id,followers});
  101. }
  102. } catch (err){
  103. return Promise.reject(err);
  104. }
  105.  
  106. }
  107.  
  108. async function ngeComment(session, id, text){
  109. try {
  110. await Client.Comment.create(session, id, text);
  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. ngeComment(session, result[0].params.id, text)
  131. ]
  132. const [Comment] = await Promise.all(task);
  133. const printComment = Comment ? chalk`{green Comment}` : chalk`{red Comment}`;
  134. return chalk`{bold.green ${printComment} [${text}]}`;
  135. }
  136. return chalk`{bold.cyan Aw, Snap! Timeline Kosong (SKIPPED)}`
  137. };
  138.  
  139. const Followers = async function(session, id){
  140. const feed = new Client.Feed.AccountFollowers(session, id);
  141. try{
  142. const Pollowers = [];
  143. var cursor;
  144. do {
  145. if (cursor) feed.setCursor(cursor);
  146. const getPollowers = await feed.get();
  147. await Promise.all(getPollowers.map(async(akun) => {
  148. Pollowers.push(akun.id);
  149. }))
  150. cursor = await feed.getCursor();
  151. } while(feed.isMoreAvailable());
  152. return Promise.resolve(Pollowers);
  153. } catch(err){
  154. return Promise.reject(err);
  155. }
  156. }
  157.  
  158. const Excute = async function(User, TargetUsername, Text, Sleep, mysyntx){
  159. try {
  160. console.log(chalk`{yellow \n[?] Try to Login . . .}`)
  161. const doLogin = await Login(User);
  162. console.log(chalk`{green [✓] Login Succsess. }{yellow [?] Try To Get ID & Followers Target . . .}`)
  163. const getTarget = await Target(TargetUsername);
  164. console.log(chalk`{green [✓] ${TargetUsername}: [${getTarget.id}] | Total Followers: [${getTarget.followers}]}`)
  165. const getFollowers = await Followers(doLogin.session, doLogin.account.id)
  166. console.log(chalk`{cyan [?] Try to Comment Target . . . \n}`)
  167. const Targetfeed = new Client.Feed.AccountFollowers(doLogin.session, getTarget.id);
  168. var TargetCursor;
  169. console.log(chalk`{yellow [#][>] START FFTAUTO WITH RATIO ${mysyntx} TARGET/${Sleep} MiliSeconds [<][#]\n}`)
  170. do {
  171. if (TargetCursor) Targetfeed.setCursor(TargetCursor);
  172. var TargetResult = await Targetfeed.get();
  173. TargetResult = _.chunk(TargetResult, mysyntx);
  174. for (let i = 0; i < TargetResult.length; i++) {
  175. var timeNow = new Date();
  176. timeNow = `${timeNow.getHours()}:${timeNow.getMinutes()}:${timeNow.getSeconds()}`
  177. await Promise.all(TargetResult[i].map(async(akun) => {
  178. if (!getFollowers.includes(akun.id) && akun.params.isPrivate === false) {
  179. var ranText = Text[Math.floor(Math.random() * Text.length)];
  180. const ngeDo = await CommentAndLike(doLogin.session, akun.id, ranText)
  181. console.log(chalk`[{magenta ${timeNow}}] {bold.green [>]}${akun.params.username} => ${ngeDo}`)
  182. } else {
  183. console.log(chalk`[{magenta ${timeNow}}] {bold.yellow [SKIPPED]}${akun.params.username} => PRIVATE OR ALREADY FOLLOWED`)
  184. }
  185. }));
  186. console.log(chalk`{yellow \n[#][>] Delay For ${Sleep} MiliSeconds [<][#]\n}`);
  187. await delay(Sleep);
  188. }
  189. TargetCursor = await Targetfeed.getCursor();
  190. console.log(chalk`{yellow \n[#][>] Delay For ${Sleep} MiliSeconds [<][#]\n}`);
  191. await delay(Sleep);
  192. } while(Targetfeed.isMoreAvailable());
  193. } catch (err) {
  194. console.log(err);
  195. }
  196. }
  197. console.log(chalk`{bold.green
  198. Ξ TITLE : BOT COMMENT
  199. Ξ CODE : CYBER SCREAMER CCOCOT (ccocot@bc0de.net)
  200. Ξ UPDATE : ADD ITTYW by @auliaahmad16
  201. Ξ STATUS : ITTYW : {bold.green Supported!}}
  202. `);
  203. inquirer.prompt(User)
  204. .then(answers => {
  205. var text = answers.text.split('|');
  206. Excute({
  207. username:answers.username,
  208. password:answers.password
  209. },answers.target,text,answers.sleep,answers.mysyntx);
  210. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement