diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..91cb81d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,29 @@ +name: ci +on: + push: + branches: + - master + - main +permissions: + contents: write +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Configure Git Credentials + run: | + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV + - uses: actions/cache@v4 + with: + key: mkdocs-material-${{ env.cache_id }} + path: .cache + restore-keys: | + mkdocs-material- + - run: pip install mkdocs-material + - run: mkdocs gh-deploy --force diff --git a/CONFIG_DOCUMENTATION.md b/CONFIG_DOCUMENTATION.md deleted file mode 100644 index cd5bf86..0000000 --- a/CONFIG_DOCUMENTATION.md +++ /dev/null @@ -1,71 +0,0 @@ - config.json documentation - -Essential settings - -botToken: - Your bot token that you can get from @BotFather - -botStaff: - Array of userId(String) considered bot staff - - -Privacy settings - -deleteChatDataAfterBotRemove: - If enabled all chat data (configurations included) will be deleted from bot database when you kick the bot from a group - -overwriteChatDataIfReAddedToGroup: - If enabled chat data and configurations will be regenerated if bot has been re-added to the group (similiar to deleteChatDataAfterBotRemove,) - -allowExternalApi: - Allow to gather additional data by varous online api's, that's may reveal the ip of your server, default to false - - -Other settings - -reserveLang: - Principal language for the bot, this will be used to overwrite other languages with incompleted translations, we advise to keep it unchanged or use a full implemented language - -saveDatabaseSeconds: - Number of seconds of how often loaded chats should be written on disk, useful to prevent data loss on crash - -saveTagResolverSeconds: - Number of seconds of how often tagResolver data should be saved on disk - -maxCallbackAge: - Maximum number of seconds a callback button should be old to be accepted by the bot, you can reduce this in case of incompatible callbacks after an update that cause crash - -preventSetUselessRoles: - Disallow from setting roles if it does not change the user status in the group - -chatWhitelist: - Array, if there are at least one element the bot will work only on this chat ids - -privateWhitelist: - Boolean, true if chat whitelist includes private chats, useless if chatWhitelist has no elements - -chatBlacklist: - Bot wont more handle requests of chat ids in this array - - -Plugin settings - -ANTIFLOOD_msgMin: - minimum allowed number of messages to triggher the antiflood - -ANTIFLOOD_msgMax: - maximum allowed number of messages to triggher the antiflood - -ANTIFLOOD_timeMin: - minimum allowed time in which N messages should be sent to triggher the antiflood - -ANTIFLOOD_timeMax: - maximum allowed time in which N messages should be sent to triggher the antiflood - -minWarns: - minimum allowed warns in settings - -maxWarns: - maximum allowed warns in settings - - diff --git a/GHbot.js b/GHbot.js index 3462db4..eb2af08 100644 --- a/GHbot.js +++ b/GHbot.js @@ -1,16 +1,14 @@ const TelegramBot = require("node-telegram-bot-api"); const { pushUserRequest } = require("./api/tg/SafeTelegram"); -/** - * @typedef {import("node-telegram-bot-api")} TelegramBot - */ //BASIC DECLARATIONS /** - * @typedef {Object} AnonTGUser - Descrizione di base dell'oggetto. + * @typedef {Object} AnonTGUser - Basic anonymized user object * @property {String|Number} id - userId */ + //PUNISH /** * @typedef {0|1|2|3|4} Punishment @@ -23,7 +21,7 @@ const { pushUserRequest } = require("./api/tg/SafeTelegram"); */ /** * @typedef {Object} LGHPunish antispam.js settings Object. - * @property {Punishment} punishment - Punishment to apply [0:off|1:warn|2:kick|3:mute|4:ban]. + * @property {Punishment} punishment - Punishment to apply [0:off/1:warn/2:kick/3:mute/4:ban]. * @property {Number|null} PTime - Available if punishment is set to warn/mute/ban, contains seconds of punishment. * @property {boolean|null} delete - True if deletion is enabled as side effect. */ @@ -42,46 +40,60 @@ const { pushUserRequest } = require("./api/tg/SafeTelegram"); * @property {LGHPunish} latin - Punish to apply for messages containing latin characters. */ + //TARGETUSER /** * @typedef {Object} TargetUser - Object that refers to a target user * @property {string|number} id - Telegram user Id * @property {string} name - Full LGH name identifier: "fullName [id]" * @property {LGHPerms} perms - LGHPerms with perms of target - * @property {TelegramBot.usersDir|false} user - If avaiable, target basic user object + * @property {TelegramBot.User|null} user - If avaiable, target basic user object */ +/** + * @enum {number} + * @description Permission status + * - 1: allowed + * - 0: neutral + * - -1: denied + */ +const PermissionStatus = { + ALLOWED: 1, + NEUTRAL: 0, + DENIED: -1, +}; + //PERMISSIONS /** * @typedef {Object} LGHPerms - LGHPerms Object. * @property {Array.} commands - Array of commands, if starts with "COMMAND_" means its to be translated, otherwise is the literal command. - * @property {1|0|-1} immune - Active if this user can't receive any punishment (kick/warn/mute/ban) [1/0/-1]. - * @property {1|0|-1} flood - Permission to flood messages [1/0/-1]. - * @property {1|0|-1} link - Permission to send links [1/0/-1]. - * @property {1|0|-1} tgLink - Permission to send telegram links/usernames [1/0/-1]. - * @property {1|0|-1} forward - Permission to forward messages from anywhere [1/0/-1]. - * @property {1|0|-1} quote - Permission to quote from anywhere [1/0/-1]. - * @property {1|0|-1} porn - Bypass porn/gore checks [1/0/-1]. - * @property {1|0|-1} night - Bypass any night mode limitation [1/0/-1]. - * @property {1|0|-1} media - Bypass any media limitation [1/0/-1]. - * @property {1|0|-1} alphabets - Bypass any alphabets characters limitations [1/0/-1]. - * @property {1|0|-1} words - Bypass banned words limitations [1/0/-1]. - * @property {1|0|-1} length - Bypass message length limitations [1/0/-1]. - * @property {1|0|-1} roles - Permission to change roles of lower level users [1/0/-1]. - * @property {1|0|-1} settings - Permission to change bot group settings [1/0/-1]. + * @property {PermissionStatus} immune - Active if this user can't receive any punishment (kick/warn/mute/ban) [1/0/-1]. + * @property {PermissionStatus} flood - Permission to flood messages [1/0/-1]. + * @property {PermissionStatus} link - Permission to send links [1/0/-1]. + * @property {PermissionStatus} tgLink - Permission to send telegram links/usernames [1/0/-1]. + * @property {PermissionStatus} forward - Permission to forward messages from anywhere [1/0/-1]. + * @property {PermissionStatus} quote - Permission to quote from anywhere [1/0/-1]. + * @property {PermissionStatus} porn - Bypass porn/gore checks [1/0/-1]. + * @property {PermissionStatus} night - Bypass any night mode limitation [1/0/-1]. + * @property {PermissionStatus} media - Bypass any media limitation [1/0/-1]. + * @property {PermissionStatus} alphabets - Bypass any alphabets characters limitations [1/0/-1]. + * @property {PermissionStatus} words - Bypass banned words limitations [1/0/-1]. + * @property {PermissionStatus} length - Bypass message length limitations [1/0/-1]. + * @property {PermissionStatus} roles - Permission to change roles of lower level users [1/0/-1]. + * @property {PermissionStatus} settings - Permission to change bot group settings [1/0/-1]. */ //MESSAGEMAKER /** - * @typedef {Object} simpleMedia - object with data about an user in a group - * @property {String|false} type - Type of media (audio, photo, video, video_note, animation, sticker, document) or false + * @typedef {Object} simpleMedia + * @property {String|null} type - Type of media (audio, photo, video, video_note, animation, sticker, document) or false * @property {String} fileId - media fileId or false * @property {Object} options - additional options for TelegramBot */ /** - * @typedef {Object} customMessage - object with data about an user in a group + * @typedef {Object} customMessage - object of MessageMaker * @property {String} text - Text of messsage * @property {Array.} entities - Telegram entities of text * @property {Array.} roles - array user roles, string for pre-made roles, number for custom roles (user-made) @@ -91,14 +103,19 @@ const { pushUserRequest } = require("./api/tg/SafeTelegram"); * @property {Array.} buttonsParsed - already parsed buttons ready to use for inline_keyboard */ + //CUSTOM CHAT DECLARATIONS /** - * @typedef {TelegramBot.ChatAdministratorRights & {user: AnonTGUser} & {status: TelegramBot.ChatMemberStatus}} LGHAdmin + * @typedef {object} LGHAdminAdds + * @property {AnonTGUser} user - Basic anonymized user object + * @property {TelegramBot.ChatMemberStatus} status + */ +/** + * @typedef {TelegramBot.ChatAdministratorRights | LGHAdminAdds} LGHAdmin */ /** * @typedef {Array} LGHAdminList */ - /** * @typedef {Object} userStatus - object with data about an user in a group * @property {Number} firtJoin - Unix number of first user join time in seconds, false if unknown (managed by welcome.js) @@ -106,9 +123,8 @@ const { pushUserRequest } = require("./api/tg/SafeTelegram"); * @property {LGHPerms} adminPerms - LGHPerms object for user permissions if admin * @property {Array.} roles - array user roles, string for pre-made roles, number for custom roles (user-made) * @property {String|undefined} title - user administrator title - * @property {String|false} waitingReply - string with callback data hirarchy if bot is expecting a message from user on group + * @property {String|null} waitingReply - string with callback data hirarchy if bot is expecting a message from user on group */ - /** * @typedef {Object} LGHRole - if pre-made role (string key) only users object should be used * @property {String|null} name - role name @@ -118,6 +134,7 @@ const { pushUserRequest } = require("./api/tg/SafeTelegram"); * @property {Array.} users - array of userId in this role */ + //PLUGINS DECLARATIONS //warns /** @@ -125,7 +142,7 @@ const { pushUserRequest } = require("./api/tg/SafeTelegram"); * @property {Object.} timed - ([userId]: [endTime, endTime, endTime]) contains necerray data to revoke scheduled warns when time is over * @property {Object.} count - ([userId]: number) countains count of warns for each user * @property {Number} limit - number of warns after wich should be applyed a punishment - * @property {2|3|4} punishment - punishment when limit is hit [2:kick|3:mute|4:ban] + * @property {2|3|4} punishment - punishment when limit is hit [2:kick/3:mute/4:ban] * @property {Number|null} PTime - avaiable if punishment is set to warn/mute/ban, contains seconds of punishment */ @@ -155,7 +172,7 @@ const { pushUserRequest } = require("./api/tg/SafeTelegram"); * @typedef {Object} LGHSpamTgLinksAdds - antispam.js settings Object additional items. * @property {Boolean} usernames - True if usernames should be considered as spam. * @property {Boolean} bots - True if bots should be considered as spam. - * @property {Array} exceptions - Array of Telegram exceptions, may contain "Name:Id", "Name:|hidden" (for hidden users), or t.me link, or @username, "Name" + * @property {Array} exceptions - Array of Telegram exceptions, may contain "Name:Id", `Name:|hidden` (for hidden users), or t.me link, or @username, "Name" */ /** * @typedef {LGHSpamTgLinksAdds & LGHPunish} LGHSpamTgLinks - antispam.js settings about Telegram Links Object. @@ -200,7 +217,7 @@ const { pushUserRequest } = require("./api/tg/SafeTelegram"); * @property {Number} time - Time limit to solve the captcha * @property {boolean} once - True if should be sent only at first user join (from welcome.js) (default false). * @property {boolean} fails - True if captcha should notify on group that someone failed the captcha (default false). - * @property {Punishment} punishment - Punishment to apply [1:warn|2:kick|3:mute|4:ban]. + * @property {Punishment} punishment - Punishment to apply [1:warn/2:kick/3:mute/4:ban]. * @property {Number} PTime - Available if punishment is set to warn/mute/ban, contains seconds of punishment. */ @@ -259,8 +276,8 @@ const { pushUserRequest } = require("./api/tg/SafeTelegram"); * @property {LGHAdminList|null} admins - array with known admins objects (user data anonymized) * @property {String|null} lang - current chat lang * @property {String|null} currency - currency of chat, default to USD - * @property {string|false} link - group access link - * @property {Boolean} isGroup - temporary item, result of (chat.type == "supergroup" || chat.type == "group") + * @property {string|null} link - group access link + * @property {Boolean} isGroup - temporary item, result of `(chat.type == "supergroup" || chat.type == "group")` * @property {Object.|null} users - Object-IdName based data about every user in the group (ex. users[643547] access data of userId 643547) * @property {Object.|null} roles - data about a specific role, full role Object if it's a custom role (key with a number) * @property {LGHPerms} basePerms - base permissions applyed to every user @@ -275,7 +292,6 @@ const { pushUserRequest } = require("./api/tg/SafeTelegram"); * @property {LGHAlphabetBasedPunish|null} alphabets - alphabets.js plugin related data * @property {LGHMedia|null} media - media.js plugin related data */ - /** * @typedef {TelegramBot.Chat & CustomChat} LGHChat - Full LGH chat object given by LGHBot events, custom items avaiable if working about a group */ @@ -295,7 +311,7 @@ testObject() * @property {LGHPerms|null} perms - temporary object with summary of user permissions * @property {String} lang - current user lang * @property {String} waitingReply - set to true if the bot is expecting a message from the user - + */ /** * @typedef {TelegramBot.User & CustomUser} LGHUser - Custom chat object given by LGHBot events, custom items avaiable if working about a group */ @@ -312,21 +328,18 @@ testObject() * @property {(string|boolean)} args - The arguments of the command (optional). * @property {(Array.|boolean)} splitArgs - The split arguments of the command (optional). */ - /** * @typedef {Object} CustomCommand - Additional items to command for LGH - * @property {TargetUser|false} target - Optional temporary object with data about a target LGH user in the command, false if no target found + * @property {TargetUser|null} target - Optional temporary object with data about a target LGH user in the command, false if no target found */ - /** * @typedef {Object} CustomMessage * @property {LGHChat} chat - Always original chat object where the message is coming from * @property {ParsedCommand & CustomCommand} command - result of message text parsed with parseCommand() - * @property {TargetUser|false} target - Optional temporary object with data about a command target - * @property {string|false} waitingReply - Optional temporary object with waitingReply data for the selected chat - * @property {TargetUser|false} waitingReplyTarget - Optional temporary object with data about a target LGH user, false if no target found + * @property {TargetUser|null} target - Optional temporary object with data about a command target + * @property {string|null} waitingReply - Optional temporary object with waitingReply data for the selected chat + * @property {TargetUser|null} waitingReplyTarget - Optional temporary object with data about a target LGH user, false if no target found */ - /** * @typedef {TelegramBot.Message & CustomMessage} LGHMessage - Custom chat object given by LGHBot events, custom items avaiable if working about a group */ @@ -338,98 +351,29 @@ testObject() * @property {LGHChat} chat - Always original chat object where the callback is coming from * @property {TargetUser} target - Optional temporary object with data about a target LGH user in the command, false if no target found */ - /** * @typedef {TelegramBot.CallbackQuery & CustomCallback} LGHCallback - Custom callback object given by LGHBot events, custom items may be avaiable */ //DATABASE -/** - * @typedef {Function} AddChatFunction - * @param {LGHChat} chat - The chat object to add. - * @returns {Boolean} True if the chat was successfully added, otherwise false. - */ - -/** - * @typedef {Function} DeleteChatFunction - * @param {TelegramBot.ChatId} chatId - The ID of the chat to delete. - * @returns {Boolean} True if the chat was successfully deleted, otherwise false. - */ - -/** - * @typedef {Function} ExistChatFunction - * @param {TelegramBot.ChatId} chatId - The ID of the chat to check. - * @returns {Boolean} True if the chat exists in the database, otherwise false. - */ - -/** - * @typedef {Function} GetChatFunction - * @param {TelegramBot.ChatId} chatId - The ID of the chat to retrieve. - * @returns {LGHChat|false} The retrieved chat object if found, otherwise false. - */ - -/** - * @typedef {Function} UpdateChatFunction - * @param {LGHChat} chat - The updated chat object. - * @returns {Boolean} True if the chat was successfully updated, otherwise false. - */ - -/** - * @typedef {Function} SaveChatFunction - * @param {TelegramBot.ChatId} chatId - The ID of the chat to save. - * @returns {Boolean} True if the chat was successfully saved, otherwise false. - */ - /** * @typedef {Object} chatsDatabase - Object containing chat-related database functions. - * @property {AddChatFunction} add - Function to add a new chat to the database. - * @property {DeleteChatFunction} delete - Function to delete a chat from the database. - * @property {ExistChatFunction} exhist - Function to check if a chat exhists in the database. - * @property {GetChatFunction} get - Function to retrieve a chat from the database. - * @property {UpdateChatFunction} update - Function to update a chat in the database. - * @property {SaveChatFunction} save - Function to save a chat to the database. + * @property {function(TelegramBot.Chat): boolean} add - Function to add a new chat to the database. ------------------------------------ `function(TelegramBot.Chat): boolean` + * @property {function(TelegramBot.ChatId): boolean} delete - Function to delete a chat from the database. ------------------------------------ `function(TelegramBot.ChatId): boolean` + * @property {function(TelegramBot.ChatId): boolean} exhist - Function to check if a chat exhists in the database. ------------------------------------ `function(TelegramBot.ChatId): boolean` + * @property {function(TelegramBot.ChatId): LGHChat} get - Function to retrieve a chat from the database. ------------------------------------ `function(LGHChat): boolean` + * @property {function(LGHChat): boolean} update - Function to update a chat in the database. ------------------------------------ `function(LGHChat): boolean` + * @property {function(TelegramBot.ChatId): boolean} save - Function to save a chat to the database. ------------------------------------ `function(TelegramBot.ChatId): boolean` */ - -/** - * @typedef {Function} AddUserFunction - * @param {LGHUser} user - The user object to add. - * @returns {Boolean} Result of adding a user to the database. - */ - -/** - * @typedef {Function} DeleteUserFunction - * @param {TelegramBot.ChatId} userId - The ID of the user to delete. - * @returns {Boolean} Result of deleting a user from the database. - */ - -/** - * @typedef {Function} ExistUserFunction - * @param {TelegramBot.ChatId} userId - The ID of the user to check. - * @returns {Boolean} Indicates whether the user exists in the database. - */ - -/** - * @typedef {Function} GetUserFunction - * @param {TelegramBot.ChatId} userId - The ID of the user to retrieve. - * @returns {LGHUser} Data retrieved for the user from the database. - */ - -/** - * @typedef {Function} UpdateUserFunction - * @param {LGHUser} user - The updated user object. - * @returns {boolean} True if the user was successfully updated, otherwise false. - */ - /** * @typedef {Object} usersDatabase - Object containing user-related database functions. - * @property {Function} add - Function to add a new user to the database. - * @property {Function} delete - Function to delete a user from the database. - * @property {Function} exhist - Function to check if a user exhists in the database. - * @property {Function} get - Function to retrieve a user from the database. - * @property {Function} update - Function to update a user in the database. + * @property {function(TelegramBot.User): boolean} add - Function to add a new user to the database. ------------------------------------ `function(TelegramBot.User): boolean` + * @property {function(TelegramBot.ChatId): boolean} delete - Function to delete a user from the database. ------------------------------------ `function(TelegramBot.ChatId): boolean` + * @property {function(TelegramBot.ChatId): boolean} exhist - Function to check if a user exhists in the database. ------------------------------------ `function(TelegramBot.ChatId): boolean` + * @property {function(TelegramBot.ChatId): LGHUser} get - Function to retrieve a user from the database. ------------------------------------ `function(TelegramBot.ChatId): LGHUser` + * @property {function(LGHUser): boolean} update - Function to update a user in the database. ------------------------------------ `function(LGHUser): boolean` */ - /** * @typedef {Object} LGHDatabase - Type returned by the getDatabase function. * @property {string} innerDir - Location where the database folder should be placed (and/or generated). @@ -445,9 +389,9 @@ testObject() //TEMPLATE DECLARATION /** * @typedef {Object} LibreGHelp - * @property {TelegramBot} GHbot - Test - * @property {TelegramBot} TGbot - Test - * @property {LGHDatabase} db - Test + * @property {LGHInterface} GHbot - Public interface for LGH Functions + * @property {TelegramBot} TGbot - Raw telegram bot api + * @property {LGHDatabase} db - Database interface */ /** @@ -455,11 +399,11 @@ testObject() * @classdesc * @param {LibreGHelp} LibreGHelp - Libre Group Help telegram bot handler */ -class main { +class LGHInterface { constructor(LibreGHelp) { /** - * @type {TelegramBot} + * @type {LGHInterface} */ this.GHbot = LibreGHelp.GHbot; @@ -483,7 +427,7 @@ class main { /** * LGHbot message event handler - * @param {(arg1: LGHMessage, arg2: LGHChat, arg3: LGHUser) => void} handler - handler function + * @param {function(LGHMessage, LGHChat, LGHUser): void} handler - handler function */ onMessage(handler) { this.GHbot.on("message", handler); @@ -491,7 +435,7 @@ class main { /** * LGHbot callback event handler - * @param {(arg1: LGHCallback, arg2: LGHChat, arg3: LGHUser) => void} handler - handler function + * @param {function(LGHCallback, LGHChat, LGHUser): void} handler - handler function */ onCallback(handler) { this.GHbot.on("callback_query", handler); @@ -652,4 +596,4 @@ class main { } )} } -module.exports = main; +module.exports = LGHInterface; diff --git a/README.md b/README.md index 27b2837..8b67ce9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## LibreGroupHelp +# LibreGroupHelp Open-Source re-creation of telegram group manager Group Help in NodeJS based on [node-telegram-api](https://github.com/yagop/node-telegram-bot-api). @@ -6,39 +6,23 @@ An official instance of bot is running on [@LibreGroupHelpBot](https://t.me/Libr ## Installation: -```bash -npm install -``` +Be sure to have installed a recent version of [NodeJS](https://nodejs.org/) -Set your bot token on config.js, look at [config documentation](https://github.com/Sp3rick/GroupHelp/blob/main/CONFIG_DOCUMENTATION.md). +Verify NodeJS installation with `node -v` -Run with: -```bash -node index.js -``` +Set your bot token using configuration file, look at [config documentation](configuration.md). -Installation trubleshooting: +Open a terminal inside LibreGroupHelp folder and run this commands -if you have problems with node-telegram-bot-api installation try this command url based: ```bash -npm i https://github.com/yagop/node-telegram-bot-api +npm install ``` -and if needed install other packages manually: +Now you should be ready to run LibreGroupHelp using: ```bash -npm i chrono-node +node index.js ``` -## Contribute - -Useful links to contribute: - -[documentation.md](https://github.com/Sp3rick/GroupHelp/blob/main/documentation.md). - -[Create a plugin](https://github.com/Sp3rick/GroupHelp/blob/main/plugins.md). - -[TODO (good first issue)](https://github.com/Sp3rick/GroupHelp/contribute). - ## What is done @@ -97,75 +81,12 @@ Useful links to contribute: ``` ## Updating -To update the bot you need to backup ./database folder and ./config.json only, then repeat installation process and paste there the old database and config.json, you may need to add some config.json parameters manually - - -## Our TODO List: - --short term: - - allow to edit single user perms - commands help panel - --medium term: - - allow on /perms to change user perms and roles, +add it in a button for /info or when a role is set (/free /mod etc..), +ask double confirm to give an user the "settings" and "roles" permission - support for anonymous admins - allow to customize /staff allowing to set roles to hide - create a privacy setting where users can ask to esclude themself from tagResolver and replace his's first name in database with "Anonymous" - allow to disable tagResolver log on group settings - allow to mute only media, or specific media type or extras - create a privacy option to allow a user deleting his data from the bot - custom roles - optimize database.get, .update and .save to store in temporal array most used users - implement time zone setting +implement it in /info - --long term: - - add log channel - chatIds anonymization on database - compress chats data stored on database - support all group help functions and more (+anti-sheduled messages[msg.is_from_offline], ) - allow bot clone bot when user give a token - add optionally an userbot (when active implement in tagResolver.js) - --other things: - - implement direct private settings with /*settings - add a /commands command to help user to know bot commands, admin commands, and custom-group commands if avaiable - a check system to drop wrong formatted cb.data and waitingReply - allow to see perms calculation trough user perms, then roles by priority, then base group perms, going from left to right (or opposite) - add something to allow a group admin to identify all users with additional bot perms - ?add an automatic leveling system for admins? (maybe?) - add photo preview-mode in MessageMaker.js - allow to warn only usersIds who exhist on telegram, it can be checked if applyng a restriction returns true - add config to allow/disallow adding bot from non-admin users - ?identify reply_parameters and add everytime allow_sending_without_reply? (GHBot.js) - /geturl, by replying to a message (via reply) and writing this command, you receive the link that refers directly to that message. - /inactives [days] sends in private chat the list of users who have not sent a message in the last [days], with the possibility of punish them. - /pin [message] - sends the message through the Bot and pins it. - /editpin [message] - edits the current pinned message (if sent from the Bot). - /delpin - removes the pinned message. - /repin - removes and pins again the current pinned message, with notification! - /pinned - refers to the current pinned message. - /list - sends in private chat the list of users of the group with the number of messages sent by them. - /list roles - sends in private chat the list of all the special roles assigned to users - /graphic - sends a graph showing the trend of the group members. - /trend - sends the group's growth statistics. - /logdel - deletes the selected message and sends it to the Log Channel - /send - permits to send a post through the Bot with parse mode support - -## Known possible bugs: --sometimes db.chats.update in plugins may be not used at all because you can still edit the global object cause to reference, not using it may cause some issue. +if global reference get cleared too early code may try to access and inexistent variable - --cleanHTML() may be not applyed in some text where it should, and nothing assure that it's 100% able to clean everything needed for telegram api - --if you add a new permission on userPerms object, every userPerms object should be updated adding that, otherwise this may cause incorrect result in sumUserPerms - --in some unkown cases you may get stuck in exceptions menu and SafeGram.js will block any user request due too high accumulated volume of something pending - --permissions setup on first bot adding to groups is not the same as using /reload that's more complete +To update LibreGroupHelp you need to backup ./database folder and ./config.json, then repeat installation process and paste there again both file and folder, you may need to add some config.json parameters manually if has been added + +## Contribute + +[Documentation](../documentation/) is the section you are looking for if you want to contribute to LibreGroupHelp ## Ask a question diff --git a/docs/.editorconfig b/docs/.editorconfig new file mode 100644 index 0000000..ebe51d3 --- /dev/null +++ b/docs/.editorconfig @@ -0,0 +1,12 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = false +insert_final_newline = false \ No newline at end of file diff --git a/docs/assets/logo.png b/docs/assets/logo.png new file mode 100644 index 0000000..76ad85c Binary files /dev/null and b/docs/assets/logo.png differ diff --git a/docs/documentation/GHBot.md b/docs/documentation/GHBot.md new file mode 100644 index 0000000..546478a --- /dev/null +++ b/docs/documentation/GHBot.md @@ -0,0 +1,938 @@ +## TelegramBot api + +You can finnd documentation about TelegramBot Objects on [telegram-bot-api](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/api.md) github + +--- + +The down below lines are generated with [jsdoc2md](https://github.com/jsdoc2md/jsdoc-to-markdown) + + +## Classes + +
+
LGHInterface
+
+
+ +## Functions + +
+
testObject()LGHChat
+
+
+ +## Typedefs + +
+
AnonTGUser : Object
+

Basic anonymized user object

+
+
Punishment : 0 | 1 | 2 | 3 | 4
+

Punishment to apply

+
    +
  • 0: off
  • +
  • 1: warn
  • +
  • 2: kick
  • +
  • 3: mute
  • +
  • 4: ban
  • +
+
+
LGHPunish : Object
+

antispam.js settings Object.

+
+
LGHChatBasedPunish : Object
+

Object to reresent different punish settings for more chat types

+
+
LGHAlphabetBasedPunish : Object
+

Object to reresent different punish settings for messages containing various Alphabets

+
+
TargetUser : Object
+

Object that refers to a target user

+
+
LGHPerms : Object
+

LGHPerms Object.

+
+
simpleMedia : Object
+
+
customMessage : Object
+

object of MessageMaker

+
+
LGHAdminAdds : object
+
+
LGHAdmin : TelegramBot.ChatAdministratorRights | LGHAdminAdds
+
+
LGHAdminList : Array.<LGHAdmin>
+
+
userStatus : Object
+

object with data about an user in a group

+
+
LGHRole : Object
+

if pre-made role (string key) only users object should be used

+
+
LGHWarns : Object
+

warns.js plugin related data

+
+
LGHWelcome : Object
+

welcome.js settings Object.

+
+
LGHFloodAdds : Object
+

antiflood.js settings additional Object elements.

+
+
LGHFlood : LGHFloodAdds | LGHPunish
+

antiflood.js settings Object.

+
+
LGHSpamTgLinksAdds : Object
+

antispam.js settings Object additional items.

+
+
LGHSpamTgLinks : LGHSpamTgLinksAdds | LGHPunish
+

antispam.js settings about Telegram Links Object.

+
+
LGHSpamLinksAdds : Object
+

antispam.js spam links Object additional items.

+
+
LGHSpamLinks : LGHSpamLinksAdds | LGHPunish
+

antispam.js settings about Links Object.

+
+
LGHSpamForward : LGHChatBasedPunish
+

antispam.js settings about foward.

+
+
LGHSpamQuote : LGHChatBasedPunish
+

antispam.js settings about quote.

+
+
LGHSpam : Object
+

antispam.js settings Object.

+
+
LGHGoodbye : Object
+

goodbye.js settings

+
+
LGHCaptcha : Object
+

captcha.js settings

+
+
LGHMedia : Object
+

media.js settings, if LGHPunish is disabled the object will be deleted (undefinied)

+
+
CustomChat : Object
+

Additional chat elements for chat object by LibreGroupHelp

+
+
LGHChat : TelegramBot.Chat | CustomChat
+

Full LGH chat object given by LGHBot events, custom items avaiable if working about a group

+
+
CustomUser : Object
+
+
LGHUser : TelegramBot.User | CustomUser
+

Custom chat object given by LGHBot events, custom items avaiable if working about a group

+
+
ParsedCommand : Object
+

ParsedCommand Object.

+
+
CustomCommand : Object
+

Additional items to command for LGH

+
+
CustomMessage : Object
+
+
LGHMessage : TelegramBot.Message | CustomMessage
+

Custom chat object given by LGHBot events, custom items avaiable if working about a group

+
+
CustomCallback : Object
+
+
LGHCallback : TelegramBot.CallbackQuery | CustomCallback
+

Custom callback object given by LGHBot events, custom items may be avaiable

+
+
chatsDatabase : Object
+

Object containing chat-related database functions.

+
+
usersDatabase : Object
+

Object containing user-related database functions.

+
+
LGHDatabase : Object
+

Type returned by the getDatabase function.

+
+
LibreGHelp : Object
+
+
+ + + +## LGHInterface +**Kind**: global class + +* [LGHInterface](#LGHInterface) + * [new LGHInterface(LibreGHelp)](#new_LGHInterface_new) + * [.GHbot](#LGHInterface+GHbot) : [LGHInterface](#LGHInterface) + * [.TGbot](#LGHInterface+TGbot) : [TelegramBot](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/api.md) + * [.db](#LGHInterface+db) : [LGHDatabase](#LGHDatabase) + * [.config](#LGHInterface+config) : Object + * [.onMessage(handler)](#LGHInterface+onMessage) + * [.onCallback(handler)](#LGHInterface+onCallback) + * [.sendMessage(userId, chatId, text, options)](#LGHInterface+sendMessage) ⇒ Boolean \| Promise.<TelegramBot.Message> + * [.sendPhoto(userId, chatId, photo, options, fileOptions)](#LGHInterface+sendPhoto) ⇒ Boolean \| Promise.<TelegramBot.Message> + * [.editMessageMedia(userId, media, options)](#LGHInterface+editMessageMedia) ⇒ Boolean \| Promise.<TelegramBot.Message> + * [.editMessageText(userId, text, options)](#LGHInterface+editMessageText) ⇒ Promise.<Boolean> + * [.answerCallbackQuery(userId, callbackId, options)](#LGHInterface+answerCallbackQuery) ⇒ Promise.<Boolean> + * [.banChatMember(userId, chatId, targetId, options)](#LGHInterface+banChatMember) ⇒ Promise.<Boolean> + * [.unbanChatMember(userId, chatId, targetId, options)](#LGHInterface+unbanChatMember) ⇒ Promise.<Boolean> + * [.restrictChatMember(userId, chatId, targetId, options)](#LGHInterface+restrictChatMember) ⇒ Promise.<Boolean> + + + +### new LGHInterface(LibreGHelp) + +| Param | Type | Description | +| --- | --- | --- | +| LibreGHelp | [LibreGHelp](#LibreGHelp) | Libre Group Help telegram bot handler | + + + +### lghInterface.GHbot : [LGHInterface](#LGHInterface) +**Kind**: instance property of [LGHInterface](#LGHInterface) + + +### lghInterface.TGbot : [TelegramBot](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/api.md) +**Kind**: instance property of [LGHInterface](#LGHInterface) + + +### lghInterface.db : [LGHDatabase](#LGHDatabase) +**Kind**: instance property of [LGHInterface](#LGHInterface) + + +### lghInterface.config : Object +**Kind**: instance property of [LGHInterface](#LGHInterface) + + +### lghInterface.onMessage(handler) +LGHbot message event handler + +**Kind**: instance method of [LGHInterface](#LGHInterface) + +| Param | Type | Description | +| --- | --- | --- | +| handler | function | handler function | + + + +### lghInterface.onCallback(handler) +LGHbot callback event handler + +**Kind**: instance method of [LGHInterface](#LGHInterface) + +| Param | Type | Description | +| --- | --- | --- | +| handler | function | handler function | + + + +### lghInterface.sendMessage(userId, chatId, text, options) ⇒ Boolean \| Promise.<TelegramBot.Message> +LGHbot safely send message under user request limit + +**Kind**: instance method of [LGHInterface](#LGHInterface) +**Returns**: Boolean \| Promise.<TelegramBot.Message> - - returns true on success, false if request has been dropped out + +| Param | Type | Description | +| --- | --- | --- | +| userId | number \| string | id of user that's the cause of your request | +| chatId | number \| string | chat where message should be sent | +| text | String | text of message | +| options | TelegramBot.SendMessageOptions | additional telegram options | + + + +### lghInterface.sendPhoto(userId, chatId, photo, options, fileOptions) ⇒ Boolean \| Promise.<TelegramBot.Message> +LGHbot safely send message under user request limit + +**Kind**: instance method of [LGHInterface](#LGHInterface) +**Returns**: Boolean \| Promise.<TelegramBot.Message> - - returns true on success, false if request has been dropped out + +| Param | Type | Description | +| --- | --- | --- | +| userId | | | +| chatId | number \| string | chat where message should be sent | +| photo | TelegramBot.InputMediaPhoto | photo | +| options | TelegramBot.SendPhotoOptions | additional telegram options | +| fileOptions | TelegramBot.FileOptions | file metadata | + + + +### lghInterface.editMessageMedia(userId, media, options) ⇒ Boolean \| Promise.<TelegramBot.Message> +**Kind**: instance method of [LGHInterface](#LGHInterface) +**Returns**: Boolean \| Promise.<TelegramBot.Message> - - returns true on success, false if request has been dropped out + +| Param | Type | Description | +| --- | --- | --- | +| userId | number \| string | id of user that's the cause of your request | +| media | TelegramBot.InputMedia | input media | +| options | TelegramBot.EditMessageMediaOptions | | + + + +### lghInterface.editMessageText(userId, text, options) ⇒ Promise.<Boolean> +LGHbot safely edit message under user request limit + +**Kind**: instance method of [LGHInterface](#LGHInterface) +**Returns**: Promise.<Boolean> - - returns true on success, false if request has been dropped out + +| Param | Type | Description | +| --- | --- | --- | +| userId | number \| string | id of user that's the cause of your request | +| text | String | text of message | +| options | TelegramBot.EditMessageTextOptions | additional telegram options | + + + +### lghInterface.answerCallbackQuery(userId, callbackId, options) ⇒ Promise.<Boolean> +LGHbot safely answerCallbackQuert under user request limit + +**Kind**: instance method of [LGHInterface](#LGHInterface) +**Returns**: Promise.<Boolean> - - returns true on success, false if request has been dropped out + +| Param | Type | Description | +| --- | --- | --- | +| userId | number \| string | id of user that's the cause of your request | +| callbackId | number \| string | id of user that's the cause of your request | +| options | TelegramBot.AnswerCallbackQueryOptions | additional telegram options | + + + +### lghInterface.banChatMember(userId, chatId, targetId, options) ⇒ Promise.<Boolean> +LGHbot safely answerCallbackQuert under user request limit + +**Kind**: instance method of [LGHInterface](#LGHInterface) +**Returns**: Promise.<Boolean> - - returns true on success, false if request has been dropped out + +| Param | Type | Description | +| --- | --- | --- | +| userId | number \| string | id of user that's the cause of your request | +| chatId | number \| string | - chat where message should be sent | +| targetId | number \| string | id of user that should be banned | +| options | TelegramBot.BanOptions | additional telegram options | + + + +### lghInterface.unbanChatMember(userId, chatId, targetId, options) ⇒ Promise.<Boolean> +LGHbot safely answerCallbackQuert under user request limit + +**Kind**: instance method of [LGHInterface](#LGHInterface) +**Returns**: Promise.<Boolean> - - returns true on success, false if request has been dropped out + +| Param | Type | Description | +| --- | --- | --- | +| userId | number \| string | id of user that's the cause of your request | +| chatId | number \| string | - chat where message should be sent | +| targetId | number \| string | id of user that should be unbanned | +| options | TelegramBot.UnbanOptions | additional telegram options | + + + +### lghInterface.restrictChatMember(userId, chatId, targetId, options) ⇒ Promise.<Boolean> +LGHbot safely answerCallbackQuert under user request limit + +**Kind**: instance method of [LGHInterface](#LGHInterface) +**Returns**: Promise.<Boolean> - - returns true on success, false if request has been dropped out + +| Param | Type | Description | +| --- | --- | --- | +| userId | number \| string | id of user that's the cause of your request | +| chatId | number \| string | - chat where message should be sent | +| targetId | number \| string | id of user to restrict | +| options | TelegramBot.RestrictChatMemberOptions | additional telegram options | + + + +## PermissionStatus : enum +Permission status +- 1: allowed +- 0: neutral +- -1: denied + +**Kind**: global enum +**Properties** + +| Name | Type | Default | +| --- | --- | --- | +| ALLOWED | number | 1 | +| NEUTRAL | number | 0 | +| DENIED | number | -1 | + + + +## testObject() ⇒ [LGHChat](#LGHChat) +**Kind**: global function +**Returns**: [LGHChat](#LGHChat) - testing jsdoc advices + + +## AnonTGUser : Object +Basic anonymized user object + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| id | String \| Number | userId | + + + +## Punishment : 0 \| 1 \| 2 \| 3 \| 4 +Punishment to apply +- 0: off +- 1: warn +- 2: kick +- 3: mute +- 4: ban + +**Kind**: global typedef + + +## LGHPunish : Object +antispam.js settings Object. + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| punishment | [Punishment](#Punishment) | Punishment to apply [0:off/1:warn/2:kick/3:mute/4:ban]. | +| PTime | Number \| null | Available if punishment is set to warn/mute/ban, contains seconds of punishment. | +| delete | boolean \| null | True if deletion is enabled as side effect. | + + + +## LGHChatBasedPunish : Object +Object to reresent different punish settings for more chat types + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| channels | [LGHPunish](#LGHPunish) | Punish to apply for channels. | +| groups | [LGHPunish](#LGHPunish) | Punish to apply for groups. | +| users | [LGHPunish](#LGHPunish) | Punish to apply for users. | +| bots | [LGHPunish](#LGHPunish) | Punish to apply for bots. | + + + +## LGHAlphabetBasedPunish : Object +Object to reresent different punish settings for messages containing various Alphabets + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| arabic | [LGHPunish](#LGHPunish) | Punish to apply for messages containing arabic characters. | +| cyrillic | [LGHPunish](#LGHPunish) | Punish to apply for messages containing cyrillic (russian) characters. | +| chinese | [LGHPunish](#LGHPunish) | Punish to apply for messages containing chinese characters. | +| latin | [LGHPunish](#LGHPunish) | Punish to apply for messages containing latin characters. | + + + +## TargetUser : Object +Object that refers to a target user + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| id | string \| number | Telegram user Id | +| name | string | Full LGH name identifier: "fullName [id]" | +| perms | [LGHPerms](#LGHPerms) | LGHPerms with perms of target | +| user | TelegramBot.User \| null | If avaiable, target basic user object | + + + +## LGHPerms : Object +LGHPerms Object. + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| commands | Array.<string> | Array of commands, if starts with "COMMAND_" means its to be translated, otherwise is the literal command. | +| immune | [PermissionStatus](#PermissionStatus) | Active if this user can't receive any punishment (kick/warn/mute/ban) [1/0/-1]. | +| flood | [PermissionStatus](#PermissionStatus) | Permission to flood messages [1/0/-1]. | +| link | [PermissionStatus](#PermissionStatus) | Permission to send links [1/0/-1]. | +| tgLink | [PermissionStatus](#PermissionStatus) | Permission to send telegram links/usernames [1/0/-1]. | +| forward | [PermissionStatus](#PermissionStatus) | Permission to forward messages from anywhere [1/0/-1]. | +| quote | [PermissionStatus](#PermissionStatus) | Permission to quote from anywhere [1/0/-1]. | +| porn | [PermissionStatus](#PermissionStatus) | Bypass porn/gore checks [1/0/-1]. | +| night | [PermissionStatus](#PermissionStatus) | Bypass any night mode limitation [1/0/-1]. | +| media | [PermissionStatus](#PermissionStatus) | Bypass any media limitation [1/0/-1]. | +| alphabets | [PermissionStatus](#PermissionStatus) | Bypass any alphabets characters limitations [1/0/-1]. | +| words | [PermissionStatus](#PermissionStatus) | Bypass banned words limitations [1/0/-1]. | +| length | [PermissionStatus](#PermissionStatus) | Bypass message length limitations [1/0/-1]. | +| roles | [PermissionStatus](#PermissionStatus) | Permission to change roles of lower level users [1/0/-1]. | +| settings | [PermissionStatus](#PermissionStatus) | Permission to change bot group settings [1/0/-1]. | + + + +## simpleMedia : Object +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| type | String \| null | Type of media (audio, photo, video, video_note, animation, sticker, document) or false | +| fileId | String | media fileId or false | +| options | Object | additional options for TelegramBot | + + + +## customMessage : Object +object of MessageMaker + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| text | String | Text of messsage | +| entities | Array.<TelegramBot.MessageEntity> | Telegram entities of text | +| roles | Array.<String> | array user roles, string for pre-made roles, number for custom roles (user-made) | +| format | Boolean | true if message should be formatted (enabled by default), mean that entities should be passed on sendMessage function | +| media | [simpleMedia](#simpleMedia) | user administrator title | +| buttons | String | can be transformed in inline_keyboard with parseTextToInlineKeyboard() | +| buttonsParsed | Array.<TelegramBot.KeyboardButton> | already parsed buttons ready to use for inline_keyboard | + + + +## LGHAdminAdds : object +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| user | [AnonTGUser](#AnonTGUser) | Basic anonymized user object | +| status | TelegramBot.ChatMemberStatus | | + + + +## LGHAdmin : TelegramBot.ChatAdministratorRights \| [LGHAdminAdds](#LGHAdminAdds) +**Kind**: global typedef + + +## LGHAdminList : [Array.<LGHAdmin>](#LGHAdmin) +**Kind**: global typedef + + +## userStatus : Object +object with data about an user in a group + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| firtJoin | Number | Unix number of first user join time in seconds, false if unknown (managed by welcome.js) | +| perms | [LGHPerms](#LGHPerms) | LGHPerms object for all user-specific permissions | +| adminPerms | [LGHPerms](#LGHPerms) | LGHPerms object for user permissions if admin | +| roles | Array.<String> | array user roles, string for pre-made roles, number for custom roles (user-made) | +| title | String \| undefined | user administrator title | +| waitingReply | String \| null | string with callback data hirarchy if bot is expecting a message from user on group | + + + +## LGHRole : Object +if pre-made role (string key) only users object should be used + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| name | String \| null | role name | +| emoji | String \| null | emoji for the role | +| level | Number \| null | role level, higher level users can use commands that affect lower level users | +| perms | [LGHPerms](#LGHPerms) \| null | LGHPerms object applyed at lowest priority on any user in this role | +| users | Array.<String> | array of userId in this role | + + + +## LGHWarns : Object +warns.js plugin related data + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| timed | Object.<string, Number> | ([userId]: [endTime, endTime, endTime]) contains necerray data to revoke scheduled warns when time is over | +| count | Object.<string, Number> | ([userId]: number) countains count of warns for each user | +| limit | Number | number of warns after wich should be applyed a punishment | +| punishment | 2 \| 3 \| 4 | punishment when limit is hit [2:kick/3:mute/4:ban] | +| PTime | Number \| null | avaiable if punishment is set to warn/mute/ban, contains seconds of punishment | + + + +## LGHWelcome : Object +welcome.js settings Object. + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| state | boolean | True if welcome is enabled (default false). | +| once | boolean | True if should be sent only at first user join (default false). | +| clean | boolean | True if last welcome message on the group should be (default false). | +| joinList | Array.<(string\|number)> | cronology of users that joined the group over time. | +| lastWelcomeId | string \| number \| boolean | MessageId of last welcome message sent, useful if clean is enabled, false if never sent one before. | +| message | [customMessage](#customMessage) | CustomMessage object. | + + + +## LGHFloodAdds : Object +antiflood.js settings additional Object elements. + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| messages | Number | Number of messages needed to trigger the Antiflood. | +| time | Number | Seconds within the specified message should be sent to trigger the Antiflood. | + + + +## LGHFlood : [LGHFloodAdds](#LGHFloodAdds) \| [LGHPunish](#LGHPunish) +antiflood.js settings Object. + +**Kind**: global typedef + + +## LGHSpamTgLinksAdds : Object +antispam.js settings Object additional items. + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| usernames | Boolean | True if usernames should be considered as spam. | +| bots | Boolean | True if bots should be considered as spam. | +| exceptions | Array.<String> | Array of Telegram exceptions, may contain "Name:Id", `Name:|hidden` (for hidden users), or t.me link, or @username, "Name" | + + + +## LGHSpamTgLinks : [LGHSpamTgLinksAdds](#LGHSpamTgLinksAdds) \| [LGHPunish](#LGHPunish) +antispam.js settings about Telegram Links Object. + +**Kind**: global typedef + + +## LGHSpamLinksAdds : Object +antispam.js spam links Object additional items. + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| exceptions | Array.<String> | Array of strings of allowed links or hostnames. | + + + +## LGHSpamLinks : [LGHSpamLinksAdds](#LGHSpamLinksAdds) \| [LGHPunish](#LGHPunish) +antispam.js settings about Links Object. + +**Kind**: global typedef + + +## LGHSpamForward : [LGHChatBasedPunish](#LGHChatBasedPunish) +antispam.js settings about foward. + +**Kind**: global typedef + + +## LGHSpamQuote : [LGHChatBasedPunish](#LGHChatBasedPunish) +antispam.js settings about quote. + +**Kind**: global typedef + + +## LGHSpam : Object +antispam.js settings Object. + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| tgLinks | [LGHSpamTgLinks](#LGHSpamTgLinks) | rules and exceptions for telegram links considered as spam | +| links | [LGHSpamLinks](#LGHSpamLinks) | rules and exceptions for all links considered as spam | +| forward | [LGHSpamForward](#LGHSpamForward) | rules and exceptions for all forwarded messages considered as spam | +| quote | [LGHSpamQuote](#LGHSpamQuote) | rules and exceptions for all quoted messages considered as spam | + + + +## LGHGoodbye : Object +goodbye.js settings + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| group | Boolean | True if goodbye should be sent on group | +| clear | Boolean | True if last goodbye message should be deleted before sending a new one | +| lastId | TelegramBot.MessageId | messageId of last goodbye message sent on group | +| gMsg | [CustomMessage](#CustomMessage) | Goodbye message to send on group | +| private | Boolean | True if goodbye should be sent on private chat | +| pMsg | [CustomMessage](#CustomMessage) | Goodbye message to send on private chat | + + + +## LGHCaptcha : Object +captcha.js settings + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| state | Boolean | True if welcome is enabled (default false). | +| mode | string | Type of captcha, can be "image" (default "image"). | +| time | Number | Time limit to solve the captcha | +| once | boolean | True if should be sent only at first user join (from welcome.js) (default false). | +| fails | boolean | True if captcha should notify on group that someone failed the captcha (default false). | +| punishment | [Punishment](#Punishment) | Punishment to apply [1:warn/2:kick/3:mute/4:ban]. | +| PTime | Number | Available if punishment is set to warn/mute/ban, contains seconds of punishment. | + + + +## LGHMedia : Object +media.js settings, if LGHPunish is disabled the object will be deleted (undefinied) + +**Kind**: global typedef +**Properties** + +| Name | Type | +| --- | --- | +| photo | [LGHPunish](#LGHPunish) \| undefined | +| video | [LGHPunish](#LGHPunish) \| undefined | +| album | [LGHPunish](#LGHPunish) \| undefined | +| gif | [LGHPunish](#LGHPunish) \| undefined | +| voice | [LGHPunish](#LGHPunish) \| undefined | +| audio | [LGHPunish](#LGHPunish) \| undefined | +| sticker | [LGHPunish](#LGHPunish) \| undefined | +| sticker_video | [LGHPunish](#LGHPunish) \| undefined | +| dice | [LGHPunish](#LGHPunish) \| undefined | +| emoji_video | [LGHPunish](#LGHPunish) \| undefined | +| emoji_premium | [LGHPunish](#LGHPunish) \| undefined | +| video_note | [LGHPunish](#LGHPunish) \| undefined | +| file | [LGHPunish](#LGHPunish) \| undefined | +| game | [LGHPunish](#LGHPunish) \| undefined | +| contact | [LGHPunish](#LGHPunish) \| undefined | +| poll | [LGHPunish](#LGHPunish) \| undefined | +| location | [LGHPunish](#LGHPunish) \| undefined | +| capital | [LGHPunish](#LGHPunish) \| undefined | +| payment | [LGHPunish](#LGHPunish) \| undefined | +| via_bot | [LGHPunish](#LGHPunish) \| undefined | +| story | [LGHPunish](#LGHPunish) \| undefined | +| spoiler | [LGHPunish](#LGHPunish) \| undefined | +| spoiler_media | [LGHPunish](#LGHPunish) \| undefined | +| giveaway | [LGHPunish](#LGHPunish) \| undefined | +| mention | [LGHPunish](#LGHPunish) \| undefined | +| text_mention | [LGHPunish](#LGHPunish) \| undefined | +| hashtag | [LGHPunish](#LGHPunish) \| undefined | +| cashtag | [LGHPunish](#LGHPunish) \| undefined | +| command | [LGHPunish](#LGHPunish) \| undefined | +| url | [LGHPunish](#LGHPunish) \| undefined | +| email | [LGHPunish](#LGHPunish) \| undefined | +| number | [LGHPunish](#LGHPunish) \| undefined | +| bold | [LGHPunish](#LGHPunish) \| undefined | +| italic | [LGHPunish](#LGHPunish) \| undefined | +| underline | [LGHPunish](#LGHPunish) \| undefined | +| striketrough | [LGHPunish](#LGHPunish) \| undefined | +| quoteblock | [LGHPunish](#LGHPunish) \| undefined | +| closed_blockquote | [LGHPunish](#LGHPunish) \| undefined | +| code | [LGHPunish](#LGHPunish) \| undefined | +| pre_code | [LGHPunish](#LGHPunish) \| undefined | +| textlink | [LGHPunish](#LGHPunish) \| undefined | +| scheduled | [LGHPunish](#LGHPunish) \| undefined | +| effect | [LGHPunish](#LGHPunish) \| undefined | + + + +## CustomChat : Object +Additional chat elements for chat object by LibreGroupHelp + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| admins | [LGHAdminList](#LGHAdminList) \| null | array with known admins objects (user data anonymized) | +| lang | String \| null | current chat lang | +| currency | String \| null | currency of chat, default to USD | +| link | string \| null | group access link | +| isGroup | Boolean | temporary item, result of `(chat.type == "supergroup" || chat.type == "group")` | +| users | Object.<string, userStatus> \| null | Object-IdName based data about every user in the group (ex. users[643547] access data of userId 643547) | +| roles | Object.<string, LGHRole> \| null | data about a specific role, full role Object if it's a custom role (key with a number) | +| basePerms | [LGHPerms](#LGHPerms) | base permissions applyed to every user | +| adminPerms | [LGHPerms](#LGHPerms) | base permissions applyed to admin | +| warns | [LGHWarns](#LGHWarns) \| null | warns.js plugin related data | +| rules | [customMessage](#customMessage) \| null | rules.js plugin related data | +| welcome | [LGHWelcome](#LGHWelcome) \| null | welcome.js plugin related data | +| flood | [LGHFlood](#LGHFlood) \| null | antiflood.js plugin related data | +| spam | [LGHSpam](#LGHSpam) \| null | antispam.js plugin related data | +| captcha | [LGHCaptcha](#LGHCaptcha) \| null | captcha.js plugin related data | +| goodbye | [LGHGoodbye](#LGHGoodbye) \| null | goodbye.js plugin related data | +| alphabets | [LGHAlphabetBasedPunish](#LGHAlphabetBasedPunish) \| null | alphabets.js plugin related data | +| media | [LGHMedia](#LGHMedia) \| null | media.js plugin related data | + + + +## LGHChat : TelegramBot.Chat \| [CustomChat](#CustomChat) +Full LGH chat object given by LGHBot events, custom items avaiable if working about a group + +**Kind**: global typedef + + +## CustomUser : Object +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| perms | [LGHPerms](#LGHPerms) \| null | temporary object with summary of user permissions | +| lang | String | current user lang | +| waitingReply | String | set to true if the bot is expecting a message from the user | + + + +## LGHUser : TelegramBot.User \| [CustomUser](#CustomUser) +Custom chat object given by LGHBot events, custom items avaiable if working about a group + +**Kind**: global typedef + + +## ParsedCommand : Object +ParsedCommand Object. + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| text | string | The original text input. | +| prefix | string | The prefix used in the command (e.g., "/", "!", "."). | +| botCommand | string | The command with bot name (e.g., "start@usernamebot"). | +| name | string | The name of the command. | +| bot | string | The bot name (if available). | +| args | string \| boolean | The arguments of the command (optional). | +| splitArgs | Array.<string> \| boolean | The split arguments of the command (optional). | + + + +## CustomCommand : Object +Additional items to command for LGH + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| target | [TargetUser](#TargetUser) \| null | Optional temporary object with data about a target LGH user in the command, false if no target found | + + + +## CustomMessage : Object +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| chat | [LGHChat](#LGHChat) | Always original chat object where the message is coming from | +| command | [ParsedCommand](#ParsedCommand) \| [CustomCommand](#CustomCommand) | result of message text parsed with parseCommand() | +| target | [TargetUser](#TargetUser) \| null | Optional temporary object with data about a command target | +| waitingReply | string \| null | Optional temporary object with waitingReply data for the selected chat | +| waitingReplyTarget | [TargetUser](#TargetUser) \| null | Optional temporary object with data about a target LGH user, false if no target found | + + + +## LGHMessage : TelegramBot.Message \| [CustomMessage](#CustomMessage) +Custom chat object given by LGHBot events, custom items avaiable if working about a group + +**Kind**: global typedef + + +## CustomCallback : Object +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| chat | [LGHChat](#LGHChat) | Always original chat object where the callback is coming from | +| target | [TargetUser](#TargetUser) | Optional temporary object with data about a target LGH user in the command, false if no target found | + + + +## LGHCallback : TelegramBot.CallbackQuery \| [CustomCallback](#CustomCallback) +Custom callback object given by LGHBot events, custom items may be avaiable + +**Kind**: global typedef + + +## chatsDatabase : Object +Object containing chat-related database functions. + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| add | function | Function to add a new chat to the database. ------------------------------------ `function(TelegramBot.Chat): boolean` | +| delete | function | Function to delete a chat from the database. ------------------------------------ `function(TelegramBot.ChatId): boolean` | +| exhist | function | Function to check if a chat exhists in the database. ------------------------------------ `function(TelegramBot.ChatId): boolean` | +| get | function | Function to retrieve a chat from the database. ------------------------------------ `function(LGHChat): boolean` | +| update | function | Function to update a chat in the database. ------------------------------------ `function(LGHChat): boolean` | +| save | function | Function to save a chat to the database. ------------------------------------ `function(TelegramBot.ChatId): boolean` | + + + +## usersDatabase : Object +Object containing user-related database functions. + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| add | function | Function to add a new user to the database. ------------------------------------ `function(TelegramBot.User): boolean` | +| delete | function | Function to delete a user from the database. ------------------------------------ `function(TelegramBot.ChatId): boolean` | +| exhist | function | Function to check if a user exhists in the database. ------------------------------------ `function(TelegramBot.ChatId): boolean` | +| get | function | Function to retrieve a user from the database. ------------------------------------ `function(TelegramBot.ChatId): LGHUser` | +| update | function | Function to update a user in the database. ------------------------------------ `function(LGHUser): boolean` | + + + +## LGHDatabase : Object +Type returned by the getDatabase function. + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| innerDir | string | Location where the database folder should be placed (and/or generated). | +| dir | string | Full path to the database folder. | +| chatsDir | string | Full path to the chats folder within the database. | +| usersDir | string | Full path to the users folder within the database. | +| chats | [chatsDatabase](#chatsDatabase) | Object containing chat-related database functions. | +| users | [usersDatabase](#usersDatabase) | Object containing user-related database functions. | +| unload | function | Function to unload chats from memory. | + + + +## LibreGHelp : Object +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| GHbot | [LGHInterface](#LGHInterface) | Public interface for LGH Functions | +| TGbot | [TelegramBot](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/api.md) | Raw telegram bot api | +| db | [LGHDatabase](#LGHDatabase) | Database interface | + diff --git a/docs/documentation/TODO-List.md b/docs/documentation/TODO-List.md new file mode 100644 index 0000000..0403fec --- /dev/null +++ b/docs/documentation/TODO-List.md @@ -0,0 +1,55 @@ +If you want an idea of what currently miss on the bot and you may want to implement it, that's the right page + +-short term: + + allow to edit single user perms + commands help panel + +-medium term: + + allow on /perms to change user perms and roles, +add it in a button for /info or when a role is set (/free /mod etc..), +ask double confirm to give an user the "settings" and "roles" permission + support for anonymous admins + allow to customize /staff allowing to set roles to hide + create a privacy setting where users can ask to esclude themself from tagResolver and replace his's first name in database with "Anonymous" + allow to disable tagResolver log on group settings + allow to mute only media, or specific media type or extras + create a privacy option to allow a user deleting his data from the bot + custom roles + optimize database.get, .update and .save to store in temporal array most used users + implement time zone setting +implement it in /info + +-long term: + + add log channel + chatIds anonymization on database + compress chats data stored on database + support all group help functions and more (+anti-sheduled messages[msg.is_from_offline], ) + allow bot clone bot when user give a token + add optionally an userbot (when active implement in tagResolver.js) + +-other things: + + user should have an option to delete also his warn or roles data from the entire database but accepting that he is going to be banned by any group where he got at least a warn and accepting that he is going to lose any acquired role on every group + implement direct private settings with /*settings + add a /commands command to help user to know bot commands, admin commands, and custom-group commands if avaiable + a check system to drop wrong formatted cb.data and waitingReply + allow to see perms calculation trough user perms, then roles by priority, then base group perms, going from left to right (or opposite) + add something to allow a group admin to identify all users with additional bot perms + ?add an automatic leveling system for admins? (maybe?) + add photo preview-mode in MessageMaker.js + allow to warn only usersIds who exhist on telegram, it can be checked if applyng a restriction returns true + add config to allow/disallow adding bot from non-admin users + ?identify reply_parameters and add everytime allow_sending_without_reply? (GHBot.js) + /geturl, by replying to a message (via reply) and writing this command, you receive the link that refers directly to that message. + /inactives [days] sends in private chat the list of users who have not sent a message in the last [days], with the possibility of punish them. + /pin [message] - sends the message through the Bot and pins it. + /editpin [message] - edits the current pinned message (if sent from the Bot). + /delpin - removes the pinned message. + /repin - removes and pins again the current pinned message, with notification! + /pinned - refers to the current pinned message. + /list - sends in private chat the list of users of the group with the number of messages sent by them. + /list roles - sends in private chat the list of all the special roles assigned to users + /graphic - sends a graph showing the trend of the group members. + /trend - sends the group's growth statistics. + /logdel - deletes the selected message and sends it to the Log Channel + /send - permits to send a post through the Bot with parse mode support \ No newline at end of file diff --git a/docs/documentation/callbacks.md b/docs/documentation/callbacks.md new file mode 100644 index 0000000..547b2e5 --- /dev/null +++ b/docs/documentation/callbacks.md @@ -0,0 +1,123 @@ +## LGH Hirarchy + +We need to expect button clicks and messages from users to be able to perform most of actions for our bot + + +That's why we need an unified hirarchy of how callbacks data are organized, on LibreGroupHelp they are avaiable for buttons on `cb.data` and `msg.waitingReply` for messages, we will talk about how to expect user messages soon, but first you should follow the right hirachy so main.js can set right variables for [LGH Events](events.md) + +
+ +That's the hirarchy: + +`CallbackName_opt1_opt2!data#editorName_opt1_opt2|editorData:groupId?targetUserId` + +
+ +It works too with less items like this: `CallbackName:groupId`, `CallbackName#editor?targetUserId`, `CallbackName:groupId?targetUserId`. + +
+ +**CallbackName** +Name of callback that you can use, be sure that not conflicts with other names, often plugins check if it's their match with `string.startsWith()`, `opt1` and `opt2` separated by `_` is avaiable to futher go deep with your callback listener + +--- + +**data** +Some additional data that you can attach to CallbackName (requires `CallbackName`) + +--- + +**editorName** +Also that is often identified with string.startsWith(), it's usually used by re-usable menus like MessageMaker.js, setNum.js, setTime.js + +[What are editors?](editors.md) + +--- + +**editorData** +Additional data that editor may attach (requires `editorName`) + +--- + +**groupId** +This value when given allow main.js to set by any chat context a specific full chat object on it's events inside [GHBot](GHBot.md/#LGHInterface) (`msg.chat` or `cb.message.chat` are not affected) and `user.perms` related to user permissions on the given groupId + +[Read how groupId helps LGH Events](events.md/#expect-messages) + +--- + +**targetUserId** +This value when given allow main.js to set a specific target user in various cases: `cb.target`, `msg.waitingReplyTarget` (note: it's volontarily separated from `msg.target` that's command target dedicated) + +[Read how targetUserId helps LGH Events](events.md/#target-user) + +--- + + +## Expect user messages + +In this example i will show you how to expect futher message from user and, listen it back when he replicate, and then disable futher message expectations + +For messages callbacks comes at help 2 functions: + + waitReplyForChat(database, callback, user, chat, onGroup) + unsetWaitReply(database, user, chat, onGroup) + +
+ +Keep in mind that Callback Hirarchy upon explained has to be followed + +```javascript +const LGHelpTemplate = require("../GHbot.js") +const {waitReplyForChat, unsetWaitReply} = require( "../api/utils/utils.js" ); + +function main(args) +{ + + const GHbot = new LGHelpTemplate(args); + const {TGbot, db, config} = GHbot; + + GHbot.onMessage( (msg, chat, user) => { + + if(msg.text != "/guess") return; + + //if users type /guess expect a message with "EXPECT_PASSWORD" callback + + /** + * waitReplyForChat, if chat.isGroup == false, will set + * automatically the callback as EXAMPLE:groupId + */ + waitReplyForChat(db, "EXPECT_PASSWORD", user, chat, chat.isGroup) + + GHbot.sendMessage(user.id, chat.id, "Guess the password") + + }) + + GHbot.onMessage( (msg, chat, user) => { + + var isMyCallback = msg.waitingReply && msg.waitingReply.startsWith("EXPECT_PASSWORD") + if(!isMyCallback) return; + + if(msg.text == "password1234"){ + GHbot.sendMessage(user.id, chat.id, "Congratulation, password guessed!") + unsetWaitReply(db, user, chat, chat.isGroup) //do not expect futher messages + } + else{ + GHbot.sendMessage(user.id, chat.id, "Password incorrect, try again ): ") + } + + }) + +} + +module.exports = main; +``` + +When you are expecting a message other plugins will see (with `msg.waitingReply` != false) your decision and they may stop working until you finished, so be sure to use unsetWaitReply eventually + + +## Expect user button clicks + +Currently LGH has no special procedure to expect button clicks, just follow the hirarchy and do how you would do with [TGbot](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/api.md) + +You find an example here: [LGH Events: Expect buttons clicks](events.md/#expect-buttons-clicks) diff --git a/docs/documentation/commands.md b/docs/documentation/commands.md new file mode 100644 index 0000000..71d3958 --- /dev/null +++ b/docs/documentation/commands.md @@ -0,0 +1,184 @@ +# Create a command + +LibreGroupHelp offers multi-language command support, when the user sends a command LGH will try to resolve the command trying first to translate the raw one to the command code (usually starting with `COMMAND_`), then, if registered, their function will be ran + + +## Create command lang-code + +Before registering your first command you need to know how to add it to the bot dictionary + +Open `langs/en_en.json` and scroll down below until you find the values keys starting with `"COMMAND_"` + +```json +"/rules": "COMMAND_RULES", +"/regulation" : "COMMAND_RULES", +"COMMAND_RULES" : "rules", +"CMDDESC_RULES" : "/{name} or /regulation\nSend group regulament message, it can be changed in settings", +"/permissions": "COMMAND_PERMS", +"/perms": "COMMAND_PERMS", +"COMMAND_PERMS" : "perms", +``` + +As you see, `"COMMAND_RULES" : rules` define the main command as the `/rules` one +But it owns also some alias, still linked to `COMMAND_RULES` + +```json +"/rules": "COMMAND_RULES", +"/regulation" : "COMMAND_RULES", +``` + +Both `/rules` and `/regulation` will fire up the same function + +We see also a `"CMDDESC_RULES"` parameter with a `{name}` substitution key, set this value can help back in some cases where bot has to show a short description of what the command does, it's not mandatory to add this but is reccomended + +
+ +Now add our own command + +```json +"/example" : "COMMAND_EXAMPLE", +"/showcase" : "COMMAND_EXAMPLE", +"/anotheralias" : "COMMAND_EXAMPLE", +"COMMAND_EXAMPLE" : "example", +"CMDDESC_EXAMPLE" : "/{name} or /showcase or /anotheralias\nThese are just commands to show an example on LibreGroupHelp Wiki" +"/rules": "COMMAND_RULES", +"/regulation" : "COMMAND_RULES", +"COMMAND_RULES" : "rules", +"CMDDESC_RULES" : "/{name} or /regulation\nSend group regulament message, it can be changed in settings", +"/permissions": "COMMAND_PERMS", +"/perms": "COMMAND_PERMS", +"COMMAND_PERMS" : "perms", +``` + +We added as main command of `COMMAND_EXAMPLE` the command `/example`, anyway also `/showcase` and `/anotheralias` are avaiable as aliases + +*Note: `"/example" : "COMMAND_EXAMPLE"` and `"COMMAND_EXAMPLE" : "example"` are always both needed, even if example is already described as the main command, it has to be anyway in the aliases list* + +--- + +## Register command + +The command registering tool can be required with +`const GHCommand = require("../api/tg/LGHCommand.js")` + +To reply a command the right procedure is using the sendCommandReply utility (from `api/utils/utils.js` ) + +Giving back to `sendCommandReply` the `GHCommand.registerCommand` parameters will allow it to decide what is the correct destination chat to reply, running then a callback that gives you a `chadId` where to reply + +That's because the user may have the permission to use this command only with a private bot reply, but there are also many other caveuts, this system will handle everything for you, so you can focus on the acutal command creation + +Here an example: + +```javascript +const { sendCommandReply } = require("../api/utils/utils.js"); +const GHCommand = require("../api/tg/LGHCommand.js"); +const LGHelpTemplate = require("../GHbot.js"); + +function main(args) +{ + + const GHbot = new LGHelpTemplate(args); + const {TGbot, db, config} = GHbot; + + GHCommand.registerCommands(["COMMAND_EXAMPLE"], (msg, chat, user, private, lang, key, keyLang) => { + + //we want this command to work only if from groups + if(!msg.chat.isGroup) return; + + sendCommandReply(private, lang, GHbot, user.id, chat.id, (sendId)=>{ + var text = "Thanks for the interest into LGH, we appreciate this"; + GHbot.sendMessage(user.id, sendId, text); + }) + + }) + +} + +module.exports = main; +``` + +If are you sure that your command reply has always to be on the group you can still set `false` instead of `private` on `sendCommandReply` + +In the same way if your command reply should be always on private chat, you set `true` instead of `private` + +*Note: `msg`, `chat` and `user` are exactly the same parameters you get within [LGH Events](events.md/#expect-messages), they come acutally from there* + + +## Some insights + +Any [msg](GHBot.md/#lghmessage-telegrambotmessage-custommessage) object contains [msg.command](GHBot.md/#parsedcommand-object), can be useful to handle more parameters on your command + +--- + +Why first parameter of `GHCommand.registerCommands` is an array? +Yes it's exactly what you think, you can run the same function for more commands, but why? + +I will show you this directly using `promote.js` plugin as example + + +```javascript +var commandsList = ["COMMAND_FREE", "COMMAND_UNFREE", "COMMAND_HELPER", "COMMAND_UNHELPER", "COMMAND_CLEANER", "COMMAND_UNCLEANER", + "COMMAND_MUTER", "COMMAND_UNMUTER", "COMMAND_MODERATOR", "COMMAND_UNMODERATOR", "COMMAND_COFOUNDER", "COMMAND_UNCOFOUNDER", + "COMMAND_ADMINISTRATOR", "COMMAND_UNADMINISTRATOR", "COMMAND_TITLE", "COMMAND_UNTITLE"]; + +GHCommand.registerCommands(commandsList, async (msg, chat, user, private, lang, key, keyLang) => { + if(!msg.chat.isGroup) return; + + /** + * note how we return in case of msg.waitingReply, that's because + * otherwise we would handle this command also while the user is + * dealing with some other piece of the bot + * */ + if(msg.waitingReply) return; + + var command = msg.command; + var lang = msg.chat.lang; + var target = msg.waitingReplyTarget || msg.target; + var text = false; + var options = {parse_mode : "HTML"}; + var toSetRole = false; + var toUnsetRole = false; + + if( key == "COMMAND_FREE") + toSetRole = "free"; + if( key == "COMMAND_UNFREE") + toUnsetRole = "free"; + + if( key == "COMMAND_HELPER") + toSetRole = "helper"; + if( key == "COMMAND_UNHELPER") + toUnsetRole = "helper"; + + if( key == "COMMAND_CLEANER") + toSetRole = "cleaner" + if( key == "COMMAND_UNCLEANER") + toUnsetRole = "cleaner"; + + if( key == "COMMAND_MUTER") + toSetRole = "muter"; + if( key == "COMMAND_UNMUTER") + toUnsetRole = "muter"; + + if( key == "COMMAND_MODERATOR") + toSetRole = "moderator"; + if( key == "COMMAND_UNMODERATOR") + toUnsetRole = "moderator"; + + if( key == "COMMAND_COFOUNDER") + toSetRole = "cofounder" + if( key == "COMMAND_UNCOFOUNDER") + toUnsetRole = "cofounder"; + + if( key == "COMMAND_ADMINISTRATOR"){...} + if( key == "COMMAND_UNADMINISTRATOR"){...} + if( key == "COMMAND_TITLE"){...} + if( key == "COMMAND_UNTITLE"){...} + + //check if user can change a role and if he can apply it to target + if(toSetRole || toUnsetRole){...} + if(toSetRole){...} + if(toUnsetRole){...} +}) +``` + +As you see, in this case we need to listen for multiple commands at the same time as they need to run pretty the same code, we need only `key` to change `toSetRole` and `toUnsetRole` variable, then the code is same for everyone diff --git a/docs/documentation/database.md b/docs/documentation/database.md new file mode 100644 index 0000000..1b8f75a --- /dev/null +++ b/docs/documentation/database.md @@ -0,0 +1,74 @@ +# Database + +As you may have seen by many examples, an object that we always get is [db](GHBot.md/#LGHDatabase) (database) + +```javascript +const LGHelpTemplate = require("../GHbot.js") + +function main(args) +{ + + const GHbot = new LGHelpTemplate(args); + const {TGbot, db, config} = GHbot; + ... +} + +module.exports = main; +``` + +[Database](GHBot.md/#LGHDatabase) is the core of LibreGroupHelp to store chat and users data, as to the privacy implications of that we aim to minimize the amount of sensitive data there and anyway we keep in mind that the user should be able to remove any trace of him there + +## Database usage + +Currently [database](GHBot.md/#LGHDatabase) let you control [chats](GHBot.md/#chatsDatabase) and [users](GHBot.md/#usersDatabase) using same interface of functions + +You are supposed to use `update` method everytime you want to apply changes to one of them + +```javascript +const LGHelpTemplate = require("../GHbot.js") + +function main(args) +{ + + const GHbot = new LGHelpTemplate(args); + const {TGbot, db, config} = GHbot; + + GHbot.onMessage( (msg, chat, user) => { + + if(!chat.isGroup) return; + + if( msg.text == "/antiflood kind" ) + { + chat.flood.messages = 8; + chat.flood.time = 10; + db.chats.update(chat); //apply changes to database + GHbot.sendMessage( user.id, chat.id, "Antiflood set to be kind" ); + } + else if( msg.text == "/antiflood hard" ) + { + chat.flood.messages = 3; + chat.flood.time = 5; + db.chats.update(chat); //apply changes to database + GHbot.sendMessage( user.id, chat.id, "Antiflood set to be hard" ); + } + + if( msg.text == "/anonymize" ) + { + user.first_name = "anonymous" + user.last_name = "anonymous" + db.users.update(users); //apply changes to database + GHbot.sendMessage( user.id, chat.id, "Anonymized successfully" ); + } + + } ) + +} + +module.exports = main; +``` +You find all relative methods documented clicking [db.chats](GHBot.md/#chatsDatabase) and [db.users](GHBot.md/#usersDatabase) + +--- + + +*Note: as written on [Known issues](known-issues.md) there are a problem with [chats](GHBot.md/#chatsDatabase) interface of database wich gives a reference copy of a LGHChat object, that's mean that it may be eventually stored on database even without `update` functions, fixing this would require some code refacory, you should still follow the rule of using `update` to confirm changes, if you need to apply only temporary changes of an LGHChat object please make a deep copy* \ No newline at end of file diff --git a/docs/documentation/editors.md b/docs/documentation/editors.md new file mode 100644 index 0000000..bc9e54d --- /dev/null +++ b/docs/documentation/editors.md @@ -0,0 +1,99 @@ +# What are editors? + +Editors are a way create re-usable interfaces of panels, with their expect messages and expect buttons callbacks handling to allow you to show something to an user or edit a variable, object, or something else + +As you already know by [LGH Hirarchy](callbacks.md/#lgh-hirarchy), editors has their own space there, the reason why we need to make them separate is simple: +You still need to know who is the caller of the editor it's so can correctly handle like a possible variable change + +Let's begin from the most useful of the editors, `MessageMaker`, that allow the user to modify a [customMessage](GHBot.md/#custommessage-object) object and then also to send it as a telegram message + +That's how `rules.js` uses that (some code not interested has been suppressed): + +```javascript +const LGHelpTemplate = require("../GHbot.js"); +const {sendCommandReply, waitReplyForChat, unsetWaitReply} = require( "../api/utils/utils.js" ); +const MSGMK = require( "../api/editors/MessageMaker.js" ) +... + +function main(args) +{ + + const GHbot = new LGHelpTemplate(args); + const {TGbot, db, config} = GHbot; + ... + + GHbot.onMessage( async (msg, chat, user) => { + + //check if it's our callback + if(!chat.isGroup) return; + if( !(msg.waitingReply && msg.waitingReply.startsWith("S_RULES")) ) return; + ... + + /** + * rules never expect for other messages + * so we can give it all directly to MessageMaker hands + */ + var customMessage = await MSGMK.messageEvent(GHbot, db, chat.rules, msg, chat, user, "S_RULES"); + + //then if customMessage has an update, we save that + if(customMessage) + { + chat.rules = customMessage; + db.chats.update(chat); + } + + } ) + + + GHbot.onCallback( (cb, chat, user) => { + + var msg = cb.message; + var lang = user.lang; + + //check if it's our callback + if(!chat.isGroup) return; + if( !cb.data.startsWith("S_RULES")) return; + ... + + //from rules panel we add a button to access MessageMaker + if( cb.data.startsWith("S_RULES_BUTTON:") ) + { + + GHbot.editMessageText( user.id, l[lang].RULES_SETTING, { + ... + reply_markup : {inline_keyboard :[ + [{ + text: l[lang].RULES_CHANGE_BUTTON, + //we give a button to access MessageMaker + callback_data: "S_RULES#MSGMK:"+chat.id + }], + ... + ]}}) + GHbot.answerCallbackQuery(user.id, cb.id); + } + + //we listen here back for requested MessageMaker accesses + if( cb.data.startsWith("S_RULES#MSGMK") ) + { + var returnButtons = [[{text: l[lang].BACK_BUTTON, callback_data: "S_RULES_BUTTON:"+chat.id}]]; + var title = l[lang].REGULATION; + var msgTitle = l[lang].RULES_TITLE; + //giving the buttons handling to MessageMaker hands + var customMessage = MSGMK.callbackEvent(GHbot, db, chat.rules, cb, chat, user, "S_RULES", returnButtons, title, msgTitle) + + //then if customMessage has an update, we save that + if(customMessage) + { + chat.rules = customMessage; + db.chats.update(chat); + } + } + ... + }) +} + +module.exports = main; + +``` + +The access point of MessageMaker is trough buttons callbacks, but it works then with the user also by expecting messages, so we need to forward also them diff --git a/docs/documentation/events.md b/docs/documentation/events.md new file mode 100644 index 0000000..1e09aa3 --- /dev/null +++ b/docs/documentation/events.md @@ -0,0 +1,307 @@ +# Events + +ONLY for events from GHBot you have additional elements on parameters bot-related + +Usually GHBot events has 3 parameters: +([callback](./GHBot.md/#lghcallback-telegrambotcallbackquery-customcallback) +or +[message](GHBot.md/#lghmessage-telegrambotmessage-custommessage)), +[chat](GHBot.md/#LGHChat), +[user](GHBot.md/#LGHUser) + +GHBot currently has 2 events fully supported + +```javascript +GHBot.onCallback( (cb, chat, user) => { console.log(cb) } ) +GHBot.onMessage( (msg, chat, user) => { console.log(msg) } ) +``` + +--- + +##Chat data + +So how [GHBot](GHBot.md/#LGHInterface) enchanches events for LibreGroupHelp more than using the raw [TGBot](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/api.md)? + +First at all, it allow us to get already a full chat object from the database, thus giving you the full chat configuration + +```javascript +const { punishmentToFullText } = require("../api/utils/utils.js"); +const LGHelpTemplate = require("../GHbot.js") + +function main(args) +{ + + const GHbot = new LGHelpTemplate(args); + const {TGbot, db, config} = GHbot; + + GHbot.onMessage( (msg, chat, user) => { + + var runTest = msg.chat.isGroup && msg.text == "/test" + if( !runTest ) return; + + console.log("Logging chat flood settings") + console.log("Message limit: " + msg.chat.flood.messages) + console.log("Fire if sent within " + msg.chat.flood.time + " seconds") + var punish = punishmentToFullText(user.lang, msg.chat.flood.punishment, msg.chat.flood.PTime, msg.chat.flood.delete) + console.log("User will be punished with " + punish) + + } ) + +} + +module.exports = main; +``` + +Output if any user type `/test` on a group: + + Logging chat flood settings + Message limit: 3 + Fire if sent within 5 seconds + User will be punished with Warn for 1 day + delete + +*You may wonder why we use msg.chat instead of chat? You get that in detail on [Expect messages](events.md/#expect-messages) section, shotly it's because we want to work on the chat where the message is coming from, not the select chat* + +--- + +## User permissions + +We may also want to allow the user to change settings, but we need to know if he has the permission to do that, so we have [user.perms](GHBot.md/#LGHPerms) containing a permissions object about the user on that chat + +*Note: [user.perms](GHBot.md/#LGHPerms) is a temporary item* + +```javascript +const LGHelpTemplate = require("../GHbot.js") + +function main(args) +{ + + const GHbot = new LGHelpTemplate(args); + const {TGbot, db, config} = GHbot; + + GHbot.onMessage( (msg, chat, user) => { + + if(!chat.isGroup) return; + + //we never listen to commands like this on LGH, it's just as example + if( !msg.text.startsWith("/antiflood") ) return + + //Check for user permissions to change settings + if(user.perms.settings != 1) + { + GHbot.sendMessage(user.id, chat.id, "You haven't settings permission"); + return; + } + + if( msg.text == "/antiflood kind" ) + { + chat.flood.messages = 8; + chat.flood.time = 10; + db.chats.update(chat); //apply changes to database + GHbot.sendMessage( user.id, chat.id, "Antiflood set to be kind" ); + } + else if( msg.text == "/antiflood hard" ) + { + chat.flood.messages = 3; + chat.flood.time = 5; + db.chats.update(chat); //apply changes to database + GHbot.sendMessage( user.id, chat.id, "Antiflood set to be hard" ); + } + + } ) + +} + +module.exports = main; +``` + +--- + +## Expect messages + +[GHBot](GHBot.md/#LGHInterface) makes also you easy to expect messages or callbacks from users in private chat and both still relating to the group, keeping the group [chat](GHBot.md/#LGHChat) object + +Let's see: + +```javascript +const { unsetWaitReply, waitReplyForChat } = require("../api/utils/utils.js"); +const LGHelpTemplate = require("../GHbot.js") + +function main(args) +{ + + const GHbot = new LGHelpTemplate(args); + const {TGbot, db, config} = GHbot; + + GHbot.onMessage( async (msg, chat, user) => { + + if(!msg.chat.isGroup) return; + + if(msg.text == "/antiflood") + { + /** + * waitReplyForChat, if chat.isGroup == false, will set + * automatically the callback as EXAMPLE:groupId + */ + waitReplyForChat(db, "EXAMPLE", user, chat, chat.isGroup); + var text = `Ok, antiflood should be kind or hard?\n`+ + `You can reply both here or private chat\n`+ + `@${TGbot.me.username}`; + GHbot.sendMessage(user.id, chat.id, text); + } + + } ) + + GHbot.onMessage( (msg, chat, user) => { + + + /** + * Here, if msg.waitingReply has a groupId (ex. EXAMPLE:-109848493476) + * so it's following correctly the LGH Callbacks Hirarchy, + * the "chat" parameter would be bind to the group + * enriched by the database, we have a full LGH chat object + */ + + //So behaivor is different from "if(!msg.chat.isGroup) return" + if(!chat.isGroup) return; //think that as "!selectedChat.isGroup" + if( !msg.waitingReply.startsWith("EXAMPLE") ) return; + + //even on private chat, user.perms still exhist if a group is binded + if(user.perms.settings != 1) + { + GHbot.sendMessage(user.id, chat.id, "You haven't settings permission"); + return; + } + + if( msg.text == "kind" ) + { + chat.flood.messages = 8; + chat.flood.time = 10; + db.chats.update(chat); //apply changes to database + GHbot.sendMessage( user.id, chat.id, "Antiflood set to be kind" ); + unsetWaitReply(db, user, chat, chat.isGroup); + } + else if( msg.text == "hard" ) + { + chat.flood.messages = 3; + chat.flood.time = 5; + db.chats.update(chat); //apply changes to database + GHbot.sendMessage( user.id, chat.id, "Antiflood set to be hard" ); + unsetWaitReply(db, user, chat, chat.isGroup); + } + + //msg.chat keeps for sure the chat wich message is coming from + var text = `This message is from private chat? ${!msg.chat.isGroup}`; + GHbot.sendMessage( user.id, chat.id, text); + + } ) + +} + +module.exports = main; +``` + +--- + + + +## Expect buttons clicks + +Buttons callbacks works pretty in the same way: + +```javascript +const { punishmentToFullText } = require("../api/utils/utils.js"); +const LGHelpTemplate = require("../GHbot.js"); + +function main(args) +{ + + const GHbot = new LGHelpTemplate(args); + const {TGbot, db, config} = GHbot; + + GHbot.onMessage( async (msg, chat, user) => { + + if(!msg.chat.isGroup) return; + + //we never listen to commands like this on LGH, it's just as example + if(msg.text == "/private") + { + var text = "Proceed on private chat\n@"+TGbot.me.username; + var buttons = [[ + { + //As you see we follow the hirarchy + callback_data: "EXAMPLE_SHOW_CONFIG:"+chat.id, + text: "Show antiflood config" + } + ]]; + var options = {reply_markup:{inline_keyboard:buttons}}; + GHbot.sendMessage(user.id, user.id, text, options); + } + + } ) + + GHbot.onCallback( (cb, chat, user) => { + + /** + * Also here, if cb.data has a groupId (ex. EXAMPLE:-109848493476) + * following correctly the LGH Callbacks Hirarchy + * the "chat" parameter would be bind to the group + * enriched by the database we have a full LGH chat object + */ + + if(!chat.isGroup) return; + + //callback data is stored on cb.data + if( !cb.data.startsWith("EXAMPLE") ) return + + /** + * Note: we use cb.chat.id, because editMessageText + * needs the chatId where callback is coming from + */ + var editOpts = { + message_id: cb.message.message_id, + chat_id: cb.chat.id, + } + + if(user.perms.settings != 1) + { + GHbot.editMessageText(user.id, "You haven't settings permission", editOpts); + return; + } + + if( cb.data.startsWith("EXAMPLE_SHOW_CONFIG") ) + { + var punish = punishmentToFullText(user.lang, chat.flood.punishment, chat.flood.PTime, chat.flood.delete) + var text = `Chat flood settings + Message limit: ${chat.flood.messages} + Fire if sent within ${chat.flood.time} seconds + User will be punished with ${punish}` + GHbot.editMessageText(user.id, text, editOpts); + } + + //cb.chat keeps for sure the chat wich message is coming from + GHbot.sendMessage( user.id, chat.id, "This callback is from private chat? " + !cb.chat.isGroup ); + + } ) + +} + +module.exports = main; +``` + +## Target user + +As you may have seen from the [LGH Callbacks hirarchy](callbacks.md/#lgh-hirarchy), after `?` exhists a parameter for target users, this callback parameter allows you to bind an user intended to be affected in some way trough the callback, so he is going to be avaiable on [cb.target](GHBot/#targetuser-object) or [msg.waitingReplyTarget](GHBot/#targetuser-object) + +--- + +If you need instead data about a direct target of a message you have msg.target + +These are some cases where [msg.target](GHBot/#targetuser-object) appears: +User X, replying to User Y, Y is the target +User X, use a command mentioning Y (ex. `/ban @UserY`), Y is the target + +That comes useful while handling a command after a [Command creation](commands.md) + +## Conclusion + +Is better to think about the [chat](GHBot.md/#LGHChat) parameter as the selected chat, not the chat we are (that's on msg.chat), but the chat where we are asked to work on diff --git a/docs/documentation/index.md b/docs/documentation/index.md new file mode 100644 index 0000000..e1b6801 --- /dev/null +++ b/docs/documentation/index.md @@ -0,0 +1,18 @@ +# GHBot documentation + +## How it works + +Begin point is from `index.js` which loads [plugins](./plugins.md), database and the acutal bot is then started by main.js + +Other than starting the bot `main.js` emits on [GHBot](GHBot.md/#LGHInterface) some [events](events.md) with many LibreGroupHelp related integrated data ready to use, simplyfing the code + +[Database](database.md) is managed by `database.js`, usually on the `db` variable, main methods are found on db.chats and db.users to manage data about them + +[JSDocs Objects](GHBot.md) documentation are on `GHbot.js`, it may also implement small fixes always to make an easyer interface + +[TGbot](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/api.md) variable will give you direct access to the [telegram-bot-api](https://github.com/yagop/node-telegram-bot-api), when possible you should use GHbot events and methods and if does not exhist the one needed create that +*Additionally on [TGbot.me](https://core.telegram.org/bots/api#getme) is avaiable `await TGbot.getMe()` result* + +Any LibreGroupHelp code should keep in mind that user should be able to delete his data in any moment, that's for respecting at best our privacy philosophy + +[Github good first issues](https://github.com/Sp3rick/GroupHelp/contribute) \ No newline at end of file diff --git a/docs/documentation/known-issues.md b/docs/documentation/known-issues.md new file mode 100644 index 0000000..379b7d9 --- /dev/null +++ b/docs/documentation/known-issues.md @@ -0,0 +1,11 @@ +# Known possible bugs: + +-sometimes db.chats.update in plugins may be not used at all because you can still edit the global object cause to reference, not using it may cause some issue. +if global reference get cleared too early code may try to access and inexistent variable + +-cleanHTML() may be not applyed in some text where it should, and nothing assure that it's 100% able to clean everything needed for telegram api + +-if you add a new permission on userPerms object, every userPerms object should be updated adding that, otherwise this may cause incorrect result in sumUserPerms + +-in some unkown cases you may get stuck in exceptions menu and SafeGram.js will block any user request due too high accumulated volume of something pending + +-permissions setup on first bot adding to groups is not the same as using /reload that's more complete \ No newline at end of file diff --git a/docs/documentation/languages.md b/docs/documentation/languages.md new file mode 100644 index 0000000..7d64f60 --- /dev/null +++ b/docs/documentation/languages.md @@ -0,0 +1,28 @@ +## Language info + +LibeGrouHelp has a language configuration for users (user.lang) and for groups (chat.lang) + +When our bot is added to a group the default group language will be inherited from the user who added LGH Bot + +*Note: currently LGH does not inherit the user language from it's device telegram settings, but it's planned as a future feature* + +`global.LGHLangs` is an object with every language translation loaded +Usually plugins get that using `l = global.LGHLangs` +To translate use this format: `l[lang].KEY` + +Don't bother for missing keys in case of missing translation, every missing key is already replaced with the english one version + + +## Extend bot dictionary + +The main language is english, so open `langs/en_en.json` and simply insert new parameters there + +```json +"FLAG" : "🇬🇧", +"LANG_SELECTOR" : "🇬🇧 English", +"LANG_NAME" : "International English", +"LANG_SHORTNAME" : "English", +"LANG_CHOOSE" : "🇬🇧 Choose your language", +"LANG_CHOOSE_GROUP" : "🇬🇧 Choose group language", +"EXAMPLE_MESSAGE" : "This a new item on dictionary for wiki example" +``` \ No newline at end of file diff --git a/docs/documentation/plugins.md b/docs/documentation/plugins.md new file mode 100644 index 0000000..2cf5b41 --- /dev/null +++ b/docs/documentation/plugins.md @@ -0,0 +1,34 @@ +# Plugins + +You can create any plugin you want creating a new file inside `plugins` folder + +Look at `example.js` to see how it should be organized: + +```javascript +const LGHelpTemplate = require("../GHbot.js") + +function main(args) +{ + + const GHbot = new LGHelpTemplate(args); + const {TGbot, db, config} = GHbot; + + //here your plugin code// + + l = global.LGHLangs; //importing langs object + + GHbot.onMessage( (msg, chat, user) => { + + if( chat.type == "private" && msg.text == "/test999" ) + GHbot.sendMessage( user.id, chat.id, "Hello, i send this because im a plugin\n"+l[user.lang].flag ); + + } ) + + +} + +module.exports = main; +``` + +Put and import in your plugin any needed utility on `api` folder, but if you know that some functions will be ever needed only on your plugin, you are free to declare it directly there + diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..8b67ce9 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,93 @@ +# LibreGroupHelp + +Open-Source re-creation of telegram group manager Group Help in NodeJS based on [node-telegram-api](https://github.com/yagop/node-telegram-bot-api). + +An official instance of bot is running on [@LibreGroupHelpBot](https://t.me/LibreGroupHelpBot) + +## Installation: + +Be sure to have installed a recent version of [NodeJS](https://nodejs.org/) + +Verify NodeJS installation with `node -v` + +Set your bot token using configuration file, look at [config documentation](configuration.md). + +Open a terminal inside LibreGroupHelp folder and run this commands + +```bash +npm install +``` + +Now you should be ready to run LibreGroupHelp using: +```bash +node index.js +``` + + +## What is done + +✅ Completed and working + +🟡 Not fully implemented (work in progress) + +❌ Not implemented at all + +``` +✅ Roles and permissions hirarchy +❌ Custom roles +✅ Moderation commands +❌ Support moderation for channels users +❌ Support for anonymous admins +🟡 Bot support +❌ Bot help (how to use) +❌ Bot clones support +❌ UTC Time settings +✅ Langs and lang settings +✅ Rules +✅ Welcome +✅ Anti-flood +✅ Anti-spam +✅ Goodbye +✅ Alphabets +✅ Captcha (1 mode) +❌ Checks settings +❌ @Admin +❌ Blocks settings +✅ Media blocks +❌ Anti-NSFW +✅ Warns settings +❌ Nigth mode +❌ Tag settings +✅ Link settings +❌ Approve mode +❌ Message Deletion settings +❌ Topics settings +❌ Banned words +❌ Recurring messages +❌ Members management +❌ Masked users settings +❌ Discussion group settings +❌ Personal commands +❌ Magic Strickers/GIFs +❌ Max message length settings +❌ Log channel +❌ Staff group +❌ Group statistics +✅ General commands permissions editor +✅ Remove user-data from group (/forget) +❌ Remove user-data from bot +❌ User privacy mode +✅ Crypto prices external api +``` + +## Updating + +To update LibreGroupHelp you need to backup ./database folder and ./config.json, then repeat installation process and paste there again both file and folder, you may need to add some config.json parameters manually if has been added + +## Contribute + +[Documentation](../documentation/) is the section you are looking for if you want to contribute to LibreGroupHelp + +## Ask a question + +If you have any questions about LibreGroupHelp, feel free to open an issue or ask directly in our telegram group [@LGHChat](https://t.me/LGHChat). diff --git a/docs/plugins/antiflood.md b/docs/plugins/antiflood.md new file mode 100644 index 0000000..bf14a0e --- /dev/null +++ b/docs/plugins/antiflood.md @@ -0,0 +1,12 @@ +# Anti Flood + +**File**: `antiflood.js` + +**Description**: Plugin to punish users who send messages on a group too fast, configuration accessible on [settings](settings.md) + + +## Objects implemented + +- **[LGHFlood](../documentation/GHBot.md/#LGHFlood)** +**Use cases**: +[LGHChat](../documentation/GHBot.md#LGHChat).flood diff --git a/docs/plugins/antispam.md b/docs/plugins/antispam.md new file mode 100644 index 0000000..c349e14 --- /dev/null +++ b/docs/plugins/antispam.md @@ -0,0 +1,12 @@ +# Anti Spam + +**File**: `antispam.js` + +**Description**: Plugin to punish users who send spam messages on a group, this may include `quotes`, `forward`, `external links`, and `telegram links`, configuration accessible on [settings](settings.md) + + +## Objects implemented + +- **[LGHSpam](../documentation/GHBot.md/#LGHSpam)** +**Use cases**: +[LGHChat](../documentation/GHBot.md#LGHChat).spam diff --git a/docs/plugins/captcha.md b/docs/plugins/captcha.md new file mode 100644 index 0000000..d091fd7 --- /dev/null +++ b/docs/plugins/captcha.md @@ -0,0 +1,12 @@ +# Captcha + +**File**: `captcha.js` + +**Description**: Plugin to prevent bot fake users from joining the group asking a captcha process to be not punished, configuration accessible on [settings](settings.md) + + +## Objects implemented + +- **[LGHCaptcha](../documentation/GHBot.md/#LGHCaptcha)** +**Use cases**: +[LGHChat](../documentation/GHBot.md#LGHChat).captcha diff --git a/docs/plugins/command-perms.md b/docs/plugins/command-perms.md new file mode 100644 index 0000000..a7dfd14 --- /dev/null +++ b/docs/plugins/command-perms.md @@ -0,0 +1,7 @@ +# Command permissions + +**File**: `api/editors/CommandsPerms.js` + +**Description**: Implements an [editor](../documentation/editors.md) menu to change commands on a [permissions](../documentation/GHBot.md/#lghperms-object) Object, + +Allows also to set up both permissions for user with private/group reply, and admin with private/group reply, in future it may be used to change perms for roles \ No newline at end of file diff --git a/docs/plugins/goodbye.md b/docs/plugins/goodbye.md new file mode 100644 index 0000000..192fbb9 --- /dev/null +++ b/docs/plugins/goodbye.md @@ -0,0 +1,12 @@ +# Goodbye + +**File**: `goodbye.js` + +**Description**: Plugin to send a goodbye on private user chat and in the group when an user leaves, you can edit both trough [settings](settings.md) with [MessageMaker](message-maker.md) + + +## Objects implemented + +- **[LGHGoodbye](../documentation/GHBot.md/#LGHGoodbye)** +**Use cases**: +[LGHChat](../documentation/GHBot.md#LGHChat).goodbye diff --git a/docs/plugins/index.md b/docs/plugins/index.md new file mode 100644 index 0000000..4f965da --- /dev/null +++ b/docs/plugins/index.md @@ -0,0 +1,5 @@ +# Plugins documentation + +Here you can find every documentation about any [plugin](../documentation/plugins.md) and [editors](../documentation/editors.md) + +Use left side panel to navigate \ No newline at end of file diff --git a/docs/plugins/message-maker.md b/docs/plugins/message-maker.md new file mode 100644 index 0000000..47546fb --- /dev/null +++ b/docs/plugins/message-maker.md @@ -0,0 +1,90 @@ +# Message maker + +## Informations + +**File**: `api/editors/MessageMaker.js` + +**Description**: This is an [editor](../documentation/editors.md) who adds a panel to allow an user to configurate easly a message with `text`, `media` and `buttons`, then, using `MessageMaker.sendMessage` function you can send it anywhere + +### Substitutions + +It implements also a text substitution system extended optionally trough `config.allowExternalApi`, the substitutions are as follows: + + • {ID} = user ID + + • {NAME} = first name of user + + • {SURNAME} = user surname + + • {NAMESURNAME} = name and surname + + • {GHNAME} = name in LGH format ( [userId] name/surname ) + + • {USERNAME} = user @username + + • {MENTION} = link to the user profile + + • {LANG} = user language + + • {FLAG} = user language flag + + • {GROUPNAME} = group name + + • {GROUPUSERNAME} = group username + + • {GROUPID} = group id + + --- + + config.allowExternalApi substitutions: + + Syntax: FIAT{SYMBOL:OPTION} + + • {BTC} {ETH} {BNB} {SOL} {XRP} {DOGE} {TON} {ADA} ... {XMR} = crypto price, avaiable any top2000 crypto symbol + + • {TOP1} {TOP2} ... {TOP2000} = get crypto symbol at specific classific height (max 2000) ({TOP1} will translate to "BTC", so {{TOP1}} is the same of {BTC} and will give you the crypto price) + + • Options: CAP(capitalization), VOL(24h volume), SUPPLY, RANK(cap classific), NAME, EXPLORER. (example: {BTC:CAP}) + + • Convert from default to specific currency: ${number}, €{number}, £{number}, CHF{number} or ₣{number}. + + • Examples: {BNB}, €{BTC}, CHF{ETH}, £{BTC:CAP}, {XMR:SUPPLY}, €{{TOP15}} £{{TOP3}:NAME} + + • Api: https://api.coincap.io/v2/assets (https://docs.coincap.io/) + + + --- + + NOT IMPLEMENTED: + + • {RULES} = group regulation text + + • {DATE} = current date + + • {TIME} = current time + + • {WEEKDAY} = week day + + • {MONTH} = current month + + • {YEAR} = current year + + • {UNIX} = seconds since 1970/1/1 + + + + +## Objects implemented + +- **[customMessage](../documentation/GHBot.md/#custommessage-object)** +**Use cases**: +[LGHChat](../documentation/GHBot.md/#LGHChat).rules +[LGHWelcome](../documentation/GHBot.md/#lghwelcome-object).message +[LGHGoodbye](../documentation/GHBot.md/#LGHGoodbye).gMsg +[LGHGoodbye](../documentation/GHBot.md/#LGHGoodbye).pMsg + +
+ +- **[simpleMedia](../documentation/GHBot.md/#simplemedia-object)** +**Use cases**: +[customMessage](../documentation/GHBot.md/#LGHChat).media \ No newline at end of file diff --git a/docs/plugins/pin.md b/docs/plugins/pin.md new file mode 100644 index 0000000..f13681e --- /dev/null +++ b/docs/plugins/pin.md @@ -0,0 +1,7 @@ +# Pin + +**File**: `pin.js` + +**Description**: Plugin to add pin messages commands + +**Commands**: `/pin` \ No newline at end of file diff --git a/docs/plugins/promote.md b/docs/plugins/promote.md new file mode 100644 index 0000000..e06347b --- /dev/null +++ b/docs/plugins/promote.md @@ -0,0 +1,7 @@ +# Promotions + +**File**: `promotions.js` + +**Description**: This plugin add commands to promote users to any pre-made role by [Roles manager](roles-manager.md) + +**Commands**: `/free`, `/unfree`, `/helper`, `/unhelper`, `/cleaner`, `/uncleaner`, `/muter`, `/unmuter`, `/mod`, `/unmod`, `/cofounder`, `/uncofounder`, `/admin`, `/unadmin`, `/title`, `/untitle` \ No newline at end of file diff --git a/docs/plugins/punish.md b/docs/plugins/punish.md new file mode 100644 index 0000000..6fcfc03 --- /dev/null +++ b/docs/plugins/punish.md @@ -0,0 +1,7 @@ +# Punishments + +**File**: `punish.js` + +**Description**: Implement punishent and unpunishent commands using the utility of `api/utils/punishment.js` + +**Commands**: `/delete`, `/warn`, `/unwarn`, `/kick`, `/mute`, `/unmute`, `/ban`, `/unban` \ No newline at end of file diff --git a/docs/plugins/roles-manager.md b/docs/plugins/roles-manager.md new file mode 100644 index 0000000..ef38c82 --- /dev/null +++ b/docs/plugins/roles-manager.md @@ -0,0 +1,35 @@ +# Roles Manager + +## Informations + +**File**: `usersHandler.js` + +**Description**: This plugin manage users data and roles in the group, implements also `api/utils/rolesManager.js` to give an external interface to deal with roles + +Adds on `global.roles[roleName]` data about these pre-made roles: `founder`, `moderator`, `muter`, `cleaner`, `helper`, `free`. + +**Commands**: `/reload`, `/staff`, `/info`, `/perms`, `/forgot` + + +## Objects implemented + +- **[LGHRole](../documentation/GHBot.md/#lghrole-object)** +**Use cases**: +[LGHChat](../documentation/GHBot.md#LGHChat).roles + +
+ +- **[LGHPerms](../documentation/GHBot.md/#lghperms-object)** +**Use cases**: +[LGHChat](../documentation/GHBot.md#LGHChat).basePerms +[LGHChat](../documentation/GHBot.md#LGHChat).adminPerms +[LGHUser](../documentation/GHBot.md#LGHUser).perms +[LGHRole](../documentation/GHBot.md#LGHRole).perms + +
+ +- **[userStatus](../documentation/GHBot.md/#userstatus-object)** +**Use cases**: +[LGHChat](../documentation/GHBot.md#LGHChat).users + +
diff --git a/docs/plugins/rules.md b/docs/plugins/rules.md new file mode 100644 index 0000000..8ed47bf --- /dev/null +++ b/docs/plugins/rules.md @@ -0,0 +1,7 @@ +# Rules + +**File**: `rules.js` + +**Description**: Plugin to add rules of the group and allow to edit these trough [settings](settings.md) with [MessageMaker](message-maker.md) + +**Commands**: `/rules` \ No newline at end of file diff --git a/docs/plugins/set-chat-based-punish.md b/docs/plugins/set-chat-based-punish.md new file mode 100644 index 0000000..ec8c2a5 --- /dev/null +++ b/docs/plugins/set-chat-based-punish.md @@ -0,0 +1,17 @@ +# Set chat based punishment + +## Informations + +**File**: `api/editors/setChatBasedPunish.js` + +**Description**: This is an [editor](../documentation/editors.md) who adds a panel to allow an user to configurate easly a different punishment based on various chat types `private`, `bot`, `group`, `channel` + + +## Objects implemented + +- **[LGHChatBasedPunish](../documentation/GHBot.md/#lghrole-object)** +**Use cases**: +[LGHSpam](../documentation/GHBot.md/#lghspam-object).forward +[LGHSpam](../documentation/GHBot.md/#lghspam-object).quote + +
\ No newline at end of file diff --git a/docs/plugins/settings.md b/docs/plugins/settings.md new file mode 100644 index 0000000..6d01a33 --- /dev/null +++ b/docs/plugins/settings.md @@ -0,0 +1,7 @@ +# Settings + +**File**: `settings.js` + +**Description**: This plugin manages settings for single users and settings panel for groups, lang settings are included + +**Commands**: `/settings` \ No newline at end of file diff --git a/docs/plugins/warns.md b/docs/plugins/warns.md new file mode 100644 index 0000000..dfcdcfc --- /dev/null +++ b/docs/plugins/warns.md @@ -0,0 +1,12 @@ +# Warns + +**File**: `warns.js` + +**Description**: Plugin to implement warn configuration [settings](settings.md) on a group + + +## Objects implemented + +- **[LGHWarns](../documentation/GHBot.md/#LGHWarns)** +**Use cases**: +[LGHChat](../documentation/GHBot.md#LGHChat).warns diff --git a/docs/plugins/welcome.md b/docs/plugins/welcome.md new file mode 100644 index 0000000..5496b78 --- /dev/null +++ b/docs/plugins/welcome.md @@ -0,0 +1,12 @@ +# Welcome + +**File**: `welcome.js` + +**Description**: Plugin to allow to set up trough [settings](settings.md) with [MessageMaker](message-maker.md) a welcome message for new users in the group + + +## Objects implemented + +- **[LGHWelcome](../documentation/GHBot.md/#lghwelcome-object)** +**Use cases**: +[LGHChat](../documentation/GHBot.md#LGHChat).welcome diff --git a/docs/wiki/commands.md b/docs/wiki/commands.md new file mode 100644 index 0000000..d1f641e --- /dev/null +++ b/docs/wiki/commands.md @@ -0,0 +1,172 @@ +# 📋 Commands + +> ### Note for devs: +> - **`COMMAND_`** code prefix means that the command is to be resolved on languages. +> - **`COMMAND`** codes is also used to define permitted commands on [perms](../documentation/GHBot.md/#LGHPerms) object. +> - **`@`** prefix on a command code/name means that user has permission to get the reply within private chat only (e.g., `@COMMAND_RULES`). + +--- + +Some commands can use the **`*`** prefix (e.g., `/*rules`, `/*perms`) to force a reply on private chat, only if you have the right permissions inside the group + +### General Commands + +- **/settings** + Opens the group settings. + **Code:** `COMMAND_SETTINGS` + +- **/rules** + Shows the group rules. + **Code:** `COMMAND_RULES` + **Note:** **`*`** Allowed + +- **/perms** + Shows bot permissions of a user. + **Code:** `COMMAND_PERMS` + **Note:** **`*`** Allowed + +- **/staff** + Shows group staff with default and custom roles. + **Code:** `COMMAND_STAFF` + **Note:** **`*`** Allowed + +- **/info** + Shows information about a group user and allows editing. + **Code:** `COMMAND_INFO` + **Note:** **`*`** Allowed + +- **/me** + Shows information about yourself. + **Code:** `COMMAND_ME` + **Note:** **`*`** Allowed + +- **/pin** + Pins a chat message with or without a notification. + **Code:** `COMMAND_PIN` + **Note:** **`*`** Allowed + +### Punishment Commands + +- **/del** + Deletes a message. + **Code:** `COMMAND_DELETE` + +- **/warn** + Warns a user and punishes them if they reach the group warning limit. + **Code:** `COMMAND_WARN` + +- **/unwarn** + Removes a warning from a user. + **Code:** `COMMAND_UNWARN` + +- **/delwarn** + Warns a user and deletes a message. + **Code:** `COMMAND_DELWARN` + +- **/kick** + Kicks a user out of the group. + **Code:** `COMMAND_KICK` + +- **/delkick** + Kicks a user and deletes a message. + **Code:** `COMMAND_DELKICK` + +- **/mute** + Disables messaging for a user. + **Code:** `COMMAND_MUTE` + +- **/unmute** + Re-enables messaging for a user. + **Code:** `COMMAND_UNMUTE` + +- **/delmute** + Mutes a user and deletes a message. + **Code:** `COMMAND_DELMUTE` + +- **/ban** + Permanently removes a user from the group. + **Code:** `COMMAND_BAN` + +- **/unban** + Unbans a user from the group. + **Code:** `COMMAND_UNBAN` + +- **/delban** + Bans a user and deletes a message. + **Code:** `COMMAND_DELBAN` + +### Role Management Commands + +- **/free** + Assigns the free role to a user. + **Code:** `COMMAND_FREE` + +- **/unfree** + Removes the free role from a user. + **Code:** `COMMAND_UNFREE` + +- **/helper** + Assigns the helper role to a user. + **Code:** `COMMAND_HELPER` + +- **/unhelper** + Removes the helper role from a user. + **Code:** `COMMAND_UNHELPER` + +- **/cleaner** + Assigns the cleaner role to a user. + **Code:** `COMMAND_CLEANER` + +- **/uncleaner** + Removes the cleaner role from a user. + **Code:** `COMMAND_UNCLEANER` + +- **/muter** + Assigns the muter role to a user. + **Code:** `COMMAND_MUTER` + +- **/unmuter** + Removes the muter role from a user. + **Code:** `COMMAND_UNMUTER` + +- **/mod** + Assigns the moderator role to a user. + **Code:** `COMMAND_MODERATOR` + +- **/unmod** + Removes the moderator role from a user. + **Code:** `COMMAND_UNMODERATOR` + +- **/cofounder** + Assigns the cofounder role to a user. + **Code:** `COMMAND_COFOUNDER` + +- **/uncofounder** + Removes the cofounder role from a user. + **Code:** `COMMAND_UNCOFOUNDER` + +### Admin Commands + +- **/admin** + Grants admin status to a user. + **Code:** `COMMAND_ADMINISTRATOR` + +- **/unadmin** + Removes admin status from a user. + **Code:** `COMMAND_UNADMINISTRATOR` + +- **/title** + Sets an administrator group title. + **Code:** `COMMAND_TITLE` + +- **/untitle** + Removes an administrator group title. + **Code:** `COMMAND_UNTITLE` + +### Privacy Commands + +- **/forgot** + Removes all data about an user from your group. + **Code:** `COMMAND_FORGOT` + +
\ No newline at end of file diff --git a/docs/wiki/configuration.md b/docs/wiki/configuration.md new file mode 100644 index 0000000..7712724 --- /dev/null +++ b/docs/wiki/configuration.md @@ -0,0 +1,71 @@ +# Configuration guide (config.json) + +## Essential settings + +**botToken**: `String` +Your bot token gaven from [@BotFather](https://t.me/BotFather) (ex. `4839574812:AAFD39kkdpWt3ywyRZergyOLMaJhac60qc`) + +**botStaff**: `Array` +List of User Ids considered bot staff (ex. `[33224765, 82399935]`) + + +## Privacy settings + +**deleteChatDataAfterBotRemove**: `Boolean` +If enabled all chat data will be deleted from bot database when you kick the bot from a group + +**overwriteChatDataIfReAddedToGroup**: `Boolean` +If enabled chat data and configurations will be regenerated if bot has been re-added to the group overwriting the old one + +**allowExternalApi**: `Boolean` +Allow to gather additional data by various online api's, that's may reveal the ip of your server, default to false + + +## Other settings + +**reserveLang**: `String` +Main bot language, this will be used to overwrite other languages with incompleted translations, we advise to keep it unchanged or use a full implemented language + +**saveDatabaseSeconds**: `Number` +Number of seconds of how often loaded chats should be written on disk, useful to prevent data loss on crash + +**saveTagResolverSeconds**: `Number` +Number of seconds of how often tagResolver data should be saved on disk + +**maxCallbackAge**: `Number` +Maximum number of seconds a callback button should be old to be accepted by the bot, you can reduce this in case of incompatible callbacks after an update that cause crash + +**preventSetUselessRoles**: `Boolean` +Disallow from setting roles if it does not change the user status in the group + +**chatWhitelist**: `Array` +If there are at least one element the bot will work only on these chat ids (ex. `[-10294995433434, -429930035587]`) + +**privateWhitelist**: `Boolean` +True if chat whitelist should ignore also private chats not included in chatWhitelist, useless if chatWhitelist is disabled + +**chatBlacklist**: `Array` +Bot wont more handle requests of Chat Ids on this list (ex. `[-10294995433434, -429930035587]`) + + +## Plugin settings + +**ANTIFLOOD_msgMin**: `Number` +minimum settable number of messages to triggher the antiflood + +**ANTIFLOOD_msgMax**: `Number` +maximum settable number of messages to triggher the antiflood + +**ANTIFLOOD_timeMin**: `Number` +minimum settable time in which N messages should be sent to triggher the antiflood + +**ANTIFLOOD_timeMax**: `Number` +maximum settable time in which N messages should be sent to triggher the antiflood + +**minWarns**: `Number` +minimum settable warns on settings + +**maxWarns**: `Number` +maximum settable warns on settings + +
\ No newline at end of file diff --git a/docs/wiki/perms.md b/docs/wiki/perms.md new file mode 100644 index 0000000..28e46ee --- /dev/null +++ b/docs/wiki/perms.md @@ -0,0 +1,46 @@ +# Permissions + +Permissions is the system that define what the user is allowed or disallowed to do inside your group, what commands he can and can't use, and trough [roles](roles.md) authority level, who he can penalize and who not + +An user inherits the autorithy level from the higher level among his roles + +You can always see the permissions and level that an user owns using `/perms` + +--- + +## Calculating user permissions + +The calculation of user permissions is made by levels of priority based on this order (the following list goes from lowest priority to higher): + + +- **👥 Group basic permissions** + The basic group permissions that's applied by default to every user, that has lowest priority on perms calculation + **🔧 How to edit:** `/settings` -> `Other (button)` -> `Permissions` -> `Commands permissions` +

+ +- **👲 Admin basic permissions** + Basic group permissions that's applied to every group administrator + **🔧 How to edit:** `/settings` -> `Other (button)` -> `Permissions` -> `Commands permissions` +

+ +- **🎓 Roles permissions** + Permission set of each [role](roles.md/#bot-roles), priority ordered from lowest role Authority level to higher + **🔧 How to edit:** [Bot roles promotion commands](roles.md/#bot-roles) +

+ +- **👮 Admin permissions** + Permissions inhered from administrator telegram settings, if an admin can do an action trough telegram, he will be able to do so also trough LibreGroupHelp + **🔧 How to edit:** `/admin`, `/perms` or telegram settings +

+ +- **👤 User permissions** + Permission applyed only to that one specific user, it takes over maximum priority on perms calculation, essential for more granular permissions control + **🔧 How to edit:** Currently not implemented +

+ + +Each permission can be either ✅ allowing wise, 🔘 neutral, or ❌ disallowing wise, as example, if `Group basic permissions` (lowest priority) allows the `/rules` command, but `User permissions` (highest priority) disallow it, this user won't be able to use `/rules` + +Neutral state instead, allows an higher priority level to inherit from lowest, when creating custom roles we advise you to use always the neutral state if the role you are making is not limitation-focused + +
\ No newline at end of file diff --git a/docs/wiki/roles.md b/docs/wiki/roles.md new file mode 100644 index 0000000..1d2519f --- /dev/null +++ b/docs/wiki/roles.md @@ -0,0 +1,87 @@ +# Roles + +You can set roles to every user on your group, the main use of roles is giving an user authority level on the group and give them a defined set of [permissions](perms.md), both relative to your group and bot + +You can see what roles are assigned to users on your group using `/staff` + +## Admin role + +The most important role is the [Administrator](https://telegram.org/blog/supergroups) role, an user can get this role with `/admin` command (advised) or [directly trough your group settings](https://telegram.org/blog/admin-revolution#admin-rights), by fact it's the role directly correlated with the acutal admin from telegram side, you can change admin title using `/title` + +LibreGroupHelp will bind the telegram admin permissions to match with the correlated commands and functions + +If for example by telegram settings your admin can remove users, he will automatically obtain this LibreGroupHelp commands: `/kick`, `/warn`, `/mute`, `/ban` + +--- + +## Bot roles + +LibreGroupHelp aims to provide a more granular control about permissions of your users and staffers, a granularity that trough telegram admins function can't be reached, that's why you can give the role `/muter` to allow a staffer to use just the `/mute` command, + +Currently these are the roles implemented by LibreGroupHelp: + +- **👑 Founder** + The role avaiable only for group owner + **Commands:** `All` + **Promotion:** Telegram settings (transfer ownership) + **🔏 Bot permissions:** `All` + **📗 Authority:** 100 +

+ +- **⚜️ Co-Founder** + The role to give full bot permissions to an user + **Commands:** `All` + **Promotion:** `/cofounder`, `/uncofounder` + **🔏 Bot permissions:** `All` + **📗 Authority:** 90 +

+ +- **👮 Administrator** + The role given to every group admin on telegram + **Commands:** Depends on admin permissions + **Promotion:** [Telegram settings](https://telegram.org/blog/admin-revolution#admin-rights) + **🔏 Bot permissions:** `immune`, `flood`, `spam`, `nsfw`, `night`, `media`, `alphabets`, `words`, `length` (for `roles` and `settings` depends on telegram admin permissions) + **📗 Authority:** 0 +

+ +- **🙊 Muter** + Staffer who can mute users + **Commands:** `/rules`, `/mute`, `/unmute` + **Promotion:** `/muter`, `/unmuter` + **🔏 Bot permissions:** none + **📗 Authority:** 40 +

+ +- **🛃 Cleaner** + Staffer who can delete messages from your group + **Commands:** `/rules`, `/delete` + **Promotion:** `/cleaner`, `/uncleaner` + **🔏 Bot permissions:** none + **📗 Authority:** 20 +

+ +- **⛑ Helper** + An user that contributes to the group support + **Commands:** `/rules`, `/info` + **Promotion:** `/helper`, `/unhelper` + **🔏 Bot permissions:** none + **📗 Authority:** 10 +

+ +- **🔓 Free** + An user free from any bot restriction + **Commands:** none + **Promotion:** `/free`, `/unfree` + **🔏 Bot permissions:** `immune`, `flood`, `spam`, `nsfw`, `night`, `media`, `alphabets`, `words`, `length` + **📗 Authority:** 0 + + +--- + +## Custom roles + +Custom roles is a functionality still not implemented and we aim to add as soon as possible, the priority depends from the acutal request from users + +Custom roles will unlock you the possibility to create your own group roles with any Role Level and any permission set you want, speeding up your administration work + +
diff --git a/documentation.md b/documentation.md deleted file mode 100644 index 9ff15a1..0000000 --- a/documentation.md +++ /dev/null @@ -1,248 +0,0 @@ -## General code info - -index.js does load every plugin and database and acutal bot on main.js - -main.js does all necessary works before emitting on GHbot and event with many LibreGroupHelp related data ready to use - -all data is managed by database.js, you can access it's methods from db.chats and db.users - -all jsdocs objects documentation is on GHbot.js, it's also essential to document event parameters of GHbot events - -use TGbot only if you need direct native access with telegram bot api, when possible you should use GHbot events and methods and if does not exhist the one needed create that, TGbot method docs can be found on https://github.com/yagop/node-telegram-bot-api, on TGbot.me is avaiable await TGbot.getMe() result - -While coding keep in mind that user should be able to delete his data in any moment, this for respecting the privacy philosophy of LibreGroupHelp (exception can be for essential data for groups, for example warns number, allow to delete this is going to be abusable) - -## Plugins - -Look at example.js plugin to see how it uses right functions and methods to work with LibreGroupHelp - -```javascript -var LGHelpTemplate = require("../GHbot.js") - -function main(args) -{ - - const GHbot = new LGHelpTemplate(args); - const {TGbot, db, config} = GHbot; - - //here your plugin code// - - l = global.LGHLangs; //importing langs object - - GHbot.onMessage( (msg, chat, user) => { - - if( chat.type == "private" && msg.text == "/test999" ) - GHbot.sendMessage( user.id, chat.id, "Hello, i send this because im a plugin\n"+l[user.lang].flag ); - - } ) - - -} - -module.exports = main; -``` - - -You can create and use functions to import on ./api/, but if you think it's going to be used only on your plugin you can do that in same file -If you need access text of varius languages it's stored at global.LGHLangs (I advise set it like this "l = global.LGHLangs;") - - -## GHBot variables - -ONLY for events from GHBot you have additional elements on parameters bot-related - -Usually GHBot events has 3 parameters: request (cb/msg), chat, user. - -On GHBot.onCallback() and GHBot.onMessage() if event comes from a group or callback data has a chat id, "chat" object will contain the full Custom Chat Object with chat.isGroup true, anyway the chat from where the request is coming is always avaiable in cb.chat or msg.chat - -user.perms (result of api/rolesManager/sumUserPerms()) is avaiable in 2 cases: if callback.data or msg.waitingReply contains a groupId, if cb.chat.isGroup or msg.chat.isGroup - -NOTE: user.perms is a temporary item, it's not intended to be saved in the database (database does not save it) -Any "msg" object contains msg.command (result of api/utils/parseCommand(msg.text)) - -Targets -Any message object may contain an msg.target object if a message reply target user is found -Also cb.target may exhist, builded up from user id after "?" in cb.data -msg.waitingReplyTarget is set if a target if found on msg.waitingReplyType (after "?") - -NOTE FOR CALLBACK EVENT: callback event gives you the full chat object only if chat.isGroup is true, if is private chat you should require it yourself from the database (var settingsChatId = cb.data.split(":")[1]; var settingsChat = db.chats.get(settingsChatId)) - -You can find a comment referring security guards that you can use too in plugins/welcome.js - - -## Language info - -The bot has a different language configuration both for users and group -when LibreGroupHelp is added to a group (and add it to the database) the default group language will be inherited from the user who added the bot, (TODO. convert function for telegram user.language_code to LibreGroupHelp lang code, format on https://en.wikipedia.org/wiki/IETF_language_tag) - - -## Expect user messages - -You can expect for user messages in a chat or in private for a chat by using waitReplyForChat(db, callback, user, chat, onGroup) (from utils.js) -The text on callback variable should follow the Callbacks LGH Hirarchy (hirarchy in the section below) - -When you receive a new message event msg.waitingReply will be set to string or false by main.js depending if it's the right chat -Remember that if you waitReplyForChat in a certain point you will need also to disable that, otherwise other bot functions that wants msg.waitingReply false is not going to work (like commands), disable with unsetWaitReply(db, user, chat, onGroup) - - -## Callbacks and user callbacks data management (Hirarchy) - -Here is described the hirarchy of callbacks data. -Giving right callaback data is essential to allow main.js to pre-set wanted values -They are both avaiable on cb.data for buttons or on msg.waitingReplye for messages that bot is expecting - -Hirarchy - -cb.data OR msg.waitingReply = CALLBACK_NAME!data#editor_things|editorData:groupId?targetUserId - -To work with less items, same order only matters: CALLBACK_NAME:groupId OR CALLBACK_NAME#editor?targetUserId OR CALLBACK_NAME:groupId?targetUserId. They are all valid - --CALLBACK_NAME: name of callback that you can use, be sure that not conflicts with other names, often plugins check if it's their match with string.startsWith() - --data: some additional data that you can attach to CALLBACK_NAME - --editor: also that is often identified with string.startsWith(), it's usually used to open re-usable menus like MessageMaker.js, setNum.js, setTime.js - --editorData that editor may attach - --groupId: that allow main.js to set a full object of chat (note: msg.chat or cb.message.chat may be not affected, GHbot ever gives you a dedicated chat parameter), it also allow to set the user.perms object in private chat (in group it's done directly from chat.id) - --targetUserId: that allow main.js to set a target user in various cases: cb.target, msg.userWaitingReplyTarget (target for text commands is not related with that, it's also avaiable on msg.target and it's based on msg.text instead of targetUserId) - - -## Roles - -Roles is managed by plugins/usersHandler.js and api/rolesManager.js - -An user can have multiple roles at the same time -Every role has a level, higher level means best role priority, an user inherits the level of the higher level on its roles -An user can affect with any allowed command any other user with a level lower than him - -Both users and roles has their own customPerms object, user perms object has the maximal priority -(rolesManager.js) sumUserPerms() will sum for you all permissions, including roles ordered by level and user perms itself with maximum priority, this function is all you need to know what the user can and can't do - -Pre-made roles are set with specific commands (/mod, /muter, /cleaner, /helper, /free) +(unset with "un" prefix, ex: "/unmod") -To set custom roles the command will be /setrole roleName - -User permissions data result of sumUserPerms() may be avaiable at target.perms or user.perms - - -## LGH Objects - -Custom Chat Object - -Additional data of custom chat object: - ->admins: array with known admins objects (user data anonymized) - ->lang : current chat lang - ->isGroup : result of (chat.type == "supergroup" || chat.type == "group") - ->users : Object-IdName based data about every user in the group (ex. users[643547] access data of userId 643547) - ->basePerms : base permissions applyed to every user - ->adminPerms : base permissions applyed to admin - ->roles : GHRole data about a specific role, full role Object if it's a custom role (key with a number) - ->warns : warns.js plugin related data - ->rules : rules.js plugin related data - ->welcome : welcome.js plugin related data - ->flood : flood.js plugin related data - --When you modify any of this data don't forget to update it with db.chats.update(chat) - - -Custom User Object - -Additional data of custom user object: - ->lang : current user lang - ->waitingReply : set to true if the bot is expecting a message from the user - --When you modify any of this data don't forget to update it with db.users.update(user) - - -Custom Message Object - -Additional data of custom msg object: - ->command : result of message text parsed with parseCommand() - ->target : identified target of message, it's may be derived from the command or from replyed user - - -Command Object - -You can get this object trough parseCommand(text) - * @property {String} text - Full raw command text - * @property {String} prefix - Prefix, example: / ! . , ; - * @property {String} botCommand - Command and bot specifier (ex. "start@usernamebot") - * @property {String} name - Command name (ex. "start") - * @property {String} bot - Specified bot name (ex. "usernamebot") - * @property {String} args - Raw arguments text after the command - * @property {Array} splitArgs - Array of arguments split by space - -*target is not listed because that's set later by main.js - - -## Commands - -Note: COMMAND_ prefix means that command can be solved in multiple languages -@ prefix in command name gives the permission with private chat reply (example @COMMAND_RULES) -to explicitly ask to reply to your command in private chat use * as prefix (ex. /\*rules, /\*perms) -Complete list of implemented commands: - --General -* /settings - open group settings (COMMAND_SETTINGS) -* /rules - show group rules (COMMAND_RULES) (force private avaiable) -* /perms - show bot permissions of an user (COMMAND_PERMS) (force private avaiable) -* /staff - show group staff with default and custom roles (COMMAND_STAFF) (force private avaiable) -* /info - show info about a group user and edit it (COMMAND_INFO) (force private avaiable) -* /me - show info about yourself (COMMAND_ME) (force private avaiable) -* /pin - pin a chat message with or without notification (COMMAND_PIN) (force private avaiable) - --Punishments -* /del - delete a message (COMMAND_DELETE) -* /warn - warn user and punish if reach group warn limit (COMMAND_WARN) -* /unwarn - remove a warn from user (COMMAND_UNWARN) -* /delwarn - warn user and delete a message (COMMAND_DELWARN) -* /kick - kick an user out from the group (COMMAND_KICK) -* /delkick - kick user and delete a message (COMMAND_DELKICK) -* /mute - disable messages to a user (COMMAND_MUTE) -* /unmute - re-enable messages to an user (COMMAND_UNMUTE) -* /delmute - mute user and delete a message (COMMAND_DELMUTE) -* /ban - permanently remove an user from the group (COMMAND_BAN) -* /unban - unban user from the group (COMMAND_UNBAN) -* /delban - ban user and delete a message (COMMAND_DELBAN) - --Roles -* /free - give free role to user (COMMAND_FREE) -* /unfree - remove free role to user (COMMAND_UNFREE) -* /helper - set helper role to user (COMMAND_HELPER) -* /unhelper - remove helper role to user (COMMAND_UNHELPER) -* /cleaner - set cleaner role to user (COMMAND_CLEANER) -* /uncleaner - remove cleaner role to user (COMMAND_UNCLEANER) -* /muter - set muter role to user (COMMAND_MUTER) -* /unmuter - remove muter role to user (COMMAND_UNMUTER) -* /mod - set moderator role to user (COMMAND_MODERATOR) -* /unmod - remove moderator role to user (COMMAND_UNMODERATOR) -* /cofounder - set cofounder role to user (COMMAND_COFOUNDER) -* /uncofounder - remove cofounder role to user (COMMAND_UNCOFOUNDER) - --Admins -* /admin - make user admin (COMMAND_ADMINISTRATOR) -* /unadmin - remove admin role to user (COMMAND_UNADMINISTRATOR) -* /title - set admin title (COMMAND_TITLE) -* /untitle - remove admin title (COMMAND_UNTITLE) - --Privacy -* /forgot - remove every data on the group about an user (COMMAND_FORGOT) - -You can find additional info on plugins.md https://github.com/Sp3rick/GroupHelp/blob/main/plugins.md diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..f58290f --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,80 @@ +site_name: LibreGroupHelp Wiki +site_url: https://sp3rick.github.io/GroupHelp +repo_url: https://github.com/Sp3rick/GroupHelp +repo_name: Sp3rick/GroupHelp + +theme: + name: material + logo: assets/logo.png + palette: + - scheme: default + primary: deep purple + accent: green + toggle: + icon: material/brightness-7 + name: Switch to dark mode + - scheme: slate + primary: deep purple + accent: green + toggle: + icon: material/brightness-4 + name: Switch to light mode + features: + - search.suggest + - search.highlight + - search.share + - navigation.tabs + - navigation.tabs.sticky + - navigation.indexes + - content.code.copy + +nav: + - Home: + - Home: index.md + - Configuration: wiki/configuration.md + - Commands: wiki/commands.md + - Roles: wiki/roles.md + - Permissions: wiki/perms.md + - Documentation: + - Home: documentation/index.md + - Plugins creation: documentation/plugins.md + - Database usage: documentation/database.md + - Expect messages/buttons: documentation/callbacks.md + - LGH Events: documentation/events.md + - Command creation: documentation/commands.md + - Languages: documentation/languages.md + - Editors: documentation/editors.md + - Objects: documentation/GHBot.md + - TODO List: documentation/TODO-List.md + - Known issues: documentation/known-issues.md + - Plugins Documentation: + - Home: plugins/index.md + - Settings: plugins/settings.md + - ✏️ Message maker: plugins/message-maker.md + - Roles manager: plugins/roles-manager.md + - Promotions: plugins/promote.md + - Punishments: plugins/punish.md + - Rules: plugins/rules.md + - Welcome: plugins/welcome.md + - Anti-Flood: plugins/antiflood.md + - Anti-Spam: plugins/antispam.md + - Captcha: plugins/captcha.md + - Goodbye: plugins/goodbye.md + - Warns: plugins/warns.md + - Pin: plugins/pin.md + - ✏️ Set chat based punishment: plugins/set-chat-based-punish.md + - ✏️ Command permissions: plugins/command-perms.md + + + + + + +markdown_extensions: + - pymdownx.highlight: + anchor_linenums: true + line_spans: __span + pygments_lang_class: true + - pymdownx.inlinehilite + - pymdownx.snippets + - pymdownx.superfences diff --git a/package.json b/package.json index 68713b2..4148d1d 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,7 @@ { + "devDependencies": { + "jsdoc-to-markdown": "^8.0.3" + }, "dependencies": { "@xmldom/xmldom": "^0.8.10", "canvas": "^2.11.2", diff --git a/plugins.md b/plugins.md deleted file mode 100644 index 80477df..0000000 --- a/plugins.md +++ /dev/null @@ -1,439 +0,0 @@ -Here there are various documentations about various plugins, if you created one you can document it here - -If you need documentation look at here [documentation.md](https://github.com/Sp3rick/GroupHelp/blob/main/documentation.md) - - -## Roles Manager -(api/rolesManager.js) - ->Depends on api/utils/utils.js - -This plugin manages users data and roles in the group - -1 means true - -0 means neutral - --1 means false - -LGHPerms Object: - ->commands: array of commands, if starts with "COMMAND_" means its to be translated, otherwise is the literal command -> ->immune: active if this user can't receive any punishment (kick/warn/mute/ban) [1/0/-1] -> ->flood: permission to flood messages [1/0/-1] -> ->link: permission to send links [1/0/-1] -> ->tgLink: permission to send telegram links/usernames [1/0/-1] -> ->forward: permission to forward messages from anywhere [1/0/-1] -> ->quote: permission to quote from anywhere [1/0/-1] -> ->porn: bypass porn/gore checks [1/0/-1] -> ->night: bypass any night mode limitation [1/0/-1] -> ->media: bypass any media limitation [1/0/-1] -> ->alphabets: Bypass any alphabets characters limitations [1/0/-1] -> ->words: Bypass banned words limitations [1/0/-1] -> ->length: Bypass message length limitations [1/0/-1] -> ->roles: permission to change roles of lower level users [1/0/-1] -> ->settings: permission to change bot group settings [1/0/-1] - - -Intended permissions anarchy: (if a left-side permission is not neutral overwrites everything in the right side) - -chat.users[id].perms > chat.users[id].adminPerms > chat.roles[role].perms (higher role level has higher priority) > chat.basePerms - - - -chat.users[id] userStatus Object: - ->firtJoin: Unix number of first user join time in seconds, false if unknown -> ->perms: LGHPerms object for all user-specific permissions -> ->adminPerms: LGHPerms object for user permissions if admin -> ->roles: array of user roles, string for pre-made roles, number for custom roles (user-made) -> ->warnCount: number of user warns -> ->title: user administrator title - - - -chat.roles[role] LGHRole Object: ( the pre-made roles are in global.roles[roleName] ) - ->name: role name -> ->emoji: emoji for the role -> ->level: role level, higher level users can use commands that affect lower level users -> ->perms: LGHPerms object applyed at lowest priority on any user in this role -> ->users: array of userId in this role - - - - - -## Message Maker -(api/MessageMaker.js) - ->Depends on api/utils/utils.js - -simpleMedia Object: - ->type : Type of media (audio, photo, video, video_note, animation, sticker, document) or false -> ->fileId : media fileId or false -> ->options : additional options for TelegramBot - - -customMessage Object: - ->text : Text of messsage -> ->entities : Telegram entities of text -> ->format : Boolean, true if message should be formatted (enabled by default), mean that entities should be passed on sendMessage function -> ->media : { type, fileId, thumbnail } -> ->buttons : String, can be transformed in inline_keyboard with parseTextToInlineKeyboard() -> ->buttonsParsed : already parsed buttons ready to use for inline_keyboard - -Callback_data order: - -CallerPrefix#MSGMK:settingsChatId - -CallerPrefix is useful to allow the caller to identify it's own callback (ex. if( cb.data.startsWith(myPrefix) ... )) - -text avaiable substitutions: - -• {ID} = user ID - -• {NAME} = first name of user - -• {SURNAME} = user surname - -• {NAMESURNAME} = name and surname - -• {GHNAME} = name in LGH format ( [userId] name/surname ) - -• {USERNAME} = user @username - -• {MENTION} = link to the user profile - -• {LANG} = user language - -• {FLAG} = user language flag - -• {GROUPNAME} = group name - -• {GROUPUSERNAME} = group username - -• {GROUPID} = group id - -(TO IMPLEMENT & TODO: allow to make a sum of dates and time) - -• {RULES} = group regulation text - -• {DATE} = current date - -• {TIME} = current time - -• {WEEKDAY} = week day - -• {MONTH} = current month - -• {YEAR} = current year - -• {UNIX} = seconds since 1970/1/1 - -optional if configuration allow external api: - -Syntax: FIAT{SYMBOL:OPTION} - -• {BTC} {ETH} {BNB} {SOL} {XRP} {DOGE} {TON} {ADA} ... {XMR} = crypto price, avaiable any top2000 crypto symbol - -• {TOP1} {TOP2} ... {TOP2000} = get crypto symbol at specific classific height (max 2000) ({TOP1} will translate to "BTC", so {{TOP1}} is the same of {BTC} and will give you the crypto price) - -• Options: CAP(capitalization), VOL(24h volume), SUPPLY, RANK(cap classific), NAME, EXPLORER. (example: {BTC:CAP}) - -• Convert from default to specific currency: ${number}, €{number}, £{number}, CHF{number} or ₣{number}. - -• Examples: {BNB}, €{BTC}, CHF{ETH}, £{BTC:CAP}, {XMR:SUPPLY}, €{{TOP15}} £{{TOP3}:NAME} - -• Api: https://api.coincap.io/v2/assets (https://docs.coincap.io/) - - - - - -## setChatBasedPunish.js - ->Depends on api/utils/utils.js ->Depends on api/setTime.js - -A settings panel to edit LGHChatBasedPunish object (avaiable on GHbot.js) - - - - - -## usersHandler.js - ->Depends on api/rolesManager.js ->Depends on api/utils/utils.js - -Adds on global.roles[roleName] data about pre-made roles: founder, moderator, muter, cleaner, helper, free. - -This plugin is made for automatic handling of secondary works about users on chats that's not needed to stay on main.js - -Added commands: /reload, /staff, /info, /perms, /forgot - - - - - -## promote.js - ->Depends on api/rolesManager.js ->Depends on api/utils/utils.js - -Handle promotions and unpromotions commands, allow also to edit single admin perms - -Added commands: /free, /unfree, /helper, /unhelper, /cleaner, /uncleaner, /muter, /unmuter, /mod, /unmod, /cofounder, /uncofounder, /admin, /unadmin, /title, /untitle - - - - - -## punish.js - ->Depends on api/punishments.js ->Depends on api/utils/utils.js - -Handle punish and unpunish commands - -Added commands: /delete, /warn, /unwarn, /kick, /mute, /unmute, /ban, /unban - - - - - -## Settings Plugin - ->Depends on api/utils/utils.js - -Manage settings for single users and settings panel for chats, lang setting is included - -Added commands: /settings - - - - -## CommandsPerms.js - ->Depends on api/utils/utils.js - -A menu to change basic commands permissions for every on group or admins, in future will allow to change perms for roles - - - - - -## Rules Plugin - ->Depends on api/MessageMaker.js ->Depends on api/utils/utils.js - -Module to add rules of the group and allow to edit these trough settings - -Added commands: /rules - -Adds on chat.rules a custom object "customMessage" (Message Maker) - -Note: if format is false or entities unavaiable set message parse_mode to HTML (User should see changing format as switching betheen HTML and Formatted) - - - - - -## Welcome Plugin - ->Depends on api/MessageMaker.js ->Depends on api/utils/utils.js - -Module to allow set up a welcome message for new users in the group - -Adds on chat.welcome a custom object "LGHWelcome" - -LGHWelcome Object: - ->state : true if welcome is enabled (default false) -> ->once : true if should be sent only at first user join (default false) -> ->clean : true if last welcome message on the group should be (default false) -> ->joinList : array cronology of users that joined the group over time -> ->lastWelcomeId : messageId of last welcome message sent, useful if clean is enabled, false if never sent one before -> ->message : customMessage object - - - - - -## Anti-Flood Plugin - ->Depends on api/rolesManager.js ->Depends on api/utils/utils.js ->Depends on api/setNum.js ->Depends on api/setTime.js - -Adds on chat.flood a custom object "LGHFlood" - -LGHFlood Object: - ->messages: number of messages needed to triggher the Antiflood -> ->time: seconds within the specified message should be sent to triggher the Antiflood -> ->punishment: punishment to apply at the user that trigghers the Antiflood [0:off|1:warn|2:kick|3:mute|4:ban] -> ->PTime: avaiable if punishment is set to warn/mute/ban, contains seconds of punishment -> ->delete: true if flooded messages should be deleted - - - - - -## Anti-Spam Plugin - ->Depends on api/punishment.js ->Depends on api/utils/utils.js ->Depends on api/setNum.js ->Depends on api/setExceptions.js ->Depends on api/setChatBasedPunishment.js ->Depends on api/rolesManager.js - -Adds on chat.flood a custom object "LGHSpam" - -LGHSpam Object: - ->tgLinks: rules and exceptions for telegram links considered as spam -> ->links: rules and exceptions for all links considered as spam -> ->forward: rules and exceptions for all forwarded messages considered as spam -> ->quote: rules and exceptions for all quoted messages considered as spam - - - - - -## Captcha Plugin - ->Depends on api/punishment.js ->Depends on api/utils/utils.js ->Depends on api/setTime.js ->Depends on api/MessageMaker.js ->Depends on svg-captcha ->Depends on canvas ->Depends on canvg ->Depends on @xmldom/xmldom ->Depends on node-fetch - -Adds on chat.captcha a custom object "LGHCaptcha" - -LGHSpam Object: - ->state: True if welcome is enabled (default false). -> ->mode: Type of captcha, can be "image" (default "image") -> ->time: Time limit to solve the captcha -> ->once: True if should be sent only at first user join (from welcome.js) (default false). -> ->fails: True if captcha should notify on group that someone failed the captcha (default false). -> ->punishment: Punishment to apply [1:warn|2:kick|3:mute|4:ban]. -> ->PTime: Available if punishment is set to warn/mute/ban, contains seconds of punishment - - - - - -## Goodbye Plugin - ->Depends on api/MessageMaker.js - -Adds on chat.goodbye a custom object "LGHGoodbye" - -LGHSpam Object: - ->group: True if goodbye should be sent on group -> ->clear: True if last goodbye message should be deleted before sending a new one -> ->lastId: messageId of last goodbye message sent on group -> ->gMsg: Goodbye message to send on group -> ->private: True if goodbye should be sent on private chat -> ->pMsg: Goodbye message to send on private chat - - - - - -## warns.js - ->Depends on api/utils/utils.js ->Depends on api/setNum.js ->Depends on api/setTime.js - -Allow you to change warn settings on a group - -chat.warns Warns Object: - ->timed: ([userId]: [endTime, endTime, endTime]) contains necerray data to revoke scheduled warns when time is over -> ->count: ([userId]: number) countains count of warns for each user -> ->limit: number of warns after wich should be applyed a punishment -> ->punishment: punishment when limit is hit [2:kick|3:mute|4:ban] -> ->PTime: avaiable if punishment is set to warn/mute/ban, contains seconds of punishment - - - - - -## pin.js - ->Depends on api/utils/utils.js - -Adds /pin command and handle all related things diff --git a/runDocs.js b/runDocs.js new file mode 100644 index 0000000..18742ea --- /dev/null +++ b/runDocs.js @@ -0,0 +1,24 @@ +const fs = require('fs'); +const jsdoc2md = require('jsdoc-to-markdown'); + +const data = fs.readFileSync("./GHbot.js", "utf-8").replaceAll("&","|"); +const docs = jsdoc2md.renderSync({source: data, "no-cache": true}) +.replaceAll("TelegramBot", "[TelegramBot](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/api.md)") +.replaceAll(`TelegramBot.`, `TelegramBot.`) + +const head = +`## TelegramBot api + +You can finnd documentation about TelegramBot Objects on [telegram-bot-api](https://github.com/yagop/node-telegram-bot-api/blob/master/doc/api.md) github + +--- + +The down below lines are generated with [jsdoc2md](https://github.com/jsdoc2md/jsdoc-to-markdown) + + +` + +fs.writeFileSync("./docs/documentation/GHBot.md", head+docs) + +console.log("JSDoc to Markdown successfull, now run `mkdocs serve`\n"+ + "Install guide for mkdocs: https://www.mkdocs.org/user-guide/installation/")