Skip to content

bossvirus03/Pangolin

Repository files navigation

PANGOLIN

A simple Facebook Messenger Bot using personal account with framework NestJs

NPM Version Static Badge

Installation

  • Download Nodejs & Git
  • Open git bash & enter
$ git clone https://github.com/bossvirus03/Pangolin.git

and then

$ npm install

Some settings to get started

  • Download c3c fbstate to get fbstate
  • Add that extension to chrome or any browse
  • Log in to your Facebook account, remember not to use your main account
  • Copy fbstate and paste into the appstate.json file located in the root directory
  • Instructional video Here

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Note

  • This is a messenger chat bot using a personal account, using facebook-chat-api and this is not supported from Facebook, so its use may result in the account being locked due to spam or some other reason.
  • i'm not responsible if your account gets banned for spammy activities such as sending lots of messages to people you don't know, sending messages very quickly, sending spammy looking URLs, logging in and out very quickly... Be responsible Facebook citizens.

Example Usage

Screenshot-2024-04-21-191605

Example create modules

  • From root directory to /src/modules/commands or /src/modules/events and then you need follow template Here
  • With prefix

    import { IPangolinRun } from "src/types/type.pangolin-handle";
     async run({
        api,
        event,
        client,
        args,
        UserData,
        ThreadData,
        UserInThreadData,
        getLang,
        pangolin,
      }: IPangolinRun) {
        // logic here
      }

    Listen event from command has prefix

    import { IPangolinHandleEvent } from "src/types/type.pangolin-handle";
     async handleEvent({
        api,
        event,
        client,
        UserData,
        ThreadData,
        UserInThreadData,
        getLang,
        pagolin,
      }: IPangolinHandleEvent) {
        // logic
      }

    No prefix

    import { IPangolinNoprefix } from "src/types/type.pangolin-handle";
     async noprefix({
        api,
        event,
        client,
        args,
        UserData,
        ThreadData,
        UserInThreadData,
        getLang,
        pangolin,
      }: IPangolinNoprefix) {
        // logic
      }

    Something you need to know

    • From functions handle command
    async run({
        api,
        event,
        client,
        args,
        UserData,
        ThreadData,
        UserInThreadData,
        getLang,
        pangolin,
      }: IPangolinRun){}

    In the code above

    api

    Example: send a message

    api.sendMessage("hello world", event.ThreadID);

    To see detail you need to Here

    event

    Some event you need to know

    • event.type
    • event.messageID
    • event.threadID
    • event.isGroup
    • event.body
    • event.senderID
    • ...Here

    args

    Example

    If you receive a message which is "nguyen van a", then args[0] = "nguyen", args[1] = "van", args[2] = "a"

    UserData

    Example get a user

    const user = await UserData.get("61556745520442");
    console.log(user);
    //response
    /*
       User {
            uid: "",
            name: "",
            exp: 0,
            money: 0,
            prefix: ""
        }
    */

    ThreadData

    Example get a thread

    const thread = await ThreadData.get("47923492740238");
    console.log(thread);
    //response
    /*
       Thread {
            name: "",
            tid: "",
            prefix: "",
            rankup: false,
            resend: false,
        }
    */

    UserInThreadData

    Example get a user in group

    const userInThread = await UserInThreadData.get(
      "61556745520442",
      "47923492740238",
    );
    console.log(userInThread);
    //response
    /*
       UserInThread {
            name: "",
            uid: "",
            uniqueId: "",
            tid: "",
            countMessageOfDay: 0,
            lastDayUpdate: "",
            countMessageOfWeek:0,
            lastWeekUpdate: ""
        }
    */

    pangolin

    To get all config of current bot

    const config = pangolin;
    console.log(config);
    // response
    /*
       {
        "botname": "heloo",
        "admins": [
            "100049732817959",
            "100000113681117"
        ],
        "prefix": ";",
        "commands": {
            "youtube_search_api": ""
        },
        "access_token": "",
        "log_event": false,
        "help_paginate": false
    } 
    */

    Stay in touch