commit
This commit is contained in:
parent
0bd53741af
commit
8f8309cda0
1 changed files with 6 additions and 6 deletions
12
app.js
12
app.js
|
@ -4,16 +4,11 @@ const google = require('googlethis');
|
||||||
//bot initialization
|
//bot initialization
|
||||||
const bot = new Telegraf(process.env.TELEGRAM);
|
const bot = new Telegraf(process.env.TELEGRAM);
|
||||||
|
|
||||||
//variable
|
|
||||||
var last = "";
|
|
||||||
|
|
||||||
|
|
||||||
//function to search google
|
//function to search google
|
||||||
function image_search(query, ctx) {
|
function image_search(query, ctx) {
|
||||||
const images = google.image(query, { safe: false });
|
const images = google.image(query, { safe: false });
|
||||||
images.then((results) => {
|
images.then((results) => {
|
||||||
var imgLink = results[Math.floor(Math.random() * results.length)].url
|
var imgLink = results[Math.floor(Math.random() * results.length)].url
|
||||||
last = imgLink;
|
|
||||||
console.log("--> sent the image for the query: " + query);
|
console.log("--> sent the image for the query: " + query);
|
||||||
bot.telegram.sendPhoto(ctx.chat.id, imgLink, {"caption": "This is a random image for the query : " + query});
|
bot.telegram.sendPhoto(ctx.chat.id, imgLink, {"caption": "This is a random image for the query : " + query});
|
||||||
});
|
});
|
||||||
|
@ -28,7 +23,7 @@ bot.command('start', ctx => {
|
||||||
|
|
||||||
bot.help(ctx => {
|
bot.help(ctx => {
|
||||||
console.log(ctx.from)
|
console.log(ctx.from)
|
||||||
ctx.reply('This is the help message :\nhelp command : \n -/help\nAnime command : \n -/anime\nimage search command : \n -/search or /s')
|
ctx.reply('This is the help message :\nHelp command : \n -/help\nAnime command : \n -/anime\nImage search command : \n -/search or /s\nGithub link command : \n -/github')
|
||||||
})
|
})
|
||||||
|
|
||||||
bot.command('anime', ctx => {
|
bot.command('anime', ctx => {
|
||||||
|
@ -46,5 +41,10 @@ bot.command('s', ctx => {
|
||||||
image_search(ctx.message.text.slice(+3), ctx)
|
image_search(ctx.message.text.slice(+3), ctx)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
bot.command('github', ctx => {
|
||||||
|
console.log(ctx.from)
|
||||||
|
bot.telegram.sendMessage(ctx.chat.id, 'Link of the Gihhub repository :\n -https://github.com/Ninja-Jambon/chaise_bot', {})
|
||||||
|
})
|
||||||
|
|
||||||
//bot launch
|
//bot launch
|
||||||
bot.launch();
|
bot.launch();
|
Loading…
Add table
Add a link
Reference in a new issue