code stringlengths 24 2.07M | docstring stringlengths 25 85.3k | func_name stringlengths 1 92 | language stringclasses 1
value | repo stringlengths 5 64 | path stringlengths 4 172 | url stringlengths 44 218 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
getStickerSet(name, form = {}) {
form.name = name;
return this._request('getStickerSet', { form });
} | Use this method to get a sticker set.
@param {String} name Name of the sticker set
@param {Object} [options] Additional Telegram query options
@return {Promise} On success, a [StickerSet](https://core.telegram.org/bots/api#stickerset) object is returned
@see https://core.telegram.org/bots/api#getstickerset | getStickerSet | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
getCustomEmojiStickers(customEmojiIds, form = {}) {
form.custom_emoji_ids = stringify(customEmojiIds);
return this._request('getCustomEmojiStickers', { form });
} | Use this method to get information about custom emoji stickers by their identifiers.
@param {Array} custom_emoji_ids List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified.
@param {Object} [options] Additional Telegram query options
@return {Promise} Array of [Sticker](https://core.tel... | getCustomEmojiStickers | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
uploadStickerFile(userId, sticker, stickerFormat = 'static', options = {}, fileOptions = {}) {
const opts = {
qs: options,
};
opts.qs.user_id = userId;
opts.qs.sticker_format = stickerFormat;
try {
const sendData = this._formatSendData('sticker', sticker, fileOptions);
opts.formDa... | Use this method to upload a file with a sticker for later use in *createNewStickerSet* and *addStickerToSet* methods (can be used multiple
times).
@param {Number} userId User identifier of sticker file owner
@param {String|stream.Stream|Buffer} sticker A file path or a Stream with the sticker in .WEBP, .PNG, .TGS, or ... | uploadStickerFile | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
createNewStickerSet(userId, name, title, pngSticker, emojis, options = {}, fileOptions = {}) {
const opts = {
qs: options,
};
opts.qs.user_id = userId;
opts.qs.name = name;
opts.qs.title = title;
opts.qs.emojis = emojis;
opts.qs.mask_position = stringify(options.mask_position);
try... | Use this method to create new sticker set owned by a user.
The bot will be able to edit the created sticker set.
You must use exactly one of the fields *png_sticker*, *tgs_sticker*, or *webm_sticker*
@param {Number} userId User identifier of created sticker set owner
@param {String} name Short name of sticker set, t... | createNewStickerSet | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
addStickerToSet(userId, name, sticker, emojis, stickerType = 'png_sticker', options = {}, fileOptions = {}) {
const opts = {
qs: options,
};
opts.qs.user_id = userId;
opts.qs.name = name;
opts.qs.emojis = emojis;
opts.qs.mask_position = stringify(options.mask_position);
if (typeof sti... | Use this method to add a new sticker to a set created by the bot.
You must use exactly one of the fields *png_sticker*, *tgs_sticker*, or *webm_sticker*
Animated stickers can be added to animated sticker sets and only to them
Note:
- Emoji sticker sets can have up to 200 sticker
- Static or Animated sticker sets can... | addStickerToSet | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
setStickerPositionInSet(sticker, position, form = {}) {
form.sticker = sticker;
form.position = position;
return this._request('setStickerPositionInSet', { form });
} | Use this method to move a sticker in a set created by the bot to a specific position.
@param {String} sticker File identifier of the sticker
@param {Number} position New sticker position in the set, zero-based
@param {Object} [options] Additional Telegram query options
@return {Promise} True on success
@see https://co... | setStickerPositionInSet | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
deleteStickerFromSet(sticker, form = {}) {
form.sticker = sticker;
return this._request('deleteStickerFromSet', { form });
} | Use this method to delete a sticker from a set created by the bot.
@param {String} sticker File identifier of the sticker
@param {Object} [options] Additional Telegram query options
@return {Promise} True on success
@see https://core.telegram.org/bots/api#deletestickerfromset
@todo Add tests for this method! | deleteStickerFromSet | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
replaceStickerInSet(userId, name, oldSticker, form = {}) {
form.user_id = userId;
form.name = name;
form.old_sticker = oldSticker;
return this._request('deleteStickerFromSet', { form });
} | Use this method to replace an existing sticker in a sticker set with a new one
@param {Number} user_id User identifier of the sticker set owner
@param {String} name Sticker set name
@param {String} sticker File identifier of the sticker
@param {Object} [options] Additional Telegram query options
@return {Promise} True... | replaceStickerInSet | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
setStickerEmojiList(sticker, emojiList, form = {}) {
form.sticker = sticker;
form.emoji_list = stringify(emojiList);
return this._request('setStickerEmojiList', { form });
} | Use this method to change the list of emoji assigned to a regular or custom emoji sticker.
The sticker must belong to a sticker set created by the bot.
@param {String} sticker File identifier of the sticker
@param { Array } emojiList A JSON-serialized list of 1-20 emoji associated with the sticker
@param {Object} [op... | setStickerEmojiList | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
setStickerKeywords(sticker, form = {}) {
form.sticker = sticker;
if (form.keywords) {
form.keywords = stringify(form.keywords);
}
return this._request('setStickerKeywords', { form });
} | Use this method to change the list of emoji assigned to a `regular` or `custom emoji` sticker.
The sticker must belong to a sticker set created by the bot.
@param {String} sticker File identifier of the sticker
@param {Object} [options] Additional Telegram query options
@return {Promise} True on success
@see https://... | setStickerKeywords | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
setStickerMaskPosition(sticker, form = {}) {
form.sticker = sticker;
if (form.mask_position) {
form.mask_position = stringify(form.mask_position);
}
return this._request('setStickerMaskPosition', { form });
} | Use this method to change the [mask position](https://core.telegram.org/bots/api#maskposition) of a mask sticker.
The sticker must belong to a sticker set created by the bot.
@param {String} sticker File identifier of the sticker
@param {Object} [options] Additional Telegram query options
@return {Promise} True on su... | setStickerMaskPosition | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
setStickerSetTitle(name, title, form = {}) {
form.name = name;
form.title = title;
return this._request('setStickerSetTitle', { form });
} | Use this method to set the title of a created sticker set.
The sticker must belong to a sticker set created by the bot.
@param {String} name Sticker set name
@param {String} title Sticker set title, 1-64 characters
@param {Object} [options] Additional Telegram query options
@return {Promise} True on success
@see http... | setStickerSetTitle | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
setStickerSetThumbnail(userId, name, thumbnail, options = {}, fileOptions = {}) {
const opts = {
qs: options,
};
opts.qs.user_id = userId;
opts.qs.name = name;
opts.qs.mask_position = stringify(options.mask_position);
try {
const sendData = this._formatSendData('thumbnail', thumbnail... | Use this method to add a thumb to a set created by the bot.
Animated thumbnails can be set for animated sticker sets only. Video thumbnails can be set only for video sticker sets only
@param {Number} userId User identifier of sticker set owner
@param {String} name Sticker set name
@param {String|stream.Stream|Buffer}... | setStickerSetThumbnail | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
setCustomEmojiStickerSetThumbnail(name, form = {}) {
form.name = name;
return this._request('setCustomEmojiStickerSetThumbnail', { form });
} | Use this method to set the thumbnail of a custom emoji sticker set.
The sticker must belong to a sticker set created by the bot.
@param {String} name Sticker set name
@param {Object} [options] Additional Telegram query options
@return {Promise} True on success
@see https://core.telegram.org/bots/api#setcustomemojisti... | setCustomEmojiStickerSetThumbnail | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
deleteStickerSet(name, form = {}) {
form.name = name;
return this._request('deleteStickerSet', { form });
} | Use this method to delete a sticker set that was created by the bot.
The sticker must belong to a sticker set created by the bot.
@param {String} name Sticker set name
@param {Object} [options] Additional Telegram query options
@return {Promise} True on success
@see https://core.telegram.org/bots/api#deletestickerset | deleteStickerSet | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
answerInlineQuery(inlineQueryId, results, form = {}) {
form.inline_query_id = inlineQueryId;
form.results = stringify(results);
return this._request('answerInlineQuery', { form });
} | Send answers to an inline query.
Note: No more than 50 results per query are allowed.
@param {String} inlineQueryId Unique identifier of the query
@param {InlineQueryResult[]} results An array of results for the inline query
@param {Object} [options] Additional Telegram query options
@return {Promise} On success, Tru... | answerInlineQuery | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
answerWebAppQuery(webAppQueryId, result, form = {}) {
form.web_app_query_id = webAppQueryId;
form.result = stringify(result);
return this._request('answerWebAppQuery', { form });
} | Use this method to set the result of an interaction with a [Web App](https://core.telegram.org/bots/webapps)
and send a corresponding message on behalf of the user to the chat from which the query originated.
@param {String} webAppQueryId Unique identifier for the query to be answered
@param {InlineQueryResult} result... | answerWebAppQuery | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
sendInvoice(chatId, title, description, payload, providerToken, currency, prices, form = {}) {
form.chat_id = chatId;
form.title = title;
form.description = description;
form.payload = payload;
form.provider_token = providerToken;
form.currency = currency;
form.prices = stringify(prices);
... | Use this method to send an invoice.
@param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
@param {String} title Product name, 1-32 characters
@param {String} description Product description, 1-255 characters
@param {String} payload Bot... | sendInvoice | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
createInvoiceLink(title, description, payload, providerToken, currency, prices, form = {}) {
form.title = title;
form.description = description;
form.payload = payload;
form.provider_token = providerToken;
form.currency = currency;
form.prices = stringify(prices);
return this._request('creat... | Use this method to create a link for an invoice.
@param {String} title Product name, 1-32 characters
@param {String} description Product description, 1-255 characters
@param {String} payload Bot defined invoice payload
@param {String} providerToken Payment provider token
@param {String} currency Three-letter ISO 4217 ... | createInvoiceLink | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
answerShippingQuery(shippingQueryId, ok, form = {}) {
form.shipping_query_id = shippingQueryId;
form.ok = ok;
form.shipping_options = stringify(form.shipping_options);
return this._request('answerShippingQuery', { form });
} | Use this method to reply to shipping queries.
If you sent an invoice requesting a shipping address and the parameter is_flexible was specified,
the Bot API will send an [Update](https://core.telegram.org/bots/api#update) with a shipping_query field to the bot
@param {String} shippingQueryId Unique identifier for the... | answerShippingQuery | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
answerPreCheckoutQuery(preCheckoutQueryId, ok, form = {}) {
form.pre_checkout_query_id = preCheckoutQueryId;
form.ok = ok;
return this._request('answerPreCheckoutQuery', { form });
} | Use this method to respond to such pre-checkout queries
Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of
an [Update](https://core.telegram.org/bots/api#update) with the field *pre_checkout_query*.
**Note:** The Bot API must receive an answer withi... | answerPreCheckoutQuery | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
getStarTransactions(form = {}) {
return this._request('getStarTransactions', { form });
} | Use this method for get the bot's Telegram Star transactions in chronological order
@param {Object} [options] Additional Telegram query options
@return {Promise} On success, returns a [StarTransactions](https://core.telegram.org/bots/api#startransactions) object
@see https://core.telegram.org/bots/api#getstartransacti... | getStarTransactions | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
refundStarPayment(userId, telegramPaymentChargeId, form = {}) {
form.user_id = userId;
form.telegram_payment_charge_id = telegramPaymentChargeId;
return this._request('refundStarPayment', { form });
} | Use this method for refund a successful payment in [Telegram Stars](https://t.me/BotNews/90)
@param {Number} userId Unique identifier of the user whose payment will be refunded
@param {String} telegramPaymentChargeId Telegram payment identifier
@param {Object} [options] Additional Telegram query options
@return {Prom... | refundStarPayment | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
editUserStarSubscription(userId, telegramPaymentChargeId, isCanceled, form = {}) {
form.user_id = userId;
form.telegram_payment_charge_id = telegramPaymentChargeId;
form.is_canceled = isCanceled;
return this._request('editUserStarSubscription', { form });
} | Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars.
@param {Number} userId Unique identifier of the user whose subscription will be canceled or re-enabled
@param {String} telegramPaymentChargeId Telegram payment identifier for the subscription
@param {Boolean} isCanceled True, if ... | editUserStarSubscription | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
sendGame(chatId, gameShortName, form = {}) {
form.chat_id = chatId;
form.game_short_name = gameShortName;
return this._request('sendGame', { form });
} | Use this method to send a game.
@param {Number|String} chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
@param {String} gameShortName name of the game to be sent. Set up your games via `@BotFather`.
@param {Object} [options] Additional Telegram query opt... | sendGame | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
setGameScore(userId, score, form = {}) {
form.user_id = userId;
form.score = score;
return this._request('setGameScore', { form });
} | Use this method to set the score of the specified user in a game message.
@param {Number} userId Unique identifier of the target user
@param {Number} score New score value, must be non-negative
@param {Object} [options] Additional Telegram query options
@return {Promise} On success, if the message is not an inline me... | setGameScore | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
getGameHighScores(userId, form = {}) {
form.user_id = userId;
return this._request('getGameHighScores', { form });
} | Use this method to get data for high score tables.
Will return the score of the specified user and several of their neighbors in a game.
@param {Number} userId Unique identifier of the target user
@param {Object} [options] Additional Telegram query options
@return {Promise} On success, returns an Array of [GameHighS... | getGameHighScores | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
getAvailableGifts(form = {}) {
return this._request('getAvailableGifts', { form });
} | Use this method to returns the list of gifts that can be sent by the bot to users and channel chats.
@param {Object} [options] Additional Telegram query options.
@return {Promise} On success, returns a [Gifts](https://core.telegram.org/bots/api#gifts) objects.
@see https://core.telegram.org/bots/api#getavailablegifts | getAvailableGifts | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
sendGift(giftId, form = {}) {
form.gift_id = giftId;
return this._request('sendGift', { form });
} | Use this method to sends a gift to the given user or channel chat.
@param {String} giftId Unique identifier of the gift
@param {Object} [options] Additional Telegram query options.
@return {Promise} On success, returns true.
@see https://core.telegram.org/bots/api#getavailablegifts | sendGift | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
giftPremiumSubscription(userId, monthCount, starCount, form = {}) {
form.user_id = userId;
form.month_count = monthCount;
form.star_count = starCount;
return this._request('giftPremiumSubscription', { form });
} | Use this method to sends a gift to the given user or channel chat.
@param {Number} userId Unique identifier of the target user who will receive a Telegram Premium subscription.
@param {Number} monthCount Number of months the Telegram Premium subscription will be active for the user; must be one of 3, 6, or 12.
@param ... | giftPremiumSubscription | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
verifyUser(userId, form = {}) {
form.user_id = userId;
return this._request('verifyUser', { form });
} | This method verifies a user [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot.
@param {Number} userId Unique identifier of the target user.
@param {Object} [options] Additional Telegram query options.
@return {Promise} On success, returns true.
@see h... | verifyUser | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
verifyChat(chatId, form = {}) {
form.chat_id = chatId;
return this._request('verifyChat', { form });
} | This method verifies a chat [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot.
@param {Number} chatId Unique identifier of the target chat.
@return {Promise} On success, returns true.
@param {Object} [options] Additional Telegram query options.
@see h... | verifyChat | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
removeUserVerification(userId, form = {}) {
form.user_id = userId;
return this._request('removeUserVerification', { form });
} | This method removes verification from a user who is currently verified [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot.
@param {Number} userId Unique identifier of the target user
@param {Object} [options] Additional Telegram query options
@return {... | removeUserVerification | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
removeChatVerification(chatId, form = {}) {
form.chat_id = chatId;
return this._request('removeChatVerification', { form });
} | This method removes verification from a chat who is currently verified [on behalf of the organization](https://telegram.org/verify#third-party-verification) which is represented by the bot.
@param {Number} chatId Unique identifier of the target chat.
@param {Object} [options] Additional Telegram query options.
@return... | removeChatVerification | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
readBusinessMessage(businessConnectionId, chatId, messageId, form = {}) {
form.business_connection_id = businessConnectionId;
form.chat_id = chatId;
form.message_id = messageId;
return this._request('readBusinessMessage', { form });
} | This method marks incoming message as read on behalf of a business account.
Requires the **can_read_messages** business bot right
@param {String} businessConnectionId Unique identifier of the business connection on behalf of which to read the message.
@param {Number} chatId Unique identifier of the chat in which the ... | readBusinessMessage | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
deleteBusinessMessages(businessConnectionId, messageIds, form = {}) {
form.business_connection_id = businessConnectionId;
form.message_ids = stringify(messageIds);
return this._request('deleteBusinessMessages', { form });
} | This method delete messages on behalf of a business account.
Requires the **can_delete_outgoing_messages** business bot right to delete messages sent by the bot itself, or the **can_delete_all_messages business** bot right to delete any message.
@param {String} businessConnectionId Unique identifier of the business c... | deleteBusinessMessages | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
setBusinessAccountName(businessConnectionId, firstName, form = {}) {
form.business_connection_id = businessConnectionId;
form.first_name = firstName;
return this._request('setBusinessAccountName', { form });
} | This method changes the first and last name of a managed business account.
Requires the **can_change_name** business bot right.
@param {String} businessConnectionId Unique identifier of the business connection.
@param {String} firstName The new value of the first name for the business account; 1-64 characters.
@param... | setBusinessAccountName | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
setBusinessAccountUsername(businessConnectionId, form = {}) {
form.business_connection_id = businessConnectionId;
return this._request('setBusinessAccountUsername', { form });
} | This method changes the username of a managed business account.
Requires the **can_change_username** business bot right.
@param {String} businessConnectionId Unique identifier of the business connection.
@param {Object} [options] Additional Telegram query options
@return {Promise} On success, returns true.
@see https... | setBusinessAccountUsername | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
setBusinessAccountBio(businessConnectionId, form = {}) {
form.business_connection_id = businessConnectionId;
return this._request('setBusinessAccountBio', { form });
} | This method changes the bio of a managed business account.
Requires the **can_change_bio** business bot right.
@param {String} businessConnectionId Unique identifier of the business connection.
@param {Object} [options] Additional Telegram query options
@return {Promise} On success, returns true.
@see https://core.te... | setBusinessAccountBio | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
setBusinessAccountProfilePhoto(businessConnectionId, photo, options = {}) {
const opts = {
qs: options,
};
opts.qs.business_connection_id = businessConnectionId;
try {
const sendData = this._formatSendData('photo', photo);
opts.formData = sendData[0];
opts.qs.photo = sendData[1... | This method changes the profile photo of a managed business account.
Requires the **can_edit_profile_photo** business bot right.
@param {String} businessConnectionId Unique identifier of the business connection.
@param {String|stream.Stream|Buffer} photo New profile photo.
@param {Object} [options] Additional Telegra... | setBusinessAccountProfilePhoto | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
removeBusinessAccountProfilePhoto(businessConnectionId, form = {}) {
form.business_connection_id = businessConnectionId;
return this._request('removeBusinessAccountProfilePhoto', { form });
} | This method removes the current profile photo of a managed business account.
Requires the **can_edit_profile_photo** business bot right.
@param {String} businessConnectionId Unique identifier of the business connection.
@param {Object} [options] Additional Telegram query options
@return {Promise} On success, returns ... | removeBusinessAccountProfilePhoto | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
setBusinessAccountGiftSettings(businessConnectionId, showGiftButton, acceptedGiftTypes, form = {}) {
form.business_connection_id = businessConnectionId;
form.show_gift_button = showGiftButton;
form.accepted_gift_types = acceptedGiftTypes;
return this._request('setBusinessAccountGiftSettings', { form });... | This method changes the privacy settings pertaining to incoming gifts in a managed business account.
Requires the **can_change_gift_settings** business bot right.
@param {String} businessConnectionId Unique identifier of the business connection.
@param {Boolean} showGiftButton Pass True, if a button for sending a gif... | setBusinessAccountGiftSettings | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
getBusinessAccountStarBalance(businessConnectionId, form = {}) {
form.business_connection_id = businessConnectionId;
return this._request('getBusinessAccountStarBalance', { form });
} | This method returns the amount of Telegram Stars owned by a managed business account.
Requires the **can_view_gifts_and_stars** business bot right.
@param {String} businessConnectionId Unique identifier of the business connection.
@param {Object} [options] Additional Telegram query options
@return {Promise} On succes... | getBusinessAccountStarBalance | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
transferBusinessAccountStars(businessConnectionId, startCount, form = {}) {
form.business_connection_id = businessConnectionId;
form.star_count = startCount;
return this._request('transferBusinessAccountStars', { form });
} | This method transfers Telegram Stars from the business account balance to the bot's balance.
Requires the **can_transfer_stars** business bot right.
@param {String} businessConnectionId Unique identifier of the business connection.
@param {Number} starCount Number of Telegram Stars to transfer; 1-10000.
@param {Objec... | transferBusinessAccountStars | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
getBusinessAccountGifts(businessConnectionId, form = {}) {
form.business_connection_id = businessConnectionId;
return this._request('getBusinessAccountGifts', { form });
} | This method returns the gifts received and owned by a managed business account.
Requires the **can_view_gifts_and_stars** business bot right.
@param {String} businessConnectionId Unique identifier of the business connection.
@param {Object} [options] Additional Telegram query options
@return {Promise} On success, ret... | getBusinessAccountGifts | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
convertGiftToStars(businessConnectionId, ownedGiftId, form = {}) {
form.business_connection_id = businessConnectionId;
form.owned_gift_id = ownedGiftId;
return this._request('convertGiftToStars', { form });
} | This method converts a given regular gift to Telegram Stars.
Requires the **can_convert_gifts_to_stars** business bot right.
@param {String} businessConnectionId Unique identifier of the business connection.
@param {String} ownedGiftId Unique identifier of the regular gift that should be converted to Telegram Stars.
... | convertGiftToStars | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
upgradeGift(businessConnectionId, ownedGiftId, form = {}) {
form.business_connection_id = businessConnectionId;
form.owned_gift_id = ownedGiftId;
return this._request('upgradeGift', { form });
} | This method upgrades a given regular gift to a unique gift.
Requires the **can_transfer_and_upgrade_gifts** business bot right.
Additionally requires the **can_transfer_stars** business bot right **if the upgrade is paid**.
@param {String} businessConnectionId Unique identifier of the business connection.
@param {Str... | upgradeGift | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
transferGift(businessConnectionId, ownedGiftId, newOwnerChatId, form = {}) {
form.business_connection_id = businessConnectionId;
form.owned_gift_id = ownedGiftId;
form.new_owner_chat_id = newOwnerChatId;
return this._request('transferGift', { form });
} | This method transfers an owned unique gift to another user.
Requires the **can_transfer_and_upgrade_gifts** business bot right.
Additionally requires the **can_transfer_stars** business bot right **if the transfer is paid**.
@param {String} businessConnectionId Unique identifier of the business connection.
@param {St... | transferGift | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
postStory(businessConnectionId, content, activePeriod, options = {}) {
const opts = {
qs: options,
};
opts.qs.business_connection_id = businessConnectionId;
opts.qs.active_period = activePeriod;
try {
const inputHistoryContent = content;
opts.formData = {};
if (!content.ty... | This method posts a story on behalf of a managed business account.
Requires the **can_manage_stories** business bot right.
@param {String} businessConnectionId Unique identifier of the business connection.
@param {Array} content [InputStoryContent](https://core.telegram.org/bots/api#inputpaidmedia). The photo/video p... | postStory | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
editStory(businessConnectionId, storyId, content, options = {}) {
const opts = {
qs: options,
};
opts.qs.business_connection_id = businessConnectionId;
opts.qs.story_id = storyId;
try {
const inputHistoryContent = content;
opts.formData = {};
if (!content.type) {
r... | This method edits a story previously posted by the bot on behalf of a managed business account.
Requires the **can_manage_stories** business bot right.
@param {String} businessConnectionId Unique identifier of the business connection.
@param {Number} storyId Unique identifier of the story to edit.
@param {Array} cont... | editStory | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
deleteStory(businessConnectionId, storyId, form = {}) {
form.business_connection_id = businessConnectionId;
form.story_id = storyId;
return this._request('deleteStory', { form });
} | This method deletes a story previously posted by the bot on behalf of a managed business account.
Requires the **can_manage_stories** business bot right.
@param {String} businessConnectionId Unique identifier of the business connection.
@param {Number} storyId Unique identifier of the story to delete.
@param {Object}... | deleteStory | javascript | yagop/node-telegram-bot-api | src/telegram.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegram.js | MIT |
constructor(bot) {
this.bot = bot;
this.options = (typeof bot.options.polling === 'boolean') ? {} : bot.options.polling;
this.options.interval = (typeof this.options.interval === 'number') ? this.options.interval : 300;
this.options.params = (typeof this.options.params === 'object') ? this.options.param... | Handles polling against the Telegram servers.
@param {TelegramBot} bot
@see https://core.telegram.org/bots/api#getting-updates | constructor | javascript | yagop/node-telegram-bot-api | src/telegramPolling.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegramPolling.js | MIT |
start(options = {}) {
if (this._lastRequest) {
if (!options.restart) {
return Promise.resolve();
}
return this.stop({
cancel: true,
reason: 'Polling restart',
}).then(() => {
return this._polling();
});
}
return this._polling();
} | Start polling
@param {Object} [options]
@param {Object} [options.restart]
@return {Promise} | start | javascript | yagop/node-telegram-bot-api | src/telegramPolling.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegramPolling.js | MIT |
stop(options = {}) {
if (!this._lastRequest) {
return Promise.resolve();
}
const lastRequest = this._lastRequest;
this._lastRequest = null;
clearTimeout(this._pollingTimeout);
if (options.cancel) {
const reason = options.reason || 'Polling stop';
lastRequest.cancel(reason);
... | Stop polling
@param {Object} [options] Options
@param {Boolean} [options.cancel] Cancel current request
@param {String} [options.reason] Reason for stopping polling
@return {Promise} | stop | javascript | yagop/node-telegram-bot-api | src/telegramPolling.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegramPolling.js | MIT |
isPolling() {
return !!this._lastRequest;
} | Return `true` if is polling. Otherwise, `false`. | isPolling | javascript | yagop/node-telegram-bot-api | src/telegramPolling.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegramPolling.js | MIT |
_error(error) {
if (!this.bot.listeners('polling_error').length) {
return console.error('error: [polling_error] %j', error); // eslint-disable-line no-console
}
return this.bot.emit('polling_error', error);
} | Handle error thrown during polling.
@private
@param {Error} error | _error | javascript | yagop/node-telegram-bot-api | src/telegramPolling.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegramPolling.js | MIT |
_polling() {
this._lastRequest = this
._getUpdates()
.then(updates => {
this._lastUpdate = Date.now();
debug('polling data %j', updates);
updates.forEach(update => {
this.options.params.offset = update.update_id + 1;
debug('updated offset: %s', this.options.pa... | Invokes polling (with recursion!)
@return {Promise} promise of the current request
@private | _polling | javascript | yagop/node-telegram-bot-api | src/telegramPolling.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegramPolling.js | MIT |
_unsetWebHook() {
debug('unsetting webhook');
return this.bot._request('setWebHook');
} | Unset current webhook. Used when we detect that a webhook has been set
and we are trying to poll. Polling and WebHook are mutually exclusive.
@see https://core.telegram.org/bots/api#getting-updates
@private | _unsetWebHook | javascript | yagop/node-telegram-bot-api | src/telegramPolling.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegramPolling.js | MIT |
constructor(bot) {
this.bot = bot;
this.options = (typeof bot.options.webHook === 'boolean') ? {} : bot.options.webHook;
this.options.host = this.options.host || '0.0.0.0';
this.options.port = this.options.port || 8443;
this.options.https = this.options.https || {};
this.options.healthEndpoint =... | Sets up a webhook to receive updates
@param {TelegramBot} bot
@see https://core.telegram.org/bots/api#getting-updates | constructor | javascript | yagop/node-telegram-bot-api | src/telegramWebHook.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegramWebHook.js | MIT |
open() {
if (this.isOpen()) {
return Promise.resolve();
}
return new Promise((resolve, reject) => {
this._webServer.listen(this.options.port, this.options.host, () => {
debug('WebHook listening on port %s', this.options.port);
this._open = true;
return resolve();
})... | Open WebHook by listening on the port
@return {Promise} | open | javascript | yagop/node-telegram-bot-api | src/telegramWebHook.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegramWebHook.js | MIT |
isOpen() {
// NOTE: Since `http.Server.listening` was added in v5.7.0
// and we still need to support Node v4,
// we are going to fallback to 'this._open'.
// The following LOC would suffice for newer versions of Node.js
// return this._webServer.listening;
return this._open;
} | Return `true` if server is listening. Otherwise, `false`. | isOpen | javascript | yagop/node-telegram-bot-api | src/telegramWebHook.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegramWebHook.js | MIT |
_error(error) {
if (!this.bot.listeners('webhook_error').length) {
return console.error('error: [webhook_error] %j', error); // eslint-disable-line no-console
}
return this.bot.emit('webhook_error', error);
} | Handle error thrown during processing of webhook request.
@private
@param {Error} error | _error | javascript | yagop/node-telegram-bot-api | src/telegramWebHook.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegramWebHook.js | MIT |
_parseBody(error, body) {
if (error) {
return this._error(new errors.FatalError(error));
}
let data;
try {
data = JSON.parse(body.toString());
} catch (parseError) {
return this._error(new errors.ParseError(parseError.message));
}
return this.bot.processUpdate(data);
} | Handle request body by passing it to 'callback'
@private | _parseBody | javascript | yagop/node-telegram-bot-api | src/telegramWebHook.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegramWebHook.js | MIT |
_requestListener(req, res) {
debug('WebHook request URL: %s', req.url);
debug('WebHook request headers: %j', req.headers);
if (req.url.indexOf(this.bot.token) !== -1) {
if (req.method !== 'POST') {
debug('WebHook request isn\'t a POST');
res.statusCode = 418; // I'm a teabot!
... | Listener for 'request' event on server
@private
@see https://nodejs.org/docs/latest/api/http.html#http_http_createserver_requestlistener
@see https://nodejs.org/docs/latest/api/https.html#https_https_createserver_options_requestlistener | _requestListener | javascript | yagop/node-telegram-bot-api | src/telegramWebHook.js | https://github.com/yagop/node-telegram-bot-api/blob/master/src/telegramWebHook.js | MIT |
function startMockServer(port, options = {}) {
assert.ok(port);
const server = http.Server((req, res) => {
servers[port].polling = true;
if (options.bad) {
return res.end('can not be parsed with JSON.parse()');
}
return res.end(JSON.stringify({
ok: true,
result: [{
update_i... | Start the static server, serving files in './data'
@param {Number} port | startMockServer | javascript | yagop/node-telegram-bot-api | test/utils.js | https://github.com/yagop/node-telegram-bot-api/blob/master/test/utils.js | MIT |
function startStaticServer(port) {
const fileServer = new statics.Server(`${__dirname}/data`);
http.Server((req, res) => {
req.addListener('end', () => {
fileServer.serve(req, res);
}).resume();
}).listen(port);
} | Start the static server, serving files in './data'
@param {Number} port | startStaticServer | javascript | yagop/node-telegram-bot-api | test/utils.js | https://github.com/yagop/node-telegram-bot-api/blob/master/test/utils.js | MIT |
function isPollingMockServer(port, reverse) {
assert.ok(port);
return new Promise((resolve, reject) => {
// process.nextTick() does not wait until a poll request
// is complete!
setTimeout(() => {
let polling = servers[port] && servers[port].polling;
if (reverse) polling = !polling;
if... | Start the static server, serving files in './data'
@param {Number} port | isPollingMockServer | javascript | yagop/node-telegram-bot-api | test/utils.js | https://github.com/yagop/node-telegram-bot-api/blob/master/test/utils.js | MIT |
function clearPollingCheck(port) {
assert.ok(port);
if (servers[port]) servers[port].polling = false;
} | Start the static server, serving files in './data'
@param {Number} port | clearPollingCheck | javascript | yagop/node-telegram-bot-api | test/utils.js | https://github.com/yagop/node-telegram-bot-api/blob/master/test/utils.js | MIT |
function hasOpenWebHook(port, reverse) {
assert.ok(port);
const error = new Error('open-webhook-check failed');
let connected = false;
return request.get(`http://127.0.0.1:${port}`)
.then(() => {
connected = true;
}).catch(e => {
if (e.statusCode < 500) connected = true;
}).finally(() =>... | Start the static server, serving files in './data'
@param {Number} port | hasOpenWebHook | javascript | yagop/node-telegram-bot-api | test/utils.js | https://github.com/yagop/node-telegram-bot-api/blob/master/test/utils.js | MIT |
function sendWebHookRequest(port, path, options = {}) {
assert.ok(port);
assert.ok(path);
const protocol = options.https ? 'https' : 'http';
const url = `${protocol}://127.0.0.1:${port}${path}`;
return request({
url,
method: options.method || 'POST',
body: options.update || {
update_id: 1,
... | Start the static server, serving files in './data'
@param {Number} port | sendWebHookRequest | javascript | yagop/node-telegram-bot-api | test/utils.js | https://github.com/yagop/node-telegram-bot-api/blob/master/test/utils.js | MIT |
function sendWebHookMessage(port, token, options = {}) {
assert.ok(port);
assert.ok(token);
const path = `/bot${token}`;
return sendWebHookRequest(port, path, options);
} | Start the static server, serving files in './data'
@param {Number} port | sendWebHookMessage | javascript | yagop/node-telegram-bot-api | test/utils.js | https://github.com/yagop/node-telegram-bot-api/blob/master/test/utils.js | MIT |
function handleRatelimit(bot, methodName, suite) {
const backupMethodName = `__${methodName}`;
if (!bot[backupMethodName]) bot[backupMethodName] = bot[methodName];
const maxRetries = 3;
const addSecs = 5;
const method = bot[backupMethodName];
assert.equal(typeof method, 'function');
bot[methodName] = (.... | Start the static server, serving files in './data'
@param {Number} port | handleRatelimit | javascript | yagop/node-telegram-bot-api | test/utils.js | https://github.com/yagop/node-telegram-bot-api/blob/master/test/utils.js | MIT |
function exec() {
return method.call(bot, ...args)
.catch(error => {
if (!error.response || error.response.statusCode !== 429) {
throw error;
}
retry++;
if (retry > maxRetries) {
throw error;
}
if (typeof error.response.bo... | Start the static server, serving files in './data'
@param {Number} port | exec | javascript | yagop/node-telegram-bot-api | test/utils.js | https://github.com/yagop/node-telegram-bot-api/blob/master/test/utils.js | MIT |
function isTelegramFileURI(uri) {
return /https?:\/\/.*\/file\/bot.*\/.*/.test(uri);
} | Start the static server, serving files in './data'
@param {Number} port | isTelegramFileURI | javascript | yagop/node-telegram-bot-api | test/utils.js | https://github.com/yagop/node-telegram-bot-api/blob/master/test/utils.js | MIT |
function optimize(root: ?ASTElement, options: CompilerOptions) {
if (!root) return
isStaticKey = genStaticKeysCached(options.staticKeys || '')
isPlatformReservedTag = options.isReservedTag || no
// first pass: mark all non-static nodes.
markStatic(root)
// second pass: mark static roots.
markStaticRoots(r... | Goal of the optimizer: walk the generated template AST tree
and detect sub-trees that are purely static, i.e. parts of
the DOM that never needs to change.
Once we detect these sub-trees, we can:
1. Hoist them into constants, so that we no longer need to
create fresh nodes for them on each re-render;
2. Completely ... | optimize | javascript | GeekyAnts/vue-native-core | src/compiler/optimizer.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/optimizer.js | MIT |
function genStaticKeys(keys: string): Function {
return makeMap(
'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
(keys ? ',' + keys : ''),
)
} | Goal of the optimizer: walk the generated template AST tree
and detect sub-trees that are purely static, i.e. parts of
the DOM that never needs to change.
Once we detect these sub-trees, we can:
1. Hoist them into constants, so that we no longer need to
create fresh nodes for them on each re-render;
2. Completely ... | genStaticKeys | javascript | GeekyAnts/vue-native-core | src/compiler/optimizer.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/optimizer.js | MIT |
function markStatic(node: ASTNode) {
node.static = isStatic(node)
if (node.type === 1) {
// do not make component slot content static. this avoids
// 1. components not able to mutate slot nodes
// 2. static slot content fails for hot-reloading
if (
!isPlatformReservedTag(node.tag) &&
nod... | Goal of the optimizer: walk the generated template AST tree
and detect sub-trees that are purely static, i.e. parts of
the DOM that never needs to change.
Once we detect these sub-trees, we can:
1. Hoist them into constants, so that we no longer need to
create fresh nodes for them on each re-render;
2. Completely ... | markStatic | javascript | GeekyAnts/vue-native-core | src/compiler/optimizer.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/optimizer.js | MIT |
function markStaticRoots(node: ASTNode, isInFor: boolean) {
if (node.type === 1) {
if (node.static || node.once) {
node.staticInFor = isInFor
}
// For a node to qualify as a static root, it should have children that
// are not just static text. Otherwise the cost of hoisting out will
// outw... | Goal of the optimizer: walk the generated template AST tree
and detect sub-trees that are purely static, i.e. parts of
the DOM that never needs to change.
Once we detect these sub-trees, we can:
1. Hoist them into constants, so that we no longer need to
create fresh nodes for them on each re-render;
2. Completely ... | markStaticRoots | javascript | GeekyAnts/vue-native-core | src/compiler/optimizer.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/optimizer.js | MIT |
function walkThroughConditionsBlocks(
conditionBlocks: ASTIfConditions,
isInFor: boolean,
): void {
for (let i = 1, len = conditionBlocks.length; i < len; i++) {
markStaticRoots(conditionBlocks[i].block, isInFor)
}
} | Goal of the optimizer: walk the generated template AST tree
and detect sub-trees that are purely static, i.e. parts of
the DOM that never needs to change.
Once we detect these sub-trees, we can:
1. Hoist them into constants, so that we no longer need to
create fresh nodes for them on each re-render;
2. Completely ... | walkThroughConditionsBlocks | javascript | GeekyAnts/vue-native-core | src/compiler/optimizer.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/optimizer.js | MIT |
function isStatic(node: ASTNode): boolean {
if (node.type === 2) {
// expression
return false
}
if (node.type === 3) {
// text
return true
}
return !!(
node.pre ||
(!node.hasBindings && // no dynamic bindings
!node.if &&
!node.for && // not v-if or v-for or v-else
!isBuiltI... | Goal of the optimizer: walk the generated template AST tree
and detect sub-trees that are purely static, i.e. parts of
the DOM that never needs to change.
Once we detect these sub-trees, we can:
1. Hoist them into constants, so that we no longer need to
create fresh nodes for them on each re-render;
2. Completely ... | isStatic | javascript | GeekyAnts/vue-native-core | src/compiler/optimizer.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/optimizer.js | MIT |
function isDirectChildOfTemplateFor(node: ASTElement): boolean {
while (node.parent) {
node = node.parent
if (node.tag !== 'template') {
return false
}
if (node.for) {
return true
}
}
return false
} | Goal of the optimizer: walk the generated template AST tree
and detect sub-trees that are purely static, i.e. parts of
the DOM that never needs to change.
Once we detect these sub-trees, we can:
1. Hoist them into constants, so that we no longer need to
create fresh nodes for them on each re-render;
2. Completely ... | isDirectChildOfTemplateFor | javascript | GeekyAnts/vue-native-core | src/compiler/optimizer.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/optimizer.js | MIT |
function genComponentModel(
el: ASTElement,
value: string,
modifiers: ?ASTModifiers,
): ?boolean {
const { number, trim } = modifiers || {}
const baseValueExpression = '$$v'
let valueExpression = baseValueExpression
if (trim) {
valueExpression =
`(typeof ${baseValueExpression} === 'string'` +
... | Cross-platform code generation for component v-model | genComponentModel | javascript | GeekyAnts/vue-native-core | src/compiler/directives/model.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/directives/model.js | MIT |
function genAssignmentCode(value: string, assignment: string): string {
const modelRs = parseModel(value)
if (modelRs.idx === null) {
return `${value}=${assignment}`
} else {
return (
`var $$exp = ${modelRs.exp}, $$idx = ${modelRs.idx};` +
`if (!Array.isArray($$exp)){` +
`${value}=${assi... | Cross-platform codegen helper for generating v-model value assignment code. | genAssignmentCode | javascript | GeekyAnts/vue-native-core | src/compiler/directives/model.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/directives/model.js | MIT |
function parseModel(val: string): Object {
str = val
len = str.length
index = expressionPos = expressionEndPos = 0
if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
return {
exp: val,
idx: null,
}
}
while (!eof()) {
chr = next()
/* istanbul ignore if */
if (isSt... | parse directive model to do the array update transform. a[idx] = val => $$a.splice($$idx, 1, val)
for loop possible cases:
- test
- test[idx]
- test[test1[idx]]
- test["a"][idx]
- xxx.test[a[a].test1[idx]]
- test.xxx.a["asa"][test1[idx]] | parseModel | javascript | GeekyAnts/vue-native-core | src/compiler/directives/model.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/directives/model.js | MIT |
function next(): number {
return str.charCodeAt(++index)
} | parse directive model to do the array update transform. a[idx] = val => $$a.splice($$idx, 1, val)
for loop possible cases:
- test
- test[idx]
- test[test1[idx]]
- test["a"][idx]
- xxx.test[a[a].test1[idx]]
- test.xxx.a["asa"][test1[idx]] | next | javascript | GeekyAnts/vue-native-core | src/compiler/directives/model.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/directives/model.js | MIT |
function eof(): boolean {
return index >= len
} | parse directive model to do the array update transform. a[idx] = val => $$a.splice($$idx, 1, val)
for loop possible cases:
- test
- test[idx]
- test[test1[idx]]
- test["a"][idx]
- xxx.test[a[a].test1[idx]]
- test.xxx.a["asa"][test1[idx]] | eof | javascript | GeekyAnts/vue-native-core | src/compiler/directives/model.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/directives/model.js | MIT |
function isStringStart(chr: number): boolean {
return chr === 0x22 || chr === 0x27
} | parse directive model to do the array update transform. a[idx] = val => $$a.splice($$idx, 1, val)
for loop possible cases:
- test
- test[idx]
- test[test1[idx]]
- test["a"][idx]
- xxx.test[a[a].test1[idx]]
- test.xxx.a["asa"][test1[idx]] | isStringStart | javascript | GeekyAnts/vue-native-core | src/compiler/directives/model.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/directives/model.js | MIT |
function parseBracket(chr: number): void {
let inBracket = 1
expressionPos = index
while (!eof()) {
chr = next()
if (isStringStart(chr)) {
parseString(chr)
continue
}
if (chr === 0x5b) inBracket++
if (chr === 0x5d) inBracket--
if (inBracket === 0) {
expressionEndPos = ind... | parse directive model to do the array update transform. a[idx] = val => $$a.splice($$idx, 1, val)
for loop possible cases:
- test
- test[idx]
- test[test1[idx]]
- test["a"][idx]
- xxx.test[a[a].test1[idx]]
- test.xxx.a["asa"][test1[idx]] | parseBracket | javascript | GeekyAnts/vue-native-core | src/compiler/directives/model.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/directives/model.js | MIT |
function parseString(chr: number): void {
const stringQuote = chr
while (!eof()) {
chr = next()
if (chr === stringQuote) {
break
}
}
} | parse directive model to do the array update transform. a[idx] = val => $$a.splice($$idx, 1, val)
for loop possible cases:
- test
- test[idx]
- test[test1[idx]]
- test["a"][idx]
- xxx.test[a[a].test1[idx]]
- test.xxx.a["asa"][test1[idx]] | parseString | javascript | GeekyAnts/vue-native-core | src/compiler/directives/model.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/directives/model.js | MIT |
function decodeAttr(value, shouldDecodeNewlines) {
const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr
return value.replace(re, match => decodingMap[match])
} | Not type-checking this file because it's mostly vendor code. | decodeAttr | javascript | GeekyAnts/vue-native-core | src/compiler/parser/html-parser.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/parser/html-parser.js | MIT |
function parseHTML(html, options) {
const stack = []
const expectHTML = options.expectHTML
const isUnaryTag = options.isUnaryTag || no
const canBeLeftOpenTag = options.canBeLeftOpenTag || no
let index = 0
let last, lastTag
while (html) {
last = html
// Make sure we're not in a plaintext content el... | Not type-checking this file because it's mostly vendor code. | parseHTML | javascript | GeekyAnts/vue-native-core | src/compiler/parser/html-parser.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/parser/html-parser.js | MIT |
function advance(n) {
index += n
html = html.substring(n)
} | Not type-checking this file because it's mostly vendor code. | advance | javascript | GeekyAnts/vue-native-core | src/compiler/parser/html-parser.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/parser/html-parser.js | MIT |
function parseStartTag() {
const start = html.match(startTagOpen)
if (start) {
const match = {
tagName: start[1],
attrs: [],
start: index,
}
advance(start[0].length)
let end, attr
while (
!(end = html.match(startTagClose)) &&
(attr = html.mat... | Not type-checking this file because it's mostly vendor code. | parseStartTag | javascript | GeekyAnts/vue-native-core | src/compiler/parser/html-parser.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/parser/html-parser.js | MIT |
function handleStartTag(match) {
const tagName = match.tagName
const unarySlash = match.unarySlash
if (expectHTML) {
if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
parseEndTag(lastTag)
}
if (canBeLeftOpenTag(tagName) && lastTag === tagName) {
parseEndTag(tagName)
... | Not type-checking this file because it's mostly vendor code. | handleStartTag | javascript | GeekyAnts/vue-native-core | src/compiler/parser/html-parser.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/parser/html-parser.js | MIT |
function parseEndTag(tagName, start, end) {
let pos, lowerCasedTagName
if (start == null) start = index
if (end == null) end = index
if (tagName) {
lowerCasedTagName = tagName.toLowerCase()
}
// Find the closest opened tag of the same type
if (tagName) {
for (pos = stack.length... | react-vue change
<div autorun></div>
{name: "autorun", value: """"} => {name: "autorun", value: "true"} | parseEndTag | javascript | GeekyAnts/vue-native-core | src/compiler/parser/html-parser.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/compiler/parser/html-parser.js | MIT |
function bindObjectProps(
data: any,
tag: string,
value: any,
asProp?: boolean,
): VNodeData {
if (value) {
if (!isObject(value)) {
process.env.NODE_ENV !== 'production' &&
warn('v-bind without argument expects an Object or Array value', this)
} else {
if (Array.isArray(value)) {
... | Runtime helper for merging v-bind="object" into a VNode's data. | bindObjectProps | javascript | GeekyAnts/vue-native-core | src/core/instance/render-helpers/bind-object-props.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/core/instance/render-helpers/bind-object-props.js | MIT |
key
if (Array.isArray(val) || typeof val === 'string') {
ret = new Array(val.length)
for (i = 0, l = val.length; i < l; i++) {
ret[i] = render(val[i], i)
}
} | Runtime helper for rendering v-for lists. | key | javascript | GeekyAnts/vue-native-core | src/core/instance/render-helpers/render-list.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/core/instance/render-helpers/render-list.js | MIT |
isObject(val)) {
keys = Object.keys(val)
ret = new Array(keys.length)
for (i = 0, l = keys.length; i < l; i++) {
key = keys[i]
ret[i] = render(val[key], key, i)
}
} | Runtime helper for rendering v-for lists. | isObject | javascript | GeekyAnts/vue-native-core | src/core/instance/render-helpers/render-list.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/core/instance/render-helpers/render-list.js | MIT |
function resolveSlots(
children: ?Array<VNode>,
context: ?Component,
): { [key: string]: Array<VNode> } | Runtime helper for resolving raw children VNodes into a slot object. | resolveSlots | javascript | GeekyAnts/vue-native-core | src/core/instance/render-helpers/resolve-slots.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/core/instance/render-helpers/resolve-slots.js | MIT |
function isWhitespace(node: VNode): boolean {
return node.isComment || node.text === ' '
} | Runtime helper for resolving raw children VNodes into a slot object. | isWhitespace | javascript | GeekyAnts/vue-native-core | src/core/instance/render-helpers/resolve-slots.js | https://github.com/GeekyAnts/vue-native-core/blob/master/src/core/instance/render-helpers/resolve-slots.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.