Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict'
- var tg = require('telegram-node-bot')('')
- var path = require('path')
- var fs = require('fs')
- var req = require('tiny_request')
- var mysql = require('mysql')
- var connection = mysql.createConnection({
- host: 'localhost',
- user: 'root',
- password: ''
- });
- var Admins = [102503485]
- var BanList = []
- fs.readFile(path.join(__dirname, 'banlist.txt'), {
- encoding: 'utf-8'
- }, function(err, data) {
- if (!err) {
- BanList = JSON.parse(data)
- }
- })
- var InstaList = []
- fs.readFile(path.join(__dirname, 'insta.txt'), {
- encoding: 'utf-8'
- }, function(err, data) {
- if (!err) {
- InstaList = JSON.parse(data)
- }
- })
- var VKList = []
- fs.readFile(path.join(__dirname, 'vk.txt'), {
- encoding: 'utf-8'
- }, function(err, data) {
- if (!err) {
- VKList = JSON.parse(data)
- }
- })
- var ForchList = []
- function forch(callback) {
- fs.readFile(path.join(__dirname, '4chan.txt'), {
- encoding: 'utf-8'
- }, function(err, data) {
- if (!err) {
- ForchList = JSON.parse(data)
- callback()
- }
- })
- }
- var TyansList = []
- function tyan(callback) {
- fs.readFile(path.join(__dirname, 'tyans.txt'), {
- encoding: 'utf-8'
- }, function(err, data) {
- if (!err) {
- TyansList = JSON.parse(data)
- callback()
- }
- })
- }
- var BbList = []
- function brb(callback) {
- fs.readFile(path.join(__dirname, 'bb.txt'), {
- encoding: 'utf-8'
- }, function(err, data) {
- if (!err) {
- BbList = JSON.parse(data)
- callback()
- }
- })
- }
- var MolodecList = []
- function molodec(callback) {
- fs.readFile(path.join(__dirname, 'molodec.txt'), {
- encoding: 'utf-8'
- }, function(err, data) {
- if (!err) {
- MolodecList = JSON.parse(data)
- callback()
- }
- })
- }
- var MDKList = []
- function mdk(callback) {
- fs.readFile(path.join(__dirname, 'mdk.txt'), {
- encoding: 'utf-8'
- }, function(err, data) {
- if (!err) {
- MDKList = JSON.parse(data)
- callback()
- }
- })
- }
- var DvachList = []
- function dvach(callback) {
- fs.readFile(path.join(__dirname, '2ch.txt'), {
- encoding: 'utf-8'
- }, function(err, data) {
- if (!err) {
- DvachList = JSON.parse(data)
- callback()
- }
- })
- }
- var BtList = []
- function bt(callback) {
- fs.readFile(path.join(__dirname, 'bt.txt'), {
- encoding: 'utf-8'
- }, function(err, data) {
- if (!err) {
- BtList = JSON.parse(data)
- callback()
- }
- })
- }
- var KtvsList = []
- function ktvs(callback) {
- fs.readFile(path.join(__dirname, 'ktvs.txt'), {
- encoding: 'utf-8'
- }, function(err, data) {
- if (!err) {
- KtvsList = JSON.parse(data)
- callback()
- }
- })
- }
- var ASList = []
- function as(callback) {
- fs.readFile(path.join(__dirname, 'schoolboy.txt'), {
- encoding: 'utf-8'
- }, function(err, data) {
- if (!err) {
- ASList = JSON.parse(data)
- callback()
- }
- })
- }
- tg.router.
- when(['/ban'], 'BanController').
- when(['/unban'], 'UnbanController').
- when(['/list'], 'ListController').
- when(['/god'], 'GodController').
- when(['tyan', 'Одноклассница'], 'TyanController').
- when(['MDK'], 'MDKController').
- when(['2ch'], 'DvachController').
- when(['4ch'], 'ForchController').
- when(['Катавасия'], 'KtvsController').
- when(['БТ'], 'BugurtController').
- when(['MOLODEC'], 'MOLODECController').
- when(['Brighton'], 'BrightonController').
- when(['ЗШ'], 'ASController').
- when(['конец'], 'EndController').
- otherwise('OtherwiseController')
- tg.controller('BanController', ($) => {
- tg.for('/ban', () => {
- var chatId = $.chatId
- var userId = $.user.id
- if (find(Admins, userId) > -1) {
- BanList.push($.args)
- fs.writeFile(path.join(__dirname, 'banlist.txt'), JSON.stringify(BanList), function(err) {
- if (!err) {
- $.sendMessage('user ' + $.args + ' was banned')
- }
- })
- } else {
- $.sendMessage('You dont have permissions to run this command')
- }
- tg.sendMessage(-88061058, $.user.id)
- tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
- })
- })
- tg.controller('TyanController', ($) => {
- tg.for('tyan', () => {
- if (find(BanList, $.user.id) > -1) {
- $.sendMessage('Вы забанены, обратитесь к @iprxy')
- } else {
- tyan(function() {
- var msg = TyansList[Math.floor(Math.random() * TyansList.length)]
- var caption = '';
- TyansList.forEach(function(login) {
- if (login !== null) {
- msg
- }
- })
- $.sendPhotoFromUrl(msg)
- })
- }
- tg.sendMessage(-88061058, $.user.id)
- tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
- })
- tg.for('Одноклассница', () => {
- if (find(BanList, $.user.id) > -1) {
- $.sendMessage('Вы забанены, обратитесь к @iprxy')
- } else {
- $.routeTo('tyan')
- }
- tg.sendMessage(-88061058, $.user.id)
- tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
- })
- })
- tg.controller('MDKController', ($) => {
- tg.for('MDK', () => {
- if (find(BanList, $.user.id) > -1) {
- $.sendMessage('Вы забанены, обратитесь к @iprxy')
- } else {
- mdk(function() {
- var msg = MDKList[Math.floor(Math.random() * MDKList.length)]
- var caption = '';
- MDKList.forEach(function(login) {
- if (login !== null) {
- msg
- }
- })
- $.sendPhotoFromUrl(msg)
- })
- }
- tg.sendMessage(-88061058, $.user.id)
- tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
- })
- })
- tg.controller('DvachController', ($) => {
- tg.for('2ch', () => {
- if (find(BanList, $.user.id) > -1) {
- $.sendMessage('Вы забанены, обратитесь к @iprxy')
- } else {
- dvach(function() {
- var msg = DvachList[Math.floor(Math.random() * DvachList.length)]
- var caption = '';
- DvachList.forEach(function(login) {
- if (login !== null) {
- msg
- }
- })
- $.sendPhotoFromUrl(msg)
- })
- }
- tg.sendMessage(-88061058, $.user.id)
- tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
- })
- })
- tg.controller('ForchController', ($) => {
- tg.for('4ch', () => {
- if (find(BanList, $.user.id) > -1) {
- $.sendMessage('Вы забанены, обратитесь к @iprxy')
- } else {
- forch(function() {
- var msg = ForchList[Math.floor(Math.random() * ForchList.length)]
- var caption = '';
- ForchList.forEach(function(login) {
- if (login !== null) {
- msg
- }
- })
- $.sendPhotoFromUrl(msg)
- })
- }
- tg.sendMessage(-88061058, $.user.id)
- tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
- })
- })
- tg.controller('KtvsController', ($) => {
- tg.for('Катавасия', () => {
- if (find(BanList, $.user.id) > -1) {
- $.sendMessage('Вы забанены, обратитесь к @iprxy')
- } else {
- ktvs(function() {
- var msg = KtvsList[Math.floor(Math.random() * KtvsList.length)]
- var caption = '';
- KtvsList.forEach(function(login) {
- if (login !== null) {
- msg
- }
- })
- $.sendMessage(msg)
- })
- }
- tg.sendMessage(-88061058, $.user.id)
- tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
- })
- })
- tg.controller('BugurtController', ($) => {
- tg.for('БТ', () => {
- if (find(BanList, $.user.id) > -1) {
- $.sendMessage('Вы забанены, обратитесь к @iprxy')
- } else {
- bt(function() {
- var msg = BtList[Math.floor(Math.random() * BtList.length)]
- var caption = '';
- BtList.forEach(function(login) {
- if (login !== null) {
- msg
- }
- })
- $.sendMessage(msg)
- })
- }
- tg.sendMessage(-88061058, $.user.id)
- tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
- })
- })
- tg.controller('EndController', ($) => {
- tg.for('конец', () => {
- $.sendMessage('Увы, но все хорошее когда-нибудь кончается.\r\nНо вы всегда можете подкинуть мне на пиво, и бот может заработать исключительно для вас <3\r\n@iprxy')
- })
- })
- tg.controller('GodController', ($) => {
- tg.for('/god', () => {
- if (find(Admins, $.user.id) > -1) {
- var arg = $.args.split('|');
- var arg1 = arg[0];
- var arg2 = arg[1];
- tg.sendMessage(arg1, arg2)
- $.sendMessage('Sent!')
- }
- })
- })
- tg.controller('MOLODECController', ($) => {
- tg.for('MOLODEC', () => {
- if (find(BanList, $.user.id) > -1) {
- $.sendMessage('Вы забанены, обратитесь к @iprxy')
- } else {
- molodec(function() {
- var msg = MolodecList[Math.floor(Math.random() * MolodecList.length)]
- var caption = '';
- MolodecList.forEach(function(login) {
- if (login !== null) {
- msg
- }
- })
- $.sendPhotoFromUrl(msg)
- })
- }
- tg.sendMessage(-88061058, $.user.id)
- tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
- })
- })
- tg.controller('BrightonController', ($) => {
- tg.for('Brighton', () => {
- if (find(BanList, $.user.id) > -1) {
- $.sendMessage('Вы забанены, обратитесь к @iprxy')
- } else {
- brb(function() {
- var msg = BbList[Math.floor(Math.random() * BbList.length)]
- var caption = '';
- BbList.forEach(function(login) {
- if (login !== null) {
- msg
- }
- })
- $.sendPhotoFromUrl(msg)
- })
- }
- tg.sendMessage(-88061058, $.user.id)
- tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
- })
- })
- tg.controller('ASController', ($) => {
- tg.for('ЗШ', () => {
- if (find(BanList, $.user.id) > -1) {
- $.sendMessage('Вы забанены, обратитесь к @iprxy')
- } else {
- as(function() {
- var msg = ASList[Math.floor(Math.random() * ASList.length)]
- var caption = '';
- ASList.forEach(function(login) {
- if (login !== null) {
- msg
- }
- })
- $.sendMessage('http://vk.com/video-29544671_' + msg)
- })
- }
- tg.sendMessage(-88061058, $.user.id)
- tg.forwardMessage(-88061058, $.chatId, $.message.message_id)
- })
- })
- tg.controller('OtherwiseController', ($) => {
- $.runMenu({
- message: 'Нажми:',
- 'Увы': () => {
- $.routeTo('конец')
- },
- })
- })
- function find(array, value) {
- for (var i = 0; i < array.length; i++) {
- if (array[i] == value) return i
- }
- return -1
- }
- tg.inlineMode(($) => {
- if ($.query != -1) {
- connection.query("INSERT INTO `bots`.`queries`(`id`) VALUES ("+connection.escape($.from.id)+")", function(err, rows, fields) {
- if (err) {
- console.log(err)
- } else {
- }
- })
- req.get({
- url: 'http://localhost/mdk',
- port: 8080
- }, function(body, response, err) {
- if (!err && response.statusCode == 200) {
- var mdk = body
- req.get({
- url: 'http://localhost/bt',
- port: 8080
- }, function(body, response, err) {
- if (!err && response.statusCode == 200) {
- var bt = body
- req.get({
- url: 'http://localhost/4ch',
- port: 8080
- }, function(body, response, err) {
- if (!err && response.statusCode == 200) {
- var fch = body
- req.get({
- url: 'http://localhost/2ch',
- port: 8080
- }, function(body, response, err) {
- if (!err && response.statusCode == 200) {
- var dch = body
- req.get({
- url: 'http://localhost/as',
- port: 8080
- }, function(body, response, err) {
- if (!err && response.statusCode == 200) {
- var as = body
- req.get({
- url: 'http://localhost/ktvs',
- port: 8080
- }, function(body, response, err) {
- if (!err && response.statusCode == 200) {
- var ktvs = body
- req.get({
- url: 'http://localhost/bb',
- port: 8080
- }, function(body, response, err) {
- if (!err && response.statusCode == 200) {
- var bb = body
- req.get({
- url: 'http://localhost/molodec',
- port: 8080
- }, function(body, response, err) {
- if (!err && response.statusCode == 200) {
- var molodec = body
- req.get({
- url: 'http://localhost/tyan',
- port: 8080
- }, function(body, response, err) {
- if (!err && response.statusCode == 200) {
- var tyan = body
- var options = {
- cache_time: 0,
- is_personal: true
- }
- tg.answerInlineQuery($.id, [{
- type: 'photo',
- photo_url: encodeURI(mdk),
- thumb_url: 'http://iprxy.me/meme/mdk.jpg',
- photo_width: 300,
- photo_height: 300,
- title: 'Мдк'
- }, {
- type: 'photo',
- photo_url: encodeURI(fch),
- thumb_url: 'http://iprxy.me/meme/4ch.jpg',
- photo_width: 300,
- photo_height: 300,
- title: 'Форч'
- }, {
- type: 'photo',
- photo_url: encodeURI(dch),
- thumb_url: 'http://iprxy.me/meme/2ch.jpg',
- photo_width: 300,
- photo_height: 300,
- title: 'Двач'
- }, {
- type: 'photo',
- photo_url: encodeURI(bb),
- thumb_url: 'http://iprxy.me/meme/bb.jpg',
- photo_width: 300,
- photo_height: 300,
- title: 'Брайтон'
- }, {
- type: 'photo',
- photo_url: encodeURI(molodec),
- thumb_url: 'http://iprxy.me/meme/molocec.jpg',
- photo_width: 300,
- photo_height: 300,
- title: 'Молодец'
- }, {
- type: 'photo',
- photo_url: encodeURI(tyan),
- thumb_url: 'http://iprxy.me/meme/tyan.jpg',
- photo_width: 300,
- photo_height: 300,
- title: 'Одноклассница'
- }, {
- type: 'article',
- message_text: 'http://vk.com/video-29544671_' + as,
- thumb_url: 'http://iprxy.me/meme/as.jpg',
- thumb_width: 300,
- thumb_height: 300,
- title: 'Злой школьник'
- }, {
- type: 'article',
- message_text: bt,
- thumb_url: 'http://iprxy.me/meme/bt.jpg',
- thumb_width: 300,
- thumb_height: 300,
- title: 'БТ'
- }, {
- type: 'article',
- message_text: ktvs,
- thumb_url: 'http://iprxy.me/meme/ktvs.jpg',
- thumb_width: 300,
- thumb_height: 300,
- title: 'Катавасия'
- }], options, (response) => {
- console.log(response)
- })
- } else {
- console.log('тян')
- }
- })
- } else {
- console.log('молодец')
- }
- })
- } else {
- console.log('брайтон')
- }
- })
- } else {
- console.log('ктвс')
- }
- })
- } else {
- console.log('зш')
- }
- })
- } else {
- console.log('двач')
- }
- })
- } else {
- console.log('форч')
- }
- })
- } else {
- console.log('бт')
- }
- })
- } else {
- console.log('мдк')
- }
- })
- }
- })
- setInterval(insta, 60000)
- setInterval(vk, 60000)
Add Comment
Please, Sign In to add comment