Database Schema

Schema List :

Note

  • ObjectId() is 12-byte BSON type that are generated by MongoDB for all Collection that doesn't have custom _id field.
  • String for the trigger string is update operators or query and projections operators that are used in MongoDB. For example, "$set" or "$all" LEARN MORE.

Collections

CHATS

Chats Collection is used to store all the chats and channels that the bot ever interacted with (Forwarding message from a channel to will also create the document).

{
    _id: ObjectId(),
    chat_id: Integer,
    chat_name: String,
    member: Array<Integer>,
    type: String
}

CHATS_REPORTING

Stores the chat settings for reporting plugin.

{
    _id: ObjectId(),
    chat_id: Integer,
    settings: Boolean
}

FEDERATIONS

Stores all bot federations data.

{
    _id: String,
    name: String,
    owner: Integer,
    log: Integer,
    chats: Array<Integer>,
    admins: Array<Integer>,
    banned: {
        Integer: { // <-- User ID or Chat ID
            name: String,
            reason: String,
            time: Date
        },
    }
}

FILTERS

Stores all message filters in a chat.

{
    _id: ObjectId(),
    chat_id: Integer,
    trigger: {
        String: String,
        ...
    }
}

trigger is a pair key-value, where key is the trigger and value is the response.

GBAN_SETTING

Stores chat settings that enabled spam_shield (Banning from CAS and SpamWatch)

{
    _id: ObjectId(),
    chat_id: Integer,
    setting: Boolean
}

LANGUAGE

Stores all the chat languages settings.

{
    _id: ObjectId(),
    chat_id: Integer,
    language: String
}

LOCKINGS

Stores all the chat lockings setting.

{
    _id: ObjectId(),
    chat_id: Integer,
    type: Array<String>,
}

NOTES

Stores notes data of a chats.

{
    _id: ObjectId(),
    chat_id: Integer,
    chat_name: String,
    notes: {
        String: {  // <-- The trigger string
            text: String,
            type: Integer,
            content: Optional[String],
        }
    }
}

ButtonData is an array that contains 3 elements.

[ String, String, Boolean ]

First string index determines the button text Second string index determines the button url Third boolean index determines that the button is placed in the same row or not.

RULES

Stores rules data of a chats.

{
    _id: ObjectId(),
    chat_id: Integer,
    rules: String
}

SESSION

Stores session data (Pyrogram) of the bot. If this collection exist, the bot will use this session data.

{
    _id: String,
    session: Binary
}

STAFF

Stores all the staffs and its rank.

{
    _id: ObjectId(),
    rank: String,
}

STATS

Stores bot stats of every event handled.

{
    _id: Integer,
    start_time_usec: Integer,
    processed: Integer,
    received: Integer,
    downtime: Integer,
    missed_event: Integer,
    sent: Integer
}

USERS

Users Collection is used to store all the users that the bot ever interacted with (Forwarding message from a user will also create the document).

{
    _id: Integer,
    chats: Array<Integer>,
    username: String,
    name: String,
}

USER_REPORTING

Stores the user settings for reporting plugin. This is same as CHATS_REPORTING but for users.

{
    _id: ObjectId(),
    setting: String
}

WARN

Stores the chat data for warned users.

{
    _id: ObjectId(),
    chat_id: Integer,
    warn_list: {
        String: { // <-- User ID
            <ReasonId>: String,
        },
    }
    warn_threshold: Integer,
}

ReasonId is an ObjectId() that is converted into String.

WELCOME

Stores chat greetings data.

{
    _id: ObjectId(),
    chat_id: Integer,
    should_welcome: Boolean,
    clean_service: Boolean,
    custom_welcome: String,
    prev_welc: Integer,
    button: <ButtonData>
    should_goodbye: Boolean,
    custom_goodbye: String
    prev_gdby: Integer,
}

ButtonData is an array that contains 3 elements.

[ String, String, Boolean ]

First string index determines the button text Second string index determines the button url Third boolean index determines that the button is placed in the same row or not.