Skip to content

Objects

TelegramBot api

You can finnd documentation about TelegramBot Objects on telegram-bot-api github


The down below lines are generated with jsdoc2md

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

new LGHInterface(LibreGHelp)

Param Type Description
LibreGHelp LibreGHelp Libre Group Help telegram bot handler

lghInterface.GHbot : LGHInterface

Kind: instance property of LGHInterface

lghInterface.TGbot : TelegramBot

Kind: instance property of LGHInterface

lghInterface.db : LGHDatabase

Kind: instance property of LGHInterface

lghInterface.config : Object

Kind: instance property of LGHInterface

lghInterface.onMessage(handler)

LGHbot message event handler

Kind: instance method of LGHInterface

Param Type Description
handler function handler function

lghInterface.onEditedMessage(handler)

LGHbot edited_message event handler

Kind: instance method of LGHInterface

Param Type Description
handler function handler function

lghInterface.onEditedMessageText(handler)

LGHbot edited_message event handler

Kind: instance method of LGHInterface

Param Type Description
handler function handler function

lghInterface.onCallback(handler)

LGHbot callback_query event handler

Kind: instance method of 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
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
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
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
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
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
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
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
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

Kind: global function
Returns: 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 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 Punish to apply for channels.
groups LGHPunish Punish to apply for groups.
users LGHPunish Punish to apply for users.
bots 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 Punish to apply for messages containing arabic characters.
cyrillic LGHPunish Punish to apply for messages containing cyrillic (russian) characters.
chinese LGHPunish Punish to apply for messages containing chinese characters.
latin 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 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 Active if this user can't receive any punishment (kick/warn/mute/ban) [1/0/-1].
flood PermissionStatus Permission to flood messages [1/0/-1].
link PermissionStatus Permission to send links [1/0/-1].
tgLink PermissionStatus Permission to send telegram links/usernames [1/0/-1].
forward PermissionStatus Permission to forward messages from anywhere [1/0/-1].
quote PermissionStatus Permission to quote from anywhere [1/0/-1].
porn PermissionStatus Bypass porn/gore checks [1/0/-1].
night PermissionStatus Bypass any night mode limitation [1/0/-1].
media PermissionStatus Bypass any media limitation [1/0/-1].
alphabets PermissionStatus Bypass any alphabets characters limitations [1/0/-1].
words PermissionStatus Bypass banned words limitations [1/0/-1].
length PermissionStatus Bypass message length limitations [1/0/-1].
roles PermissionStatus Permission to change roles of lower level users [1/0/-1].
settings 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 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 Basic anonymized user object
status TelegramBot.ChatMemberStatus

LGHAdmin : TelegramBot.ChatAdministratorRights | LGHAdminAdds

Kind: global typedef

LGHAdminList : Array.<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 object for all user-specific permissions
adminPerms 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 | 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 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 | 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"

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.

antispam.js settings about Links Object.

Kind: global typedef

LGHSpamForward : LGHChatBasedPunish

antispam.js settings about foward.

Kind: global typedef

LGHSpamQuote : LGHChatBasedPunish

antispam.js settings about quote.

Kind: global typedef

LGHSpam : Object

antispam.js settings Object.

Kind: global typedef
Properties

Name Type Description
tgLinks LGHSpamTgLinks rules and exceptions for telegram links considered as spam
links LGHSpamLinks rules and exceptions for all links considered as spam
forward LGHSpamForward rules and exceptions for all forwarded messages considered as spam
quote 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 Goodbye message to send on group
private Boolean True if goodbye should be sent on private chat
pMsg 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 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 | undefined
video LGHPunish | undefined
album LGHPunish | undefined
gif LGHPunish | undefined
voice LGHPunish | undefined
audio LGHPunish | undefined
sticker LGHPunish | undefined
sticker_video LGHPunish | undefined
dice LGHPunish | undefined
emoji_video LGHPunish | undefined
emoji_premium LGHPunish | undefined
video_note LGHPunish | undefined
file LGHPunish | undefined
game LGHPunish | undefined
contact LGHPunish | undefined
poll LGHPunish | undefined
location LGHPunish | undefined
capital LGHPunish | undefined
payment LGHPunish | undefined
via_bot LGHPunish | undefined
story LGHPunish | undefined
spoiler LGHPunish | undefined
spoiler_media LGHPunish | undefined
giveaway LGHPunish | undefined
mention LGHPunish | undefined
text_mention LGHPunish | undefined
hashtag LGHPunish | undefined
cashtag LGHPunish | undefined
command LGHPunish | undefined
url LGHPunish | undefined
email LGHPunish | undefined
number LGHPunish | undefined
bold LGHPunish | undefined
italic LGHPunish | undefined
underline LGHPunish | undefined
striketrough LGHPunish | undefined
quoteblock LGHPunish | undefined
closed_blockquote LGHPunish | undefined
code LGHPunish | undefined
pre_code LGHPunish | undefined
textlink LGHPunish | undefined
scheduled LGHPunish | undefined
effect LGHPunish | undefined

CustomChat : Object

Additional chat elements for chat object by LibreGroupHelp

Kind: global typedef
Properties

Name Type Description
admins 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 base permissions applyed to every user
adminPerms LGHPerms base permissions applyed to admin
warns LGHWarns | null warns.js plugin related data
rules customMessage | null rules.js plugin related data
welcome LGHWelcome | null welcome.js plugin related data
flood LGHFlood | null antiflood.js plugin related data
spam LGHSpam | null antispam.js plugin related data
captcha LGHCaptcha | null captcha.js plugin related data
goodbye LGHGoodbye | null goodbye.js plugin related data
alphabets LGHAlphabetBasedPunish | null alphabets.js plugin related data
media LGHMedia | null media.js plugin related data

LGHChat : TelegramBot.Chat | 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 | 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

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 | 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 Always original chat object where the message is coming from
command ParsedCommand | CustomCommand result of message text parsed with parseCommand()
target 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 | null Optional temporary object with data about a target LGH user, false if no target found

LGHMessage : TelegramBot.Message | 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 Always original chat object where the callback is coming from
target TargetUser Optional temporary object with data about a target LGH user in the command, false if no target found

LGHCallback : TelegramBot.CallbackQuery | 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 Object containing chat-related database functions.
users 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 Public interface for LGH Functions
TGbot TelegramBot Raw telegram bot api
db LGHDatabase Database interface