Guest User

Untitled

a guest
Dec 6th, 2016
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict'
  2.  
  3. var tg = require('telegram-node-bot')('')
  4. var path = require('path')
  5. var fs = require('fs')
  6. var req = require('tiny_request')
  7. var mysql = require('mysql')
  8. var connection = mysql.createConnection({
  9.     host: 'localhost',
  10.     user: 'root',
  11.     password: ''
  12. });
  13.  
  14. var Admins = [102503485]
  15.  
  16.  
  17.  
  18. var BanList = []
  19. fs.readFile(path.join(__dirname, 'banlist.txt'), {
  20.     encoding: 'utf-8'
  21. }, function(err, data) {
  22.     if (!err) {
  23.         BanList = JSON.parse(data)
  24.  
  25.     }
  26. })
  27.  
  28. var InstaList = []
  29. fs.readFile(path.join(__dirname, 'insta.txt'), {
  30.     encoding: 'utf-8'
  31. }, function(err, data) {
  32.     if (!err) {
  33.         InstaList = JSON.parse(data)
  34.     }
  35. })
  36.  
  37. var VKList = []
  38. fs.readFile(path.join(__dirname, 'vk.txt'), {
  39.     encoding: 'utf-8'
  40. }, function(err, data) {
  41.     if (!err) {
  42.         VKList = JSON.parse(data)
  43.     }
  44. })
  45.  
  46. var ForchList = []
  47.  
  48. function forch(callback) {
  49.     fs.readFile(path.join(__dirname, '4chan.txt'), {
  50.         encoding: 'utf-8'
  51.     }, function(err, data) {
  52.         if (!err) {
  53.             ForchList = JSON.parse(data)
  54.             callback()
  55.         }
  56.     })
  57. }
  58.  
  59. var TyansList = []
  60.  
  61. function tyan(callback) {
  62.     fs.readFile(path.join(__dirname, 'tyans.txt'), {
  63.         encoding: 'utf-8'
  64.     }, function(err, data) {
  65.         if (!err) {
  66.             TyansList = JSON.parse(data)
  67.             callback()
  68.         }
  69.     })
  70. }
  71.  
  72. var BbList = []
  73.  
  74. function brb(callback) {
  75.     fs.readFile(path.join(__dirname, 'bb.txt'), {
  76.         encoding: 'utf-8'
  77.     }, function(err, data) {
  78.         if (!err) {
  79.             BbList = JSON.parse(data)
  80.             callback()
  81.         }
  82.     })
  83. }
  84.  
  85.  
  86. var MolodecList = []
  87.  
  88. function molodec(callback) {
  89.     fs.readFile(path.join(__dirname, 'molodec.txt'), {
  90.         encoding: 'utf-8'
  91.     }, function(err, data) {
  92.         if (!err) {
  93.             MolodecList = JSON.parse(data)
  94.             callback()
  95.         }
  96.     })
  97. }
  98.  
  99. var MDKList = []
  100.  
  101. function mdk(callback) {
  102.     fs.readFile(path.join(__dirname, 'mdk.txt'), {
  103.         encoding: 'utf-8'
  104.     }, function(err, data) {
  105.         if (!err) {
  106.             MDKList = JSON.parse(data)
  107.             callback()
  108.         }
  109.     })
  110. }
  111. var DvachList = []
  112.  
  113. function dvach(callback) {
  114.     fs.readFile(path.join(__dirname, '2ch.txt'), {
  115.         encoding: 'utf-8'
  116.     }, function(err, data) {
  117.         if (!err) {
  118.             DvachList = JSON.parse(data)
  119.             callback()
  120.         }
  121.     })
  122. }
  123.  
  124. var BtList = []
  125.  
  126. function bt(callback) {
  127.     fs.readFile(path.join(__dirname, 'bt.txt'), {
  128.         encoding: 'utf-8'
  129.     }, function(err, data) {
  130.         if (!err) {
  131.             BtList = JSON.parse(data)
  132.             callback()
  133.         }
  134.     })
  135. }
  136.  
  137. var KtvsList = []
  138.  
  139. function ktvs(callback) {
  140.     fs.readFile(path.join(__dirname, 'ktvs.txt'), {
  141.         encoding: 'utf-8'
  142.     }, function(err, data) {
  143.         if (!err) {
  144.             KtvsList = JSON.parse(data)
  145.             callback()
  146.         }
  147.     })
  148. }
  149.  
  150. var ASList = []
  151.  
  152. function as(callback) {
  153.     fs.readFile(path.join(__dirname, 'schoolboy.txt'), {
  154.         encoding: 'utf-8'
  155.     }, function(err, data) {
  156.         if (!err) {
  157.             ASList = JSON.parse(data)
  158.             callback()
  159.         }
  160.     })
  161. }
  162.  
  163. tg.router.
  164. when(['/ban'], 'BanController').
  165. when(['/unban'], 'UnbanController').
  166. when(['/list'], 'ListController').
  167. when(['/god'], 'GodController').
  168. when(['tyan', 'Одноклассница'], 'TyanController').
  169. when(['MDK'], 'MDKController').
  170. when(['2ch'], 'DvachController').
  171. when(['4ch'], 'ForchController').
  172. when(['Катавасия'], 'KtvsController').
  173. when(['БТ'], 'BugurtController').
  174. when(['MOLODEC'], 'MOLODECController').
  175. when(['Brighton'], 'BrightonController').
  176. when(['ЗШ'], 'ASController').
  177. when(['конец'], 'EndController').
  178. otherwise('OtherwiseController')
  179.  
  180. tg.controller('BanController', ($) => {
  181.     tg.for('/ban', () => {
  182.         var chatId = $.chatId
  183.         var userId = $.user.id
  184.         if (find(Admins, userId) > -1) {
  185.             BanList.push($.args)
  186.             fs.writeFile(path.join(__dirname, 'banlist.txt'), JSON.stringify(BanList), function(err) {
  187.                 if (!err) {
  188.                     $.sendMessage('user ' + $.args + ' was banned')
  189.                 }
  190.             })
  191.         } else {
  192.             $.sendMessage('You dont have permissions to run this command')
  193.         }
  194.         tg.sendMessage(-88061058, $.user.id)
  195.         tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
  196.     })
  197. })
  198.  
  199.  
  200.  
  201. tg.controller('TyanController', ($) => {
  202.     tg.for('tyan', () => {
  203.         if (find(BanList, $.user.id) > -1) {
  204.             $.sendMessage('Вы забанены, обратитесь к @iprxy')
  205.         } else {
  206.             tyan(function() {
  207.                 var msg = TyansList[Math.floor(Math.random() * TyansList.length)]
  208.                 var caption = '';
  209.                 TyansList.forEach(function(login) {
  210.                     if (login !== null) {
  211.                         msg
  212.                     }
  213.                 })
  214.                 $.sendPhotoFromUrl(msg)
  215.  
  216.             })
  217.         }
  218.         tg.sendMessage(-88061058, $.user.id)
  219.         tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
  220.     })
  221.     tg.for('Одноклассница', () => {
  222.         if (find(BanList, $.user.id) > -1) {
  223.             $.sendMessage('Вы забанены, обратитесь к @iprxy')
  224.         } else {
  225.             $.routeTo('tyan')
  226.         }
  227.         tg.sendMessage(-88061058, $.user.id)
  228.         tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
  229.     })
  230. })
  231. tg.controller('MDKController', ($) => {
  232.     tg.for('MDK', () => {
  233.         if (find(BanList, $.user.id) > -1) {
  234.             $.sendMessage('Вы забанены, обратитесь к @iprxy')
  235.         } else {
  236.             mdk(function() {
  237.                 var msg = MDKList[Math.floor(Math.random() * MDKList.length)]
  238.                 var caption = '';
  239.                 MDKList.forEach(function(login) {
  240.                     if (login !== null) {
  241.                         msg
  242.                     }
  243.                 })
  244.                 $.sendPhotoFromUrl(msg)
  245.  
  246.             })
  247.         }
  248.         tg.sendMessage(-88061058, $.user.id)
  249.         tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
  250.     })
  251. })
  252. tg.controller('DvachController', ($) => {
  253.     tg.for('2ch', () => {
  254.         if (find(BanList, $.user.id) > -1) {
  255.             $.sendMessage('Вы забанены, обратитесь к @iprxy')
  256.         } else {
  257.             dvach(function() {
  258.                 var msg = DvachList[Math.floor(Math.random() * DvachList.length)]
  259.                 var caption = '';
  260.                 DvachList.forEach(function(login) {
  261.                     if (login !== null) {
  262.                         msg
  263.                     }
  264.                 })
  265.                 $.sendPhotoFromUrl(msg)
  266.  
  267.             })
  268.         }
  269.         tg.sendMessage(-88061058, $.user.id)
  270.         tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
  271.     })
  272. })
  273. tg.controller('ForchController', ($) => {
  274.     tg.for('4ch', () => {
  275.         if (find(BanList, $.user.id) > -1) {
  276.             $.sendMessage('Вы забанены, обратитесь к @iprxy')
  277.         } else {
  278.             forch(function() {
  279.                 var msg = ForchList[Math.floor(Math.random() * ForchList.length)]
  280.                 var caption = '';
  281.                 ForchList.forEach(function(login) {
  282.                     if (login !== null) {
  283.                         msg
  284.                     }
  285.                 })
  286.                 $.sendPhotoFromUrl(msg)
  287.  
  288.             })
  289.         }
  290.         tg.sendMessage(-88061058, $.user.id)
  291.         tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
  292.     })
  293. })
  294. tg.controller('KtvsController', ($) => {
  295.     tg.for('Катавасия', () => {
  296.         if (find(BanList, $.user.id) > -1) {
  297.             $.sendMessage('Вы забанены, обратитесь к @iprxy')
  298.         } else {
  299.             ktvs(function() {
  300.                 var msg = KtvsList[Math.floor(Math.random() * KtvsList.length)]
  301.                 var caption = '';
  302.                 KtvsList.forEach(function(login) {
  303.                     if (login !== null) {
  304.                         msg
  305.                     }
  306.                 })
  307.                 $.sendMessage(msg)
  308.  
  309.             })
  310.         }
  311.         tg.sendMessage(-88061058, $.user.id)
  312.         tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
  313.     })
  314. })
  315. tg.controller('BugurtController', ($) => {
  316.     tg.for('БТ', () => {
  317.         if (find(BanList, $.user.id) > -1) {
  318.             $.sendMessage('Вы забанены, обратитесь к @iprxy')
  319.         } else {
  320.             bt(function() {
  321.                 var msg = BtList[Math.floor(Math.random() * BtList.length)]
  322.                 var caption = '';
  323.                 BtList.forEach(function(login) {
  324.                     if (login !== null) {
  325.                         msg
  326.                     }
  327.                 })
  328.                 $.sendMessage(msg)
  329.  
  330.             })
  331.         }
  332.         tg.sendMessage(-88061058, $.user.id)
  333.         tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
  334.     })
  335. })
  336. tg.controller('EndController', ($) => {
  337.     tg.for('конец', () => {
  338.         $.sendMessage('Увы, но все хорошее когда-нибудь кончается.\r\nНо вы всегда можете подкинуть мне на пиво, и бот может заработать исключительно для вас <3\r\n@iprxy')
  339.     })
  340. })
  341. tg.controller('GodController', ($) => {
  342.     tg.for('/god', () => {
  343.         if (find(Admins, $.user.id) > -1) {
  344.             var arg = $.args.split('|');
  345.             var arg1 = arg[0];
  346.             var arg2 = arg[1];
  347.             tg.sendMessage(arg1, arg2)
  348.             $.sendMessage('Sent!')
  349.         }
  350.     })
  351. })
  352. tg.controller('MOLODECController', ($) => {
  353.     tg.for('MOLODEC', () => {
  354.         if (find(BanList, $.user.id) > -1) {
  355.             $.sendMessage('Вы забанены, обратитесь к @iprxy')
  356.         } else {
  357.             molodec(function() {
  358.                 var msg = MolodecList[Math.floor(Math.random() * MolodecList.length)]
  359.                 var caption = '';
  360.                 MolodecList.forEach(function(login) {
  361.                     if (login !== null) {
  362.                         msg
  363.                     }
  364.                 })
  365.                 $.sendPhotoFromUrl(msg)
  366.  
  367.             })
  368.         }
  369.         tg.sendMessage(-88061058, $.user.id)
  370.         tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
  371.     })
  372. })
  373. tg.controller('BrightonController', ($) => {
  374.     tg.for('Brighton', () => {
  375.         if (find(BanList, $.user.id) > -1) {
  376.             $.sendMessage('Вы забанены, обратитесь к @iprxy')
  377.         } else {
  378.             brb(function() {
  379.                 var msg = BbList[Math.floor(Math.random() * BbList.length)]
  380.                 var caption = '';
  381.                 BbList.forEach(function(login) {
  382.                     if (login !== null) {
  383.                         msg
  384.                     }
  385.                 })
  386.                 $.sendPhotoFromUrl(msg)
  387.  
  388.             })
  389.         }
  390.         tg.sendMessage(-88061058, $.user.id)
  391.         tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
  392.     })
  393. })
  394. tg.controller('ASController', ($) => {
  395.     tg.for('ЗШ', () => {
  396.         if (find(BanList, $.user.id) > -1) {
  397.             $.sendMessage('Вы забанены, обратитесь к @iprxy')
  398.         } else {
  399.             as(function() {
  400.                 var msg = ASList[Math.floor(Math.random() * ASList.length)]
  401.                 var caption = '';
  402.                 ASList.forEach(function(login) {
  403.                     if (login !== null) {
  404.                         msg
  405.                     }
  406.                 })
  407.                 $.sendMessage('http://vk.com/video-29544671_' + msg)
  408.  
  409.             })
  410.         }
  411.         tg.sendMessage(-88061058, $.user.id)
  412.         tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
  413.     })
  414. })
  415.  
  416. tg.controller('OtherwiseController', ($) => {
  417.     $.runMenu({
  418.         message: 'Нажми:',
  419.         'Увы': () => {
  420.             $.routeTo('конец')
  421.         },
  422.  
  423.  
  424.     })
  425. })
  426.  
  427.  
  428. function find(array, value) {
  429.  
  430.     for (var i = 0; i < array.length; i++) {
  431.         if (array[i] == value) return i
  432.     }
  433.  
  434.     return -1
  435. }
  436.  
  437.  
  438. tg.inlineMode(($) => {
  439.  
  440.     if ($.query != -1) {
  441.                 connection.query("INSERT INTO `bots`.`queries`(`id`) VALUES ("+connection.escape($.from.id)+")", function(err, rows, fields) {
  442.         if (err) {
  443.             console.log(err)
  444.         } else {
  445.            
  446.         }
  447.         })
  448.         req.get({
  449.             url: 'http://localhost/mdk',
  450.             port: 8080
  451.         }, function(body, response, err) {
  452.             if (!err && response.statusCode == 200) {
  453.                 var mdk = body
  454.                 req.get({
  455.                     url: 'http://localhost/bt',
  456.                     port: 8080
  457.                 }, function(body, response, err) {
  458.                     if (!err && response.statusCode == 200) {
  459.                         var bt = body
  460.                         req.get({
  461.                             url: 'http://localhost/4ch',
  462.                             port: 8080
  463.                         }, function(body, response, err) {
  464.                             if (!err && response.statusCode == 200) {
  465.                                 var fch = body
  466.                                 req.get({
  467.                                     url: 'http://localhost/2ch',
  468.                                     port: 8080
  469.                                 }, function(body, response, err) {
  470.                                     if (!err && response.statusCode == 200) {
  471.                                         var dch = body
  472.                                         req.get({
  473.                                             url: 'http://localhost/as',
  474.                                             port: 8080
  475.                                         }, function(body, response, err) {
  476.                                             if (!err && response.statusCode == 200) {
  477.                                                 var as = body
  478.                                                 req.get({
  479.                                                     url: 'http://localhost/ktvs',
  480.                                                     port: 8080
  481.                                                 }, function(body, response, err) {
  482.                                                     if (!err && response.statusCode == 200) {
  483.                                                         var ktvs = body
  484.                                                         req.get({
  485.                                                             url: 'http://localhost/bb',
  486.                                                             port: 8080
  487.                                                         }, function(body, response, err) {
  488.                                                             if (!err && response.statusCode == 200) {
  489.                                                                 var bb = body
  490.                                                                 req.get({
  491.                                                                     url: 'http://localhost/molodec',
  492.                                                                     port: 8080
  493.                                                                 }, function(body, response, err) {
  494.                                                                     if (!err && response.statusCode == 200) {
  495.                                                                         var molodec = body
  496.                                                                         req.get({
  497.                                                                             url: 'http://localhost/tyan',
  498.                                                                             port: 8080
  499.                                                                         }, function(body, response, err) {
  500.                                                                             if (!err && response.statusCode == 200) {
  501.                                                                                 var tyan = body
  502.  
  503.                                                                                 var options = {
  504.                                                                                     cache_time: 0,
  505.                                                                                     is_personal: true
  506.                                                                                 }
  507.                                                                                 tg.answerInlineQuery($.id, [{
  508.                                                                                     type: 'photo',
  509.                                                                                     photo_url: encodeURI(mdk),
  510.                                                                                     thumb_url: 'http://iprxy.me/meme/mdk.jpg',
  511.                                                                                     photo_width: 300,
  512.                                                                                     photo_height: 300,
  513.                                                                                     title: 'Мдк'
  514.  
  515.                                                                                 }, {
  516.                                                                                     type: 'photo',
  517.                                                                                     photo_url: encodeURI(fch),
  518.                                                                                     thumb_url: 'http://iprxy.me/meme/4ch.jpg',
  519.                                                                                     photo_width: 300,
  520.                                                                                     photo_height: 300,
  521.                                                                                     title: 'Форч'
  522.  
  523.                                                                                 }, {
  524.                                                                                     type: 'photo',
  525.                                                                                     photo_url: encodeURI(dch),
  526.                                                                                     thumb_url: 'http://iprxy.me/meme/2ch.jpg',
  527.                                                                                     photo_width: 300,
  528.                                                                                     photo_height: 300,
  529.                                                                                     title: 'Двач'
  530.  
  531.                                                                                 }, {
  532.                                                                                     type: 'photo',
  533.                                                                                     photo_url: encodeURI(bb),
  534.                                                                                     thumb_url: 'http://iprxy.me/meme/bb.jpg',
  535.                                                                                     photo_width: 300,
  536.                                                                                     photo_height: 300,
  537.                                                                                     title: 'Брайтон'
  538.  
  539.                                                                                 }, {
  540.                                                                                     type: 'photo',
  541.                                                                                     photo_url: encodeURI(molodec),
  542.                                                                                     thumb_url: 'http://iprxy.me/meme/molocec.jpg',
  543.                                                                                     photo_width: 300,
  544.                                                                                     photo_height: 300,
  545.                                                                                     title: 'Молодец'
  546.  
  547.                                                                                 }, {
  548.                                                                                     type: 'photo',
  549.                                                                                     photo_url: encodeURI(tyan),
  550.                                                                                     thumb_url: 'http://iprxy.me/meme/tyan.jpg',
  551.                                                                                     photo_width: 300,
  552.                                                                                     photo_height: 300,
  553.                                                                                     title: 'Одноклассница'
  554.  
  555.                                                                                 }, {
  556.                                                                                     type: 'article',
  557.                                                                                     message_text: 'http://vk.com/video-29544671_' + as,
  558.                                                                                     thumb_url: 'http://iprxy.me/meme/as.jpg',
  559.                                                                                     thumb_width: 300,
  560.                                                                                     thumb_height: 300,
  561.                                                                                     title: 'Злой школьник'
  562.  
  563.                                                                                 }, {
  564.                                                                                     type: 'article',
  565.                                                                                     message_text: bt,
  566.                                                                                     thumb_url: 'http://iprxy.me/meme/bt.jpg',
  567.                                                                                     thumb_width: 300,
  568.                                                                                     thumb_height: 300,
  569.                                                                                     title: 'БТ'
  570.  
  571.                                                                                 }, {
  572.                                                                                     type: 'article',
  573.                                                                                     message_text: ktvs,
  574.                                                                                     thumb_url: 'http://iprxy.me/meme/ktvs.jpg',
  575.                                                                                     thumb_width: 300,
  576.                                                                                     thumb_height: 300,
  577.                                                                                     title: 'Катавасия'
  578.  
  579.                                                                                 }], options, (response) => {
  580.                                                                                     console.log(response)
  581.                                                                                 })
  582.                                                                             } else {
  583.                                                                                 console.log('тян')
  584.                                                                             }
  585.                                                                         })
  586.                                                                     } else {
  587.                                                                         console.log('молодец')
  588.                                                                     }
  589.                                                                 })
  590.                                                             } else {
  591.                                                                 console.log('брайтон')
  592.                                                             }
  593.                                                         })
  594.                                                     } else {
  595.                                                         console.log('ктвс')
  596.                                                     }
  597.                                                 })
  598.                                             } else {
  599.                                                 console.log('зш')
  600.                                             }
  601.                                         })
  602.                                     } else {
  603.                                         console.log('двач')
  604.                                     }
  605.                                 })
  606.                             } else {
  607.                                 console.log('форч')
  608.                             }
  609.                         })
  610.                     } else {
  611.                         console.log('бт')
  612.                     }
  613.                 })
  614.             } else {
  615.                 console.log('мдк')
  616.             }
  617.  
  618.         })
  619.     }
  620.  
  621. })
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631. setInterval(insta, 60000)
  632. setInterval(vk, 60000)
Add Comment
Please, Sign In to add comment