make it better

This commit is contained in:
Secven 2021-07-14 19:36:59 +00:00
parent 71d0923731
commit 6e60fb6d5f
16 changed files with 136 additions and 64 deletions

View File

@ -1,13 +1,8 @@
# @BotFather => /newbot
#TG API SERVICING
# http://127.0.0.1:8081
TG_APIROOT = 'https://api.telegram.org'
# @BotFather => /newbot
BOT_TOKEN = '1745011940:AAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
# ADMIN for report message
ADMIN_ID = 1159809878
# Example ( BOT_CLUSTER_CORE = 2 ) or AutoScale ( BOT_CLUSTER_CORE = 0 )
BOT_CLUSTER_CORE = 2
# Mongoose databse
#MONGOOSE_URL = 'mongodb+srv://secven:secvennotabugsecven@cluster0.myekb.mongodb.net/secven'
MONGOOSE_URL = 'mongodb://127.0.0.1/secven'
ADMIN_ID = 1872887287
BOT_CLUSTER_CORE = 0
MONGOOSE_URL = 'mongodb+srv://:@cluster0.myekb.mongodb.net/secven'
DADATA_TOKEN = '1b333051049e4edbgffffffffffffffffffffffgg'
DADATA_SECRET = '303bd4ac15aegggggggggggggggggggggggggggg'

View File

@ -1,8 +1,8 @@
module.exports = {
apps: [
{
name: 'APP-BOT',
script: './index.js',
name: require('package.json').name,
script: require('package.json').main,
max_memory_restart: '1000M',
wait_ready: true,
restart_delay: 5000,

View File

@ -1,5 +1,5 @@
{
"name": "bot-pattern-telegraf",
"name": "bot-eye-leak",
"version": "1.0.0",
"main": "index.js",
"author": "<secven@riseup.net>",
@ -9,8 +9,8 @@
"start": "cross-env NODE_ENV=development node index.js",
"dev": "cross-env NODE_ENV=development nodemon index.js",
"prod": "cross-env NODE_ENV=production node index.js",
"pm:stop": "cross-env NODE_ENV=production pm2 stop ecosystem.config.js",
"pm:prod": "cross-env NODE_ENV=production pm2 start ecosystem.config.js",
"pm:stop": "pm2 stop ecosystem.config.js",
"pm:prod": "pm2 start ecosystem.config.js",
"pm:up": "pm2 startup"
},
"dependencies": {

View File

@ -16,11 +16,9 @@ config.consignOpts = {
config.limitSecurity = {
window: ms('15s'),
limit: 5,
onLimitExceeded: ({ message, replyWithHTML }) =>
replyWithHTML('❗Please wait a second (5s)', {
disable_notification: true
})
limit: 4,
onLimitExceeded: ({ answerCbQuery }) =>
answerCbQuery('❗Please wait a second !', true)
}
config.i18nOpts = {

View File

@ -43,6 +43,7 @@ const Route = new Router(({ callbackQuery }) => {
})()
bot.route = Route
bot.rateLimit = rateLimit
bot.context.db = db
bot.context.extra = Extra
bot.context.markup = Markup

View File

@ -1,15 +1,19 @@
const { SERVICE } = require('../util/service')
class EyeofgodTask {
checkLeak = async ({ db, i18n, extra, message, session, replyWithHTML }) => {
try {
const id = (session.eyeof = message.text.trim())
const base = await db.Eye.findOne({ id }).sort({ id: 1 }).lean()
/// const expectData = await SERVICE.getInfoOperator(base?.phone)
return await replyWithHTML(
i18n.t('eyeofgod', {
id: base.id,
phone: base?.phone,
nPhone: base?.phone,
username: base?.username,
fullName: `${base?.first_name} | ${base?.last_name}`
fullName: `${base?.first_name ?? ''} | ${base?.last_name ?? ''}`
// ...expectData
}),
extra
.HTML()
@ -25,10 +29,9 @@ class EyeofgodTask {
)
)
)
} catch (e) {
// console.log(e.message)
} catch {
return await replyWithHTML(
'💮 <b>No in Database</b>',
'📍 <b>There is no database !</b>',
extra
.HTML()
.inReplyTo(message.message_id)

View File

@ -1,7 +1,7 @@
const fetch = require('node-fetch')
class JokeTask {
async getRandomAnimation(ctx) {
async getRandomAnimation({ replyWithAnimation }) {
const page = Math.floor(Math.random() * 100)
return Promise.resolve(
await fetch(`https://developerslife.ru/top/${page}?json=true`)
@ -11,7 +11,7 @@ class JokeTask {
const index = Number(Math.floor(Math.random() * data.result.length))
// eslint-disable-next-line security/detect-object-injection
const { videoURL: sendGif, description: caption } = data.result[index]
return ctx.replyWithAnimation(sendGif, {
return replyWithAnimation(sendGif, {
caption,
parse_mode: 'HTML'
})

View File

@ -1,19 +1,19 @@
class StartTask {
async start({ reply, replyWithSticker, message, i18n, from, extra }) {
await replyWithSticker(
'CAACAgIAAxkBAAIBs2DeqZIZBIYgeFBsno36780WxeHsAAIQAAPDVgMednAUKnTod-sgBA'
'CAACAgIAAxkBAAIZH2DvF-OAI9Kzy_QazXqHYR0rUD7-AAIXAAPDVgMeQjlqcLJ92EYgBA'
)
const markup = extra
.HTML()
.inReplyTo(message.message_id)
// .webPreview(false)
.webPreview(false)
.markup(m =>
m.inlineKeyboard(
[
m.urlButton('Subscribe', 'https://t.me/ThisOpenSource'),
m.callbackButton('Subscribe ACQ', 'startMenu|test'),
m.callbackButton('💰 Donate', 'startMenu|donate'),
m.urlButton('❤️ My Notabug', 'https://notabug.org/Secven'),
m.callbackButton('❌ Delete', 'delete')
m.urlButton('😊 Subscribe', 'https://t.me/ThisOpenSource'),
m.callbackButton(i18n.t('default.closeMessage'), 'delete')
],
{ columns: 2 }
)
@ -21,8 +21,17 @@ class StartTask {
return await reply(i18n.t('main.start', { ...from }), markup)
}
subscribe = async ctx => {
return await ctx.answerCbQuery('https://t.me/ThisOpenSource', true)
donateMe = async ({ i18n, extra, editMessageText }) => {
return editMessageText(
i18n.t('main.donate'),
extra
.HTML()
.markup(m =>
m.inlineKeyboard([
m.callbackButton(i18n.t('default.closeMessage'), 'delete')
])
)
)
}
}

View File

@ -1,22 +1,34 @@
eyeofgod: |
👁 <b>EyeOfGod Leak:</b>
├ 🆔 ID: <code>${id}</code>
├ 📱 Phone: <code>${phone}</code>
├ 👤 Username: <code>${username}</code>
├ 📱 Phone: <code>+${nPhone}</code>
├ 👤 Username: @${username}
└ ⚫️ FullName: <code>${fullName}</code>
main:
start: |
💰 <b>Donete me:</b>
├ https://t.me/ThisOpenSource
🆘 Bot accepts requests to search for following formats:
👁 <b>Telegram</b>
├ <code>596999557</code> - Search by ID
└ <code>@username</code> - Soon
🤖 <b>Bot command</b>
├ /joke - IT gifs Funny
└ /lang - Change language
🗂 <b>Database</b>
├ ✅ <code>EyeOfGod 2021</code>
├ ✅ <code>Parsing 2021</code>
├ ❌ <code>Leak base May</code>
└ ❌ <code>Parsing 2020</code>
❔ If you want more databases you need to help Donat
donate: |
💰 <b>Donate:</b>
├ BTC - <code>1Ebf7gBSSD5Y8y3zLHVy1SuJxAqAgJPjhW</code>
└ XMR - <code>45UcKcUN8d6M5cccXZiqC1dtpMsqSazyKSLGP3utQh3MhBmeuCuHAbYBwngsa1eAFs4yza9HukiH4axjNg58YGBrJo2x2tS</code>
🆘 <b>SOS:</b>
├ <b>Check Database EyeOfGod:</b>
├ Just send me ID: <code>596999557</code>
└ /eye 596999557
├ <b>Change language</b>:
└ /lang
❤️ <b>Thanks you for support</b>
stackError:
report: |
<b>Handler Middleware:</b>
@ -27,7 +39,6 @@ stackError:
Stack: <code>${stack}</code>
🤖 BOTNAME: ${botName}
default:
lang: |
🤖 Language settings

View File

@ -1,22 +1,28 @@
eyeofgod: |
👁 <b>EyeOfGod Leak:</b>
├ 🆔 Айди: <code>${id}</code>
├ 📱 Телефон: <code>${phone}</code>
├ 👤 Имя пользователя: <code>${username}</code>
├ 📱 Телефон: <code>+${nPhone}</code>
├ 👤 Имя пользователя: @${username}
└ ⚫️ Полное Имя: <code>${fullName}</code>
main:
start: |
💰 <b>Поддержать меня:</b>
├ https://t.me/ThisOpenSource
├ BTC - <code>1Ebf7gBSSD5Y8y3zLHVy1SuJxAqAgJPjhW</code>
└ XMR - <code>45UcKcUN8d6M5cccXZiqC1dtpMsqSazyKSLGP3utQh3MhBmeuCuHAbYBwngsa1eAFs4yza9HukiH4axjNg58YGBrJo2x2tS</code>
🆘 Бот принимает запросы на поиск следующих форматов:
🆘 <b>SOS:</b>
├ <b>Проверьте в базе EyeOfGod:</b>
├ Просто отправь мне ID: <code>596999557</code>
└ /eye 596999557
├ <b>Изменение языка</b>:
└ /lang
👁 <b>Telegram</b>
├ <code>596999557</code> - Поиск по ID
└ <code>@username</code> - Скоро
🤖 <b>Bot command</b>
├ /joke - IT gifs Funny
└ /lang - Изменение языка
🗂 <b>База данных</b>
├ ✅ <code>EyeOfGod 2021</code>
├ ✅ <code>Parsing 2021</code>
├ ❌ <code>Leak base May</code>
└ ❌ <code>Parsing 2020</code>
❔ Если вы хотите больше баз данных, вам нужно помочь Donat
stackError:
report: |
<b>Обработчик Middleware:</b>

View File

@ -2,7 +2,7 @@ const { escapeHtml } = require('../util/escapeHTML')
module.exports = async ({ db, from, i18n, session }, next) => {
// eslint-disable-next-line camelcase
const { id, first_name, username, language_code } = from
const { id, first_name, username } = from
if (!id) return await next()
await db.User.findOne({ user_id: id })
.then(root => {

View File

@ -1,4 +1,16 @@
module.exports = bot => {
const { eyeofgodTask } = bot.handlers
bot.hears(/^[0-9]{5,20}$/, eyeofgodTask.checkLeak)
const expect = bot.rateLimit({
window: 1000 * 20,
limit: 1,
onLimitExceeded: ({ replyWithHTML }) =>
replyWithHTML(
'<code>I can handle from you only one request in 15 seconds.</code>'
)
})
bot.hears(/^[0-9]{5,20}$/g, expect, eyeofgodTask.checkLeak)
// TODO: Select menu add
}

View File

@ -1,5 +1,7 @@
module.exports = bot => {
const { jokeTask } = bot.handlers
bot.hears(['/joke', '!joke'], jokeTask.getRandomAnimation)
bot.hears(['/joke', '!joke', '!jo'], jokeTask.getRandomAnimation)
// TODO: add moar
}

View File

@ -10,7 +10,7 @@ module.exports = bot => {
answerCbQuery,
editMessageText
}) => {
if (String(state.value)) {
if (state.value) {
await answerCbQuery(state.value).then(() => {
session.root.settings.lang = state.value
i18n.locale(state.value)

View File

@ -5,8 +5,8 @@ module.exports = bot => {
const routeList = ctx => {
switch (String(ctx.state.value)) {
case 'test':
return startTask.subscribe(ctx)
case 'donate':
return startTask.donateMe(ctx)
}
}

35
src/util/service.js Normal file
View File

@ -0,0 +1,35 @@
const fetch = require('node-fetch')
const getInfoOperator = async (num = '79521305638') => {
// eslint-disable-next-line no-async-promise-executor
return new Promise(async resolve => {
const url = 'https://cleaner.dadata.ru/api/v1/clean/phone'
await fetch(url, {
method: 'POST',
mode: 'cors',
headers: {
Authorization: 'Token ' + process.env.DADATA_TOKEN,
'X-Secret': process.env.DADATA_SECRET,
'Content-Type': 'application/json'
},
compress: true,
body: JSON.stringify([num])
})
.then(res => {
if (res.statusCode === 401)
throw new Error('dadata.ru:: key or secret invalid')
if (res.statusCode === 403)
throw new Error('dadata.ru:: invalid secret key')
return res.json()
})
.then(data => resolve(...data))
.catch(err => console.error('end dadata.ru::', err.message))
})
}
const SERVICE = {
getInfoOperator: getInfoOperator
}
module.exports = { SERVICE }