PlainTL
A plain telegram listener based on GramJS
Installation
# npm
npm i plaintl
# yarn
yarn add plaintl
// esm
import { startSession, eventEmitter } from "plaintl"
// cjs
const { startSession, eventEmitter } = require("plaintl")
Usage
Listen to Requires
events and then submit your values with emitter functions. (only for the first session)
eventEmitter
.on("RequiresPhoneNumber", (phoneNumberEmitter) => {
phoneNumberEmitter("+989990009999")
})
.on("RequiresPhoneCode", (phoneCodeEmitter) => {
phoneCodeEmitter("550055")
})
.on("RequiresPassword", (passwordEmitter) => {
passwordEmitter("password")
})
.on("RequiresFirstAndLastNames", (firstAndLastNamesEmitter) => {
firstAndLastNamesEmitter("firstname", "lastname")
})
Preparing provider parameters.
Obtain
apiId
andapiHash
from here.
For receive phone code via SMS set
forceSMS
to true.
For
logLevel
, one can select between error , warn , info , debug or none.
const providerParameters = {
/* required */
apiId: "your-api-id",
apiHash: "your-api-hash",
/* optional */
forceSMS: false,
logLevel: "info",
}
Start PlainTL
session.
// async
const client = await startSession(providerParameters)
// sync
startSession(providerParameters).then((client) => {
//
})
Listen to Telegram
Update events.
eventEmitter.on("UpdateShortMessage", (event) => {
console.log(event)
})
Cli
# npm
npx plaintl
# github
npx github:dalirnet/plaintl
Limitation
- Not browser-compatible.
Update events
- UpdateWebPage
- UpdateUserTyping
- UpdateUserStatus
- UpdateUserPhoto
- UpdateUserPhone
- UpdateUserName
- UpdateTheme
- UpdatesTooLong
- UpdateStickerSetsOrder
- UpdateStickerSets
- UpdateShortSentMessage
- UpdateShortMessage
- UpdateShortChatMessage
- UpdateShort
- UpdateServiceNotification
- UpdatesCombined
- UpdateSavedGifs
- Updates
- UpdateRecentStickers
- UpdateReadMessagesContents
- UpdateReadHistoryOutbox
- UpdateReadHistoryInbox
- UpdateReadFeaturedStickers
- UpdateReadChannelOutbox
- UpdateReadChannelInbox
- UpdateReadChannelDiscussionOutbox
- UpdateReadChannelDiscussionInbox
- UpdatePtsChanged
- UpdatePrivacy
- UpdatePinnedMessages
- UpdatePinnedDialogs
- UpdatePinnedChannelMessages
- UpdatePhoneCallSignalingData
- UpdatePhoneCall
- UpdatePendingJoinRequests
- UpdatePeerSettings
- UpdatePeerLocated
- UpdatePeerHistoryTTL
- UpdatePeerBlocked
- UpdateNotifySettings
- UpdateNewStickerSet
- UpdateNewScheduledMessage
- UpdateNewMessage
- UpdateNewEncryptedMessage
- UpdateNewChannelMessage
- UpdateMessageReactions
- UpdateMessagePollVote
- UpdateMessagePoll
- UpdateMessageID
- UpdateLoginToken
- UpdateLangPackTooLong
- UpdateLangPack
- UpdateInlineBotCallbackQuery
- UpdateGroupCallParticipants
- UpdateGroupCallConnection
- UpdateGroupCall
- UpdateGeoLiveViewed
- UpdateFolderPeers
- UpdateFavedStickers
- UpdateEncryption
- UpdateEncryptedMessagesRead
- UpdateEncryptedChatTyping
- UpdateEditMessage
- UpdateEditChannelMessage
- UpdateDraftMessage
- UpdateDialogUnreadMark
- UpdateDialogPinned
- UpdateDialogFilters
- UpdateDialogFilterOrder
- UpdateDialogFilter
- UpdateDeleteScheduledMessages
- UpdateDeleteMessages
- UpdateDeleteChannelMessages
- UpdateDcOptions
- UpdateContactsReset
- UpdateConfig
- UpdateChatUserTyping
- UpdateChatParticipants
- UpdateChatParticipantDelete
- UpdateChatParticipantAdmin
- UpdateChatParticipantAdd
- UpdateChatParticipant
- UpdateChatDefaultBannedRights
- UpdateChat
- UpdateChannelWebPage
- UpdateChannelUserTyping
- UpdateChannelTooLong
- UpdateChannelReadMessagesContents
- UpdateChannelParticipant
- UpdateChannelMessageViews
- UpdateChannelMessageForwards
- UpdateChannelAvailableMessages
- UpdateChannel
- UpdateBotWebhookJSONQuery
- UpdateBotWebhookJSON
- UpdateBotStopped
- UpdateBotShippingQuery
- UpdateBotPrecheckoutQuery
- UpdateBotInlineSend
- UpdateBotInlineQuery
- UpdateBotCommands
- UpdateBotChatInviteRequester
- UpdateBotCallbackQuery