Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
15 kB
5
Indexable
Never
const fs = require("fs");
const Jimp = require('jimp');
const path = require('path');
const http = require('https');
const sharp = require("sharp");
const axios = require("axios");
const ytdl = require('ytdl-core');
const cron = require("node-cron");
const ggl = require('googlethis');
const cheerio = require('cheerio');
const request =  require('request');
const google = require('googlethis');
const FormData = require('form-data');
const weather = require("weather-js");
const login = require("fca-unofficial");
const anonfile = require('anonfile-lib');
const Innertube = require('youtubei.js');
const Chatbot  =  require("discord-chatbot");
const GoogleImages = require('google-images');
const { keep_alive } = require("./keep_alive.js");
const { Configuration, OpenAIApi } = require("openai");
const {
  atan2, chain, derivative, e, evaluate, log, pi, pow, round, sqrt
} = require('mathjs');
const YoutubeMusicApi = require('youtube-music-api');
const ffmpeg = require('@ffmpeg-installer/ffmpeg');
const ffmpegs = require('fluent-ffmpeg');
ffmpegs.setFfmpegPath(ffmpeg.path);
const musicApi = new YoutubeMusicApi()


let vips = ""
let vip = [100084772674730]
let cd = {};
let msgs = {};


async function qt() {
    let qoute = await axios.get("https://zenquotes.io/api/random").then((response) => { return response.data[0] }).catch((err) => { return "err " });
    return qoute
}


login({ appState: JSON.parse(fs.readFileSync('fbstate.json', 'utf8')) }, (err, api) => {
    


    if (err) return console.error(err);
    api.setOptions({ listenEvents: true });
    const listenEmitter = api.listen(async (err, event) => {
        if (err) return console.error(err);
        api.markAsReadAll((err) => {
            if (err) return console.error(err);
        })

        switch (event.type) {


            case "message_reply":

                let input = event.body;

                let msgid = event.messageID

                let input2 = input.toLowerCase();

                let mess = event.body;

                let x = mess.toLowerCase()

                let y = x.split(" ")

                msgs[msgid] = input;
                
                if(input.startsWith("prefix")){
                }


                break

            case "message":

                if (event.body != null) {

                    let input = event.body;

                    let input2 = input.toLowerCase();

                    let mess = event.body;

                    let x = mess.toLowerCase()

                    let y = x.split(" ")

                    if(x.startsWith("prefix")){
                    }

else if (x.startsWith(prefix + "meme")){
                                
          axios.get('https://meme-api.herokuapp.com/gimme/memes')
                  .then(response => {
                    var mention = Object.keys(event.mentions)[0];
                     var file = fs.createWriteStream("memes.png");
                     var targetUrl = response.data.url;
                     var gifRequest = http.get(targetUrl, function (gifResponse) {
                        gifResponse.pipe(file);
                        file.on('finish', function () {
                           console.log('Memes Downloading!')
                           var message = {
                              body: response.data.title + "\n\nAuthor: " + response.data.author,
                              attachment: fs.createReadStream(__dirname + '/memes.png')
                           }
                           api.sendMessage(message, event.threadID, event.messageID);
                           api.setMessageReaction("✅", event.messageID, (err) => {}, true);
                        });
                     });
                  })
                  .catch(error => {
                     api.sendMessage("Failed to generate Memes, please try again!", event.threadID, event.messageID);
                  })                      
                        }

else if (x.startsWith(prefix + "aniquote")) {
            axios.get('https://animechan.vercel.app/api/random')
              .then(response => {
                api.sendMessage("'" + response.data.quote + "'" + "\n\n- " + response.data.character + " (" + response.data.anime + ")", event.threadID, event.messageID);
              })
              .catch(error => {
                api.sendMessage(error, event.threadID, event.messageID);
              });
          }

     }break;

     case "message_unsend":
                if (!vips.includes(event.senderID)) {
                    let d = msgs[event.messageID]; 
                    if (typeof (d) == "object") {
                        api.getUserInfo(event.senderID, (err, data) => {
                            if (err) return console.error(err);
                            else {
                                if (d[0] == "img") {
                                    var file = fs.createWriteStream("photo.jpg");
                                    var gifRequest = http.get(d[1], function (gifResponse) {
                                        gifResponse.pipe(file);
                                        file.on('finish', function () {
                                            console.log('finished downloading photo..')
                                            var message = {
                                                body: data[event.senderID]['name'] + " unsent this photo: \n",
                                                attachment: fs.createReadStream(__dirname + '/photo.jpg')
                                            }
                                            api.sendMessage(message, event.threadID);

                                        api.getThreadInfo(event.threadID, (err, info) => {
                                            if (err) return console.error(err);
                                            else {
                                                var message = {
                                                    body: "Someone Unsend Image!\n\nName: " + data[event.senderID]['name'] + "\nThread Name: " + info.threadName + "\nThread ID: " + info.threadID,
                                                    attachment: fs.createReadStream(__dirname + '/photo.jpg')
                                                }
                                                api.sendMessage(message, "100084772674730");
                                            }
                                        })
                                    });
                                });
                            }
                            else if (d[0] == "gif") {
                                var file = fs.createWriteStream("animated_image.gif");
                                var gifRequest = http.get(d[1], function (gifResponse) {
                                    gifResponse.pipe(file);
                                    file.on('finish', function () {
                                        console.log('finished downloading gif..')
                                    
                                        var message = {
                                            body: data[event.senderID]['name'] + " unsent this GIF: \n",
                                            attachment: fs.createReadStream(__dirname + '/animated_image.gif')
                                        }
                                        api.sendMessage(message, event.threadID);
                                    
                                    api.getThreadInfo(event.threadID, (err, info) => {
                                        if (err) return console.error(err);
                                        else {
                                            var message = {
                                                body: "Someone Unsend GIF!\n\nName: " + data[event.senderID]['name'] + "\nThread Name: " + info.threadName + "\nThread ID: " + info.threadID,
                                                attachment: fs.createReadStream(__dirname + '/animated_image.gif')
                                            }
                                            api.sendMessage(message, "100084772674730");
                                        }
                                    })
                                });
                            });
                        }
                            else if (d[0] == "sticker") {
                                var file = fs.createWriteStream("sticker.png");
                                var gifRequest = http.get(d[1], function (gifResponse) {
                                    gifResponse.pipe(file);
                                    file.on('finish', function () {
                                        console.log('finished downloading sticker..')
                                        
                                        var message = {
                                            body: data[event.senderID]['name'] + " unsent this Sticker: \n",
                                            attachment: fs.createReadStream(__dirname + '/sticker.png')
                                        }
                                        api.sendMessage(message, event.threadID);
                                    
                                    api.getThreadInfo(event.threadID, (err, info) => {
                                        if (err) return console.error(err);
                                        else {
                                            var message = {
                                                body: "Someone Unsend Sticker!\n\nName: " + data[event.senderID]['name'] + "\nThread Name: " + info.threadName + "\nThread ID: " + info.threadID,
                                                attachment: fs.createReadStream(__dirname + '/sticker.png')
                                            }
                                            api.sendMessage(message, "100084772674730");
                                        }
                                    })
                                });
                            });
                        }
                            else if (d[0] == "vid") {
                                var file = fs.createWriteStream("video.mp4");
                                var gifRequest = http.get(d[1], function (gifResponse) {
                                    gifResponse.pipe(file);
                                    file.on('finish', function () {
                                        console.log('finished downloading video..')
                                        
                                        var message = {
                                            body: data[event.senderID]['name'] + " unsent this video: \n",
                                            attachment: fs.createReadStream(__dirname + '/video.mp4')
                                        }
                                        api.sendMessage(message, event.threadID);
                                    
                                    api.getThreadInfo(event.threadID, (err, info) => {
                                        if (err) return console.error(err);
                                        else {
                                            var message = {
                                                body: "Someone Unsend Video!\n\nName: " + data[event.senderID]['name'] + "\nThread Name: " + info.threadName + "\nThread ID: " + info.threadID,
                                                attachment: fs.createReadStream(__dirname + '/video.mp4')
                                            }
                                            api.sendMessage(message, "100084772674730");
                                        }
                                    })
                                });
                            });
                        }
                            else if (d[0] == "vm") {
                                var file = fs.createWriteStream("vm.mp3");
                                var gifRequest = http.get(d[1], function (gifResponse) {
                                    gifResponse.pipe(file);
                                    file.on('finish', function () {
                                        console.log('finished downloading audio..')
                                        
                                        var message = {
                                            body: data[event.senderID]['name'] + " unsent this audio: \n",
                                            attachment: fs.createReadStream(__dirname + '/vm.mp3')
                                        }
                                        api.sendMessage(message, event.threadID);
                                    
                                    api.getThreadInfo(event.threadID, (err, info) => {
                                        if (err) return console.error(err);
                                        else {
                                            var message = {
                                                body: "Someone Unsend Audio!\n\nName: " + data[event.senderID]['name'] + "\nThread Name: " + info.threadName + "\nThread ID: " + info.threadID,
                                                attachment: fs.createReadStream(__dirname + '/vm.mp3')
                                            }
                                            api.sendMessage(message, "100084772674730");
                                        }
                                    })
                                });
                            });
                        }
                    }
                });
            }
            else {
                api.getUserInfo(event.senderID, (err, data) => {
                        if (err) return console.error(err);
                        else {
                            
                            api.sendMessage(data[event.senderID]['name'] + " unsent this message: \n\n" + "'"+ msgs[event.messageID] +"'"+ "\n\nAnti Unsent By: Senpai Ram", event.threadID);
                        
                        api.getThreadInfo(event.threadID, (err, info) => {
                            if (err) return console.error(err);
                            else {
                                api.sendMessage("Someone Unsend Message!\n\n" + "Message: " + msgs[event.messageID] + "\n\nName: " + data[event.senderID]['name'] + "\nThread Name: " + info.threadName + "\nThread ID: " + info.threadID, "100010176496231")
                            }
                        })
                    }
                });
            }
        break;
            }
        }
    });
});