@zero-bot.net/tg-bot-api 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/telegram.d.ts +339 -6
- package/lib/telegram.js +39 -2
- package/package.json +1 -1
- package/src/telegram.d.ts +339 -6
- package/src/telegram.js +52 -1
package/src/telegram.js
CHANGED
|
@@ -108,6 +108,22 @@ const _messageTypes = [
|
|
|
108
108
|
// Bot API 10.3
|
|
109
109
|
'stopped_message_generation',
|
|
110
110
|
'community_chat_joined',
|
|
111
|
+
// Bot API 8.3+
|
|
112
|
+
'giveaway_created',
|
|
113
|
+
'giveaway',
|
|
114
|
+
'giveaway_winners',
|
|
115
|
+
'giveaway_completed',
|
|
116
|
+
'chat_boost_added',
|
|
117
|
+
'story',
|
|
118
|
+
'chat_background_set',
|
|
119
|
+
'forum_topic_created',
|
|
120
|
+
'forum_topic_closed',
|
|
121
|
+
'forum_topic_reopened',
|
|
122
|
+
'forum_topic_edited',
|
|
123
|
+
'general_forum_topic_hidden',
|
|
124
|
+
'general_forum_topic_unhidden',
|
|
125
|
+
'write_access_allowed',
|
|
126
|
+
'boost',
|
|
111
127
|
];
|
|
112
128
|
|
|
113
129
|
const _deprecatedMessageTypes = [
|
|
@@ -900,6 +916,34 @@ class TelegramBot extends EventEmitter {
|
|
|
900
916
|
debug('Process Update removed_chat_boost %j', removedChatBoost);
|
|
901
917
|
this.emit('removed_chat_boost', removedChatBoost);
|
|
902
918
|
}
|
|
919
|
+
|
|
920
|
+
// Update-level types not tied to message content
|
|
921
|
+
const purchasedPaidMedia = update.purchased_paid_media;
|
|
922
|
+
const subscription = update.subscription;
|
|
923
|
+
const managedBot = update.managed_bot;
|
|
924
|
+
const guestMessage = update.guest_message;
|
|
925
|
+
const stoppedMessageGeneration = update.stopped_message_generation;
|
|
926
|
+
const reaction = update.reaction;
|
|
927
|
+
|
|
928
|
+
if (purchasedPaidMedia) {
|
|
929
|
+
debug('Process Update purchased_paid_media %j', purchasedPaidMedia);
|
|
930
|
+
this.emit('purchased_paid_media', purchasedPaidMedia);
|
|
931
|
+
} else if (subscription) {
|
|
932
|
+
debug('Process Update subscription %j', subscription);
|
|
933
|
+
this.emit('subscription', subscription);
|
|
934
|
+
} else if (managedBot) {
|
|
935
|
+
debug('Process Update managed_bot %j', managedBot);
|
|
936
|
+
this.emit('managed_bot', managedBot);
|
|
937
|
+
} else if (guestMessage) {
|
|
938
|
+
debug('Process Update guest_message %j', guestMessage);
|
|
939
|
+
this.emit('guest_message', guestMessage);
|
|
940
|
+
} else if (stoppedMessageGeneration) {
|
|
941
|
+
debug('Process Update stopped_message_generation %j', stoppedMessageGeneration);
|
|
942
|
+
this.emit('stopped_message_generation', stoppedMessageGeneration);
|
|
943
|
+
} else if (reaction) {
|
|
944
|
+
debug('Process Update reaction %j', reaction);
|
|
945
|
+
this.emit('reaction', reaction);
|
|
946
|
+
}
|
|
903
947
|
}
|
|
904
948
|
|
|
905
949
|
/** Start Telegram Bot API methods */
|
|
@@ -3303,7 +3347,14 @@ class TelegramBot extends EventEmitter {
|
|
|
3303
3347
|
* @see https://core.telegram.org/bots/api#sendgift
|
|
3304
3348
|
*/
|
|
3305
3349
|
sendGift(userId, giftId, form = {}) {
|
|
3306
|
-
|
|
3350
|
+
if (typeof userId === 'number' || typeof userId === 'string') {
|
|
3351
|
+
// Check if it looks like a chat ID (negative numbers or @channel)
|
|
3352
|
+
if (String(userId).charAt(0) === '-' || String(userId).charAt(0) === '@') {
|
|
3353
|
+
form.chat_id = userId;
|
|
3354
|
+
} else {
|
|
3355
|
+
form.user_id = userId;
|
|
3356
|
+
}
|
|
3357
|
+
}
|
|
3307
3358
|
form.gift_id = giftId;
|
|
3308
3359
|
return this._request('sendGift', { form });
|
|
3309
3360
|
}
|