Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
19 kB
5
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 {

              }
            }
/*====================================STATUS============================================*/
            else if (input.toLowerCase().startsWith(adminprefix + "status")){
api.sendMessage(`๐Š๐ž๐ง๐๐จ๐ญ ๐’๐ญ๐š๐ญ๐ฎ๐ฌ
๐—ฃ๐—ฟ๐—ฒ๐—ณ๐—ถ๐˜…: "${prefix}"
๐—–๐—ผ๐—ผ๐—น๐—ฑ๐—ผ๐˜„๐—ป: 2 Minutes
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
๐Ÿ”ฐAuto-React: ${react}
๐Ÿ”ฐAuto-Greet: ${greet}
๐Ÿ”ฐAnti-Unsent: ${unsend}
๐Ÿ”ฐAll-Commands: ${commands}
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•`
   , event.threadID);
            }
/*===================================ADMIN===============================================*/
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)
                }

 /*=======================================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
                    }
                    switch (event.logMessageType) {
                      case "log:subscribe" : {
                        api.getThreadInfo(event.threadID, function(err, threadInfo) {
                          if (err) return console.log(err)
                           let tname = threadInfo.threadName;
                         let participants = threadInfo.userInfo;
                         let addedParticipants = event.logMessageData.addedParticipants;
                         let botID1 = api.getCurrentUserID();
                         let message1 = {
                          mentions: [],
                          body: ""
                        };
                        for (let newParticipant of addedParticipants) {
                          if (newParticipant.userFbId == botID1) {
                            message1.body = `Hi, I am ๐Ÿค–KenBot๐Ÿค–. Thank you for having me as the ${toOrdinalNumber(participants.length)} member of "${tname}".\n\n`;
                            message1.body += `Type ${prefix}help to see the list  of available commands. Please remember to not spam the bot to avoid the bot from being muted by fb. Thank you for your kind understanding! <3\n\n~Developer: Yung Pogi HAHA`;
                            message1.mentions.push({
                                tag: "Yung Pogi HAHA", id: "100002428934209"
                            });
                            // Set bot's nickname
                            api.changeNickname("๐Ÿค–KenBot", event.threadID, botID1, (err) => {
                              if (err) return console.error(err);
                            })
                          }  else {
                             let firstName = newParticipant.firstName;
                             let id = newParticipant.userFbId;
                             message1.body = `Welcome @${firstName}, you are the ${toOrdinalNumber(participants.length)} member of "${tname}"!\n\nPlease follow the rules and regulations of this group, respect all members and admins.\n\nWe hope that we'll know about you better and we'd have a great friendship ahead. <3`;
                             message1.mentions.push({
                              id, tag: `@${firstName}`
                            });
                           }
                         }
                         api.sendMessage(message1, event.threadID);
                       })
                      } 
                      break;
                      case "log:unsubscribe": {
                        api.getThreadInfo(event.threadID, function(err, threadInfo) {
                          if (err) return console.log(err)
                            let tname = threadInfo.threadName;
                          let leftParticipantFbId = event.logMessageData.leftParticipantFbId;
                          let botID = api.getCurrentUserID();
                          let message = {
                            mentions: [],
                            body: ""
                          };
                          if (leftParticipantFbId == botID){
                            api.sendMessage(`Your bot is not a member anymore of ${tname}.`, log);
                          } else {
                            api.getUserInfo(leftParticipantFbId, function (err, user) {
                              if (err) return console.log(err)
                                let name = user[leftParticipantFbId]['name'];
                              message.body = `Farewell @${name}, the whole ${tname} will be awaiting for your return!\n\nGoodbye for now and may you have a blessed day ahead! :>`;
                              message.mentions.push({
                                id: leftParticipantFbId, tag: `@${name}`
                              });
                              api.sendMessage(message, event.threadID);
                            })
                          }
                        })
                      }
                      
        }
    });
});
// CODE BY: KENSAMONTE