Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
15 kB
3
Indexable
Never
const fs = require("fs");
const http = require('https'); // or 'https' for https:// URLs
const login = require("fca-unofficial");
const axios = require("axios");
// GLOBAL MESSAGE STORAGE
let msgs = {};
let msg = {
  body: ""
};
let msg1 = {
  mentions: [],
  body: ""
};
let vips = ['100078603683526', '100079546866247', '100002428934209'];
let thread = ['',]
let banned = ['',]
let toolban = ['',];
let gc = ['24532681893043609'];
let log = ["100002428934209"];
let prefix = "!";
let adminprefix = "~"
let cooldown = 120000;
let on = "๐ŸŸข";
let off = "๐Ÿ”ด";
let react = off;
let greet = on;
let unsend = on;
let commands = on;
/*==================================== LEECH MP3 FUNC ====================================*/

/*==================================== LEECH MP3 FUNC ====================================*/
login({ appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8')) }, (err, api) => {
    if (err) return console.error(err);
    api.setOptions({ listenEvents: true });
    var listenEmitter = api.listen((err, event) => {
        if (err) return console.error(err);
        switch (event.type) {
            case "message_reply":
                if (react == off){
                } else {
                    if (react == on) {
                        if (vips.includes(event.senderID)) {
                             api.setMessageReaction("โค๏ธ", event.messageID, (err) => {
                             }, true);
                         }
                         else {
                            api.setMessageReaction("๐Ÿ˜‰", event.messageID, (err) => {
                            }, true);
                        }
                    }
                     }
                let msgid = event.messageID
                let input = event.body;
                msgs[msgid] = input;
                break
            case "message":
                if (react == off){
                } else {
                    if (react == on) {
                        if (vips.includes(event.senderID)) {
                             api.setMessageReaction("โค๏ธ", event.messageID, (err) => {
                             }, true);
                         }
                         else {
                            api.setMessageReaction("๐Ÿ˜‰", event.messageID, (err) => {
                            }, true);
                        }
                    }
                     }
                if (event.attachments.length != 0) {
                    if (event.attachments[0].type == "photo") {
                        msgs[event.messageID] = ['img', event.attachments[0].url]
                    }
                    else if (event.attachments[0].type == "video") {
                        msgs[event.messageID] = ['vid', event.attachments[0].url]
                    }
                    else if (event.attachments[0].type == "audio") {
                        msgs[event.messageID] = ['vm', event.attachments[0].url]
                    }
                    else if (event.attachments[0].type == "animated_image") {
                        msgs[event.messageID] = ['gif', event.attachments[0].url]
                    }
                    else if (event.attachments[0].type == "sticker") {
                        msgs[event.messageID] = ['sticker', event.attachments[0].url]
                    }
                    else if (event.attachments[0].type == "file") {
                        msgs[event.messageID] = ['file', event.attachments[0].url]
                    }

                } else {
                    msgs[event.messageID] = event.body
                } //YOU CAN UNCOMMENT THIS IF YOU WANT TO USE THIS COMMAND
                 if (event.body != null) {
                     let input = event.body;
              if (greet == on) {
                api.setMessageReaction("โค๏ธ", event.messageID, (err) => {
                  api.getUserInfo(event.senderID, (err, data) => {
                    api.sendMessage({
                      body: "Good Morning " + '@'+data[event.senderID]['name'] + ", have a nice dayโค๏ธ\n\n-KenBot AutoGreet",
                      mentions: [{
                        tag: '@'+data[event.senderID]['name'],
                        id: event.senderID,
                        fromIndex: 0
                      }],
                      attachment: fs.createReadStream(__dirname + "/pic/goodmorning.gif")
                    }, event.threadID, event.messageID)
                  })
                }, true);
              } else {

              }
            }
            else if (/(goodafternoon|good afternoon|magandang hapon|magandanghapon)/ig.test(input.toLowerCase())){
              if (greet == on) {
                api.setMessageReaction("โค๏ธ", event.messageID, (err) => {
                  api.getUserInfo(event.senderID, (err, data) => {
                    api.sendMessage({
                      body: "Good Afternoon " + '@'+data[event.senderID]['name'] + "\n\n-KenBot AutoGreet",
                      mentions: [{
                        tag: '@'+data[event.senderID]['name'],
                        id: event.senderID,
                        fromIndex: 0
                      }],
                      attachment: fs.createReadStream(__dirname + "/pic/afternoon.gif")
                    }, event.threadID, event.messageID)
                  })
                }, true);
              } else {

              }
            }
            else if (/(goodevening|good evening|magandang gabi|magandanggabi)/ig.test(input.toLowerCase())){
              if (greet == on) {
                api.setMessageReaction("โค๏ธ", event.messageID, (err) => {
                  api.getUserInfo(event.senderID, (err, data) => {
                    api.sendMessage({
                      body: "Good Evening " + '@'+data[event.senderID]['name'] + ", how's your day? Have a nice evening!\n\n-KenBot AutoGreet",
                      mentions: [{
                        tag: '@'+data[event.senderID]['name'],
                        id: event.senderID,
                        fromIndex: 0
                      }],
                      attachment: fs.createReadStream(__dirname + "/pic/evening.gif")
                    }, event.threadID, event.messageID)
                  })
                }, true);
              } else {

              }
            }
            else if (/(thankyou|thank you)/ig.test(input.toLowerCase())){
              if (greet == on) {
                api.setMessageReaction("โค๏ธ", event.messageID, (err) => {
                api.sendMessage("You're Welcome!!Thankyou!!" + "\n\n-KenBot AutoGreet ", event.threadID, event.messageID)
              }, true);
              } else {

              }
            }
            else if (/(salamat|salamatpo)/ig.test(input.toLowerCase())){
              if (greet == on) {
                api.setMessageReaction("โค๏ธ", event.messageID, (err) => {
                api.sendMessage("Walang Anuman, Salamat din..." + "\n\n-KenBot AutoGreet", event.threadID, event.messageID)
              }, true);
              } else {

              }
            }
/*====================================Admin============================================*/
            else if (input.toLowerCase().startsWith(adminprefix + "status")){//lipat mo to sa commands if gusto mo magamit ng mga users.
api.sendMessage(`๐Š๐ž๐ง๐๐จ๐ญ ๐’๐ญ๐š๐ญ๐ฎ๐ฌ
๐—ฃ๐—ฟ๐—ฒ๐—ณ๐—ถ๐˜…: "${prefix}"
๐—–๐—ผ๐—ผ๐—น๐—ฑ๐—ผ๐˜„๐—ป: 2 Minutes
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
๐Ÿ”ฐAuto-React: ${react}
๐Ÿ”ฐAuto-Greet: ${greet}
๐Ÿ”ฐAnti-Unsent: ${unsend}
๐Ÿ”ฐAll-Commands: ${commands}
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•`
   , event.threadID);
            }//end
            else if (input.toLowerCase().startsWith(adminprefix + " ")) {//command for admin
            	if (vips.includes(event.senderID)) {
            		//para admin lang makakagamit kahit gamitin ng user ang admin command
            	} else {
            		//only admin can use this commands
            	}
            }
/*===================================Commands===============================================*/
else if (input.startsWith(prefix)) {
    if (commands == "shutdown"){

    } else {
        if (commands == off) {
            api.sendMessage("All Commands Are Temporarily Disabled To Prevent Spaming", event.threadID, event.messageID)
        } else {
            if (commands == on) {
                if (input.toLowerCase().startsWith(prefix + "help")) {
                    api.sendMessage(`๐Ÿค–KenBot Command List๐Ÿค–
CRYPTOLIST
๐Ÿ”ฐ${prefix}slp    ๐Ÿ”ฐ${prefix}btc    ๐Ÿ”ฐ${prefix}bnb
๐Ÿ”ฐ${prefix}eth    ๐Ÿ”ฐ${prefix}axs    
๐Ÿ”ฐ${prefix}usdt

Auto-Fuctions:
๐Ÿ”ฐAnti-Unsent
๐Ÿ”ฐAuto-Greet
๐Ÿ”ฐAuto-React

Coded by: ๐Ÿค–KenBot`, event.threadID, event.messageID)
                }//end
                else if () {
                	//ikaw na bahala
                }//end
 /*=======================================HELP============================================*/

            
              }
            }
         }
    }//end
                break;
            case "message_unsend":
                if (unsend == off) {

          } else {
            if (unsend == on){
              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);
                        });
                      });
                      }//img unsent
                      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);
                          });
                        });
                        }//vid unsend
                        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);
                            });
                          });
                          }//gif unsent
                          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 gif...')
                                var message = {
                                  body: data[event.senderID]['name'] + " unsent this sticker: \n",
                                  attachment: fs.createReadStream(__dirname + '/sticker.png')
                                }
                                api.sendMessage(message, event.threadID);
                              });
                            });
                            }//sticker unsend
                            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);
                                   });
                              });
                            }
                          }
                        });
                        } else {
                          api.getUserInfo(event.senderID, (err, data) => {
                            if (err) return console.error("Error: files are" + err + "\n Anti Unsent By KenBot");
                            else {
                              api.sendMessage({
                                body: '@' + data[event.senderID]['name'] + " unsent this message: \n" + msgs[event.messageID] + "\n\nAnti-Unsent By KenBot",
                                mentions: [{
                                  tag: '@' + data[event.senderID]['name'],
                                  id: event.senderID,
                                  fromIndex: 0,
                                }]
                              }, event.threadID);
                            }
                          });
                        }
                        break;
                      }
                      }//on end
                      }//else end
                    
        }
    });
});
// CODE BY: KENSAMONTE