commit
This commit is contained in:
parent
9651a70271
commit
85edd5b626
2 changed files with 15 additions and 35 deletions
|
@ -23,9 +23,12 @@ module.exports = {
|
||||||
fs.readFile('./src/telegram_helps/default.txt', 'utf8', (err, data) => {
|
fs.readFile('./src/telegram_helps/default.txt', 'utf8', (err, data) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
addToLogs(err);
|
||||||
bot.telegram.sendMessage(ctx.chat.id, "Something went wrong", {});
|
bot.telegram.sendMessage(ctx.chat.id, "Something went wrong", {});
|
||||||
} else {
|
} else {
|
||||||
bot.telegram.sendMessage(ctx.chat.id, data, {parse_mode: 'Markdown'});
|
bot.telegram.sendMessage(ctx.chat.id, data, {parse_mode: 'Markdown'});
|
||||||
|
console.log("[Telegram] sent the help message to " + ctx.message.from.username);
|
||||||
|
addToLogs("[Telegram] sent the help message to " + ctx.message.from.username);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -35,8 +38,8 @@ module.exports = {
|
||||||
github : (bot) => {
|
github : (bot) => {
|
||||||
bot.command('github', ctx => {
|
bot.command('github', ctx => {
|
||||||
bot.telegram.sendMessage(ctx.chat.id, 'Link of the Gihhub repository :\n -https://github.com/Ninja-Jambon/chaise_bot', {})
|
bot.telegram.sendMessage(ctx.chat.id, 'Link of the Gihhub repository :\n -https://github.com/Ninja-Jambon/chaise_bot', {})
|
||||||
console.log('--> sent github link')
|
console.log('[Telegram] sent github link')
|
||||||
addToLogs('--> sent github link')
|
addToLogs('[Telegram] sent github link')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -48,8 +51,8 @@ module.exports = {
|
||||||
|
|
||||||
chatinfo : (bot) => {
|
chatinfo : (bot) => {
|
||||||
bot.command('chatinfo', ctx => {
|
bot.command('chatinfo', ctx => {
|
||||||
console.log('--> sent chat info')
|
console.log('[Telegram] sent chat info')
|
||||||
addToLogs('--> sent chat info')
|
addToLogs('[Telegram] sent chat info')
|
||||||
bot.telegram.sendMessage(ctx.chat.id, 'Chat id : ' + ctx.chat.id, {})
|
bot.telegram.sendMessage(ctx.chat.id, 'Chat id : ' + ctx.chat.id, {})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -58,8 +61,8 @@ module.exports = {
|
||||||
bot.command('suggest', ctx => {
|
bot.command('suggest', ctx => {
|
||||||
bot.telegram.sendMessage('-1001782224138', 'New suggestion of ' + ctx.message.from.username + " : " + ctx.message.text.slice(+9), {})
|
bot.telegram.sendMessage('-1001782224138', 'New suggestion of ' + ctx.message.from.username + " : " + ctx.message.text.slice(+9), {})
|
||||||
bot.telegram.sendMessage(ctx.chat.id, 'Your suggestion has been sent to the channel t.me/+SrzC81CGyusyODNk', {})
|
bot.telegram.sendMessage(ctx.chat.id, 'Your suggestion has been sent to the channel t.me/+SrzC81CGyusyODNk', {})
|
||||||
console.log('--> sent suggestion message to the channel')
|
console.log('[Telegram] sent suggestion message to the channel')
|
||||||
addToLogs('--> sent suggestion message to the channel')
|
addToLogs('[Telegram] sent suggestion message to the channel')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -78,7 +81,7 @@ module.exports = {
|
||||||
dadjoke : (bot) => {
|
dadjoke : (bot) => {
|
||||||
bot.command('dadjoke', ctx => {
|
bot.command('dadjoke', ctx => {
|
||||||
getJoke(ctx, bot)
|
getJoke(ctx, bot)
|
||||||
console.log('--> sent a dad joke')
|
console.log('[Telegram] sent a dad joke')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,7 @@
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const google = require('googlethis');
|
|
||||||
|
|
||||||
function image_search(query, ctx, bot) {
|
|
||||||
const images = google.image(query, { safe: false }).catch(err => {
|
|
||||||
console.log(err);
|
|
||||||
addToLogs("--> error : " + err);
|
|
||||||
bot.telegram.sendMessage(ctx.chat.id, "Something went wrong", {"reply_to_message_id": ctx.update.message.message_id});
|
|
||||||
});
|
|
||||||
images.then((results) => {
|
|
||||||
var imgLink = results[Math.floor(Math.random() * results.length)].url
|
|
||||||
bot.telegram.sendPhoto(ctx.chat.id, imgLink, {"caption": "This is a random image for the query : " + query}).catch(err => {
|
|
||||||
console.log(err);
|
|
||||||
addToLogs("--> error : " + err);
|
|
||||||
bot.telegram.sendMessage(ctx.chat.id, "Something went wrong", {"reply_to_message_id": ctx.update.message.message_id});
|
|
||||||
});
|
|
||||||
console.log("--> sent the image for the query: " + query);
|
|
||||||
addToLogs("--> sent the image for the query: " + query);
|
|
||||||
}).catch(err => {
|
|
||||||
console.log(err)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function isTrue(message, ctx, bot) {
|
function isTrue(message, ctx, bot) {
|
||||||
if (message != undefined) {
|
if (message != undefined) {
|
||||||
console.log("--> message received: " + message);
|
|
||||||
addToLogs("--> message received: " + message);
|
|
||||||
var totalSum = 0
|
var totalSum = 0
|
||||||
|
|
||||||
for (var i = 0; i < message.length; i++) {
|
for (var i = 0; i < message.length; i++) {
|
||||||
|
@ -32,13 +9,13 @@ function isTrue(message, ctx, bot) {
|
||||||
}
|
}
|
||||||
if (totalSum%2 == 0) {
|
if (totalSum%2 == 0) {
|
||||||
bot.telegram.sendMessage(ctx.chat.id, "This message is true", {"reply_to_message_id": ctx.update.message.reply_to_message.message_id});
|
bot.telegram.sendMessage(ctx.chat.id, "This message is true", {"reply_to_message_id": ctx.update.message.reply_to_message.message_id});
|
||||||
console.log("--> sent true for the query: " + message);
|
console.log("[Telegram] sent true for the query: " + message);
|
||||||
addToLogs("--> sent true for the query: " + message);
|
addToLogs("[Telegram] sent true for the query: " + message);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bot.telegram.sendMessage(ctx.chat.id, "This message is false", {"reply_to_message_id": ctx.update.message.reply_to_message.message_id});
|
bot.telegram.sendMessage(ctx.chat.id, "This message is false", {"reply_to_message_id": ctx.update.message.reply_to_message.message_id});
|
||||||
console.log("--> sent false for the query: " + message);
|
console.log("[Telegram] sent false for the query: " + message);
|
||||||
addToLogs("--> sent false for the query: " + message);
|
addToLogs("[Telegram] sent false for the query: " + message);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bot.telegram.sendMessage(ctx.chat.id, "Please reply to a text message", {'reply_to_message_id': ctx.update.message.message_id});
|
bot.telegram.sendMessage(ctx.chat.id, "Please reply to a text message", {'reply_to_message_id': ctx.update.message.message_id});
|
||||||
|
@ -71,4 +48,4 @@ function getHelp(commandName, ctx, bot) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { addToLogs, isTrue, image_search, getHelp };
|
module.exports = { addToLogs, isTrue, getHelp };
|
Loading…
Add table
Add a link
Reference in a new issue