@tgify/tgify 0.1.0 → 0.1.4
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/LICENSE +23 -23
- package/README.md +356 -356
- package/lib/cli.mjs +9 -9
- package/package.json +1 -1
- package/src/button.ts +182 -182
- package/src/composer.ts +1008 -1008
- package/src/context.ts +1661 -1661
- package/src/core/helpers/args.ts +63 -63
- package/src/core/helpers/check.ts +71 -71
- package/src/core/helpers/compact.ts +18 -18
- package/src/core/helpers/deunionize.ts +26 -26
- package/src/core/helpers/formatting.ts +119 -119
- package/src/core/helpers/util.ts +96 -96
- package/src/core/network/client.ts +396 -396
- package/src/core/network/error.ts +29 -29
- package/src/core/network/multipart-stream.ts +45 -45
- package/src/core/network/polling.ts +94 -94
- package/src/core/network/webhook.ts +58 -58
- package/src/core/types/typegram.ts +54 -54
- package/src/filters.ts +109 -109
- package/src/format.ts +110 -110
- package/src/future.ts +213 -213
- package/src/index.ts +17 -17
- package/src/input.ts +59 -59
- package/src/markup.ts +142 -142
- package/src/middleware.ts +24 -24
- package/src/reactions.ts +118 -118
- package/src/router.ts +55 -55
- package/src/scenes/base.ts +52 -52
- package/src/scenes/context.ts +136 -136
- package/src/scenes/index.ts +21 -21
- package/src/scenes/stage.ts +71 -71
- package/src/scenes/wizard/context.ts +58 -58
- package/src/scenes/wizard/index.ts +63 -63
- package/src/scenes.ts +1 -1
- package/src/session.ts +204 -204
- package/src/telegraf.ts +354 -354
- package/src/telegram-types.ts +219 -219
- package/src/telegram.ts +1635 -1635
- package/src/types.ts +2 -2
- package/src/utils.ts +1 -1
- package/typings/telegraf.d.ts.map +1 -1
package/src/future.ts
CHANGED
|
@@ -1,213 +1,213 @@
|
|
|
1
|
-
import { ReplyParameters } from '@telegraf/types'
|
|
2
|
-
import Context from './context'
|
|
3
|
-
import { Middleware } from './middleware'
|
|
4
|
-
|
|
5
|
-
type ReplyContext = { [key in keyof Context & `reply${string}`]: Context[key] }
|
|
6
|
-
|
|
7
|
-
function makeReply<
|
|
8
|
-
C extends Context,
|
|
9
|
-
E extends { reply_parameters?: ReplyParameters },
|
|
10
|
-
>(ctx: C, extra?: E) {
|
|
11
|
-
if (ctx.msgId)
|
|
12
|
-
return {
|
|
13
|
-
// overrides in this order so user can override all properties
|
|
14
|
-
reply_parameters: {
|
|
15
|
-
message_id: ctx.msgId,
|
|
16
|
-
...extra?.reply_parameters,
|
|
17
|
-
},
|
|
18
|
-
...extra,
|
|
19
|
-
}
|
|
20
|
-
else return extra
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const replyContext: ReplyContext = {
|
|
24
|
-
replyWithChatAction: function () {
|
|
25
|
-
throw new TypeError(
|
|
26
|
-
'ctx.replyWithChatAction has been removed, use ctx.sendChatAction instead'
|
|
27
|
-
)
|
|
28
|
-
},
|
|
29
|
-
reply(this: Context, text, extra) {
|
|
30
|
-
this.assert(this.chat, 'reply')
|
|
31
|
-
return this.telegram.sendMessage(this.chat.id, text, makeReply(this, extra))
|
|
32
|
-
},
|
|
33
|
-
replyWithAnimation(this: Context, animation, extra) {
|
|
34
|
-
this.assert(this.chat, 'replyWithAnimation')
|
|
35
|
-
return this.telegram.sendAnimation(
|
|
36
|
-
this.chat.id,
|
|
37
|
-
animation,
|
|
38
|
-
makeReply(this, extra)
|
|
39
|
-
)
|
|
40
|
-
},
|
|
41
|
-
replyWithAudio(this: Context, audio, extra) {
|
|
42
|
-
this.assert(this.chat, 'replyWithAudio')
|
|
43
|
-
return this.telegram.sendAudio(this.chat.id, audio, makeReply(this, extra))
|
|
44
|
-
},
|
|
45
|
-
replyWithContact(this: Context, phoneNumber, firstName, extra) {
|
|
46
|
-
this.assert(this.chat, 'replyWithContact')
|
|
47
|
-
return this.telegram.sendContact(
|
|
48
|
-
this.chat.id,
|
|
49
|
-
phoneNumber,
|
|
50
|
-
firstName,
|
|
51
|
-
makeReply(this, extra)
|
|
52
|
-
)
|
|
53
|
-
},
|
|
54
|
-
replyWithDice(this: Context, extra) {
|
|
55
|
-
this.assert(this.chat, 'replyWithDice')
|
|
56
|
-
return this.telegram.sendDice(this.chat.id, makeReply(this, extra))
|
|
57
|
-
},
|
|
58
|
-
replyWithDocument(this: Context, document, extra) {
|
|
59
|
-
this.assert(this.chat, 'replyWithDocument')
|
|
60
|
-
return this.telegram.sendDocument(
|
|
61
|
-
this.chat.id,
|
|
62
|
-
document,
|
|
63
|
-
makeReply(this, extra)
|
|
64
|
-
)
|
|
65
|
-
},
|
|
66
|
-
replyWithGame(this: Context, gameName, extra) {
|
|
67
|
-
this.assert(this.chat, 'replyWithGame')
|
|
68
|
-
return this.telegram.sendGame(
|
|
69
|
-
this.chat.id,
|
|
70
|
-
gameName,
|
|
71
|
-
makeReply(this, extra)
|
|
72
|
-
)
|
|
73
|
-
},
|
|
74
|
-
replyWithHTML(this: Context, html, extra) {
|
|
75
|
-
this.assert(this.chat, 'replyWithHTML')
|
|
76
|
-
return this.telegram.sendMessage(this.chat.id, html, {
|
|
77
|
-
parse_mode: 'HTML',
|
|
78
|
-
...makeReply(this, extra),
|
|
79
|
-
})
|
|
80
|
-
},
|
|
81
|
-
replyWithInvoice(this: Context, invoice, extra) {
|
|
82
|
-
this.assert(this.chat, 'replyWithInvoice')
|
|
83
|
-
return this.telegram.sendInvoice(
|
|
84
|
-
this.chat.id,
|
|
85
|
-
invoice,
|
|
86
|
-
makeReply(this, extra)
|
|
87
|
-
)
|
|
88
|
-
},
|
|
89
|
-
replyWithLocation(this: Context, latitude, longitude, extra) {
|
|
90
|
-
this.assert(this.chat, 'replyWithLocation')
|
|
91
|
-
return this.telegram.sendLocation(
|
|
92
|
-
this.chat.id,
|
|
93
|
-
latitude,
|
|
94
|
-
longitude,
|
|
95
|
-
makeReply(this, extra)
|
|
96
|
-
)
|
|
97
|
-
},
|
|
98
|
-
replyWithMarkdown(this: Context, markdown, extra) {
|
|
99
|
-
this.assert(this.chat, 'replyWithMarkdown')
|
|
100
|
-
return this.telegram.sendMessage(this.chat.id, markdown, {
|
|
101
|
-
parse_mode: 'Markdown',
|
|
102
|
-
...makeReply(this, extra),
|
|
103
|
-
})
|
|
104
|
-
},
|
|
105
|
-
replyWithMarkdownV2(this: Context, markdown, extra) {
|
|
106
|
-
this.assert(this.chat, 'replyWithMarkdownV2')
|
|
107
|
-
return this.telegram.sendMessage(this.chat.id, markdown, {
|
|
108
|
-
parse_mode: 'MarkdownV2',
|
|
109
|
-
...makeReply(this, extra),
|
|
110
|
-
})
|
|
111
|
-
},
|
|
112
|
-
replyWithMediaGroup(this: Context, media, extra) {
|
|
113
|
-
this.assert(this.chat, 'replyWithMediaGroup')
|
|
114
|
-
return this.telegram.sendMediaGroup(
|
|
115
|
-
this.chat.id,
|
|
116
|
-
media,
|
|
117
|
-
makeReply(this, extra)
|
|
118
|
-
)
|
|
119
|
-
},
|
|
120
|
-
replyWithPhoto(this: Context, photo, extra) {
|
|
121
|
-
this.assert(this.chat, 'replyWithPhoto')
|
|
122
|
-
return this.telegram.sendPhoto(this.chat.id, photo, makeReply(this, extra))
|
|
123
|
-
},
|
|
124
|
-
replyWithPoll(this: Context, question, options, extra) {
|
|
125
|
-
this.assert(this.chat, 'replyWithPoll')
|
|
126
|
-
return this.telegram.sendPoll(
|
|
127
|
-
this.chat.id,
|
|
128
|
-
question,
|
|
129
|
-
options,
|
|
130
|
-
makeReply(this, extra)
|
|
131
|
-
)
|
|
132
|
-
},
|
|
133
|
-
replyWithQuiz(this: Context, question, options, extra) {
|
|
134
|
-
this.assert(this.chat, 'replyWithQuiz')
|
|
135
|
-
return this.telegram.sendQuiz(
|
|
136
|
-
this.chat.id,
|
|
137
|
-
question,
|
|
138
|
-
options,
|
|
139
|
-
makeReply(this, extra)
|
|
140
|
-
)
|
|
141
|
-
},
|
|
142
|
-
replyWithSticker(this: Context, sticker, extra) {
|
|
143
|
-
this.assert(this.chat, 'replyWithSticker')
|
|
144
|
-
return this.telegram.sendSticker(
|
|
145
|
-
this.chat.id,
|
|
146
|
-
sticker,
|
|
147
|
-
makeReply(this, extra)
|
|
148
|
-
)
|
|
149
|
-
},
|
|
150
|
-
replyWithVenue(this: Context, latitude, longitude, title, address, extra) {
|
|
151
|
-
this.assert(this.chat, 'replyWithVenue')
|
|
152
|
-
return this.telegram.sendVenue(
|
|
153
|
-
this.chat.id,
|
|
154
|
-
latitude,
|
|
155
|
-
longitude,
|
|
156
|
-
title,
|
|
157
|
-
address,
|
|
158
|
-
makeReply(this, extra)
|
|
159
|
-
)
|
|
160
|
-
},
|
|
161
|
-
replyWithVideo(this: Context, video, extra) {
|
|
162
|
-
this.assert(this.chat, 'replyWithVideo')
|
|
163
|
-
return this.telegram.sendVideo(this.chat.id, video, makeReply(this, extra))
|
|
164
|
-
},
|
|
165
|
-
replyWithVideoNote(this: Context, videoNote, extra) {
|
|
166
|
-
this.assert(this.chat, 'replyWithVideoNote')
|
|
167
|
-
return this.telegram.sendVideoNote(
|
|
168
|
-
this.chat.id,
|
|
169
|
-
videoNote,
|
|
170
|
-
makeReply(this, extra)
|
|
171
|
-
)
|
|
172
|
-
},
|
|
173
|
-
replyWithVoice(this: Context, voice, extra) {
|
|
174
|
-
this.assert(this.chat, 'replyWithVoice')
|
|
175
|
-
return this.telegram.sendVoice(this.chat.id, voice, makeReply(this, extra))
|
|
176
|
-
},
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Sets up Context to use the new reply methods.
|
|
181
|
-
* This middleware makes `ctx.reply()` and `ctx.replyWith*()` methods will actually reply to the message they are replying to.
|
|
182
|
-
* Use `ctx.sendMessage()` to send a message in chat without replying to it.
|
|
183
|
-
*
|
|
184
|
-
* If the message to reply is deleted, `reply()` will send a normal message.
|
|
185
|
-
* If the update is not a message and we are unable to reply, `reply()` will send a normal message.
|
|
186
|
-
*/
|
|
187
|
-
export function useNewReplies<C extends Context>(): Middleware<C> {
|
|
188
|
-
return (ctx, next) => {
|
|
189
|
-
ctx.reply = replyContext.reply
|
|
190
|
-
ctx.replyWithPhoto = replyContext.replyWithPhoto
|
|
191
|
-
ctx.replyWithMediaGroup = replyContext.replyWithMediaGroup
|
|
192
|
-
ctx.replyWithAudio = replyContext.replyWithAudio
|
|
193
|
-
ctx.replyWithDice = replyContext.replyWithDice
|
|
194
|
-
ctx.replyWithDocument = replyContext.replyWithDocument
|
|
195
|
-
ctx.replyWithSticker = replyContext.replyWithSticker
|
|
196
|
-
ctx.replyWithVideo = replyContext.replyWithVideo
|
|
197
|
-
ctx.replyWithAnimation = replyContext.replyWithAnimation
|
|
198
|
-
ctx.replyWithVideoNote = replyContext.replyWithVideoNote
|
|
199
|
-
ctx.replyWithInvoice = replyContext.replyWithInvoice
|
|
200
|
-
ctx.replyWithGame = replyContext.replyWithGame
|
|
201
|
-
ctx.replyWithVoice = replyContext.replyWithVoice
|
|
202
|
-
ctx.replyWithPoll = replyContext.replyWithPoll
|
|
203
|
-
ctx.replyWithQuiz = replyContext.replyWithQuiz
|
|
204
|
-
ctx.replyWithChatAction = replyContext.replyWithChatAction
|
|
205
|
-
ctx.replyWithLocation = replyContext.replyWithLocation
|
|
206
|
-
ctx.replyWithVenue = replyContext.replyWithVenue
|
|
207
|
-
ctx.replyWithContact = replyContext.replyWithContact
|
|
208
|
-
ctx.replyWithMarkdown = replyContext.replyWithMarkdown
|
|
209
|
-
ctx.replyWithMarkdownV2 = replyContext.replyWithMarkdownV2
|
|
210
|
-
ctx.replyWithHTML = replyContext.replyWithHTML
|
|
211
|
-
return next()
|
|
212
|
-
}
|
|
213
|
-
}
|
|
1
|
+
import { ReplyParameters } from '@telegraf/types'
|
|
2
|
+
import Context from './context'
|
|
3
|
+
import { Middleware } from './middleware'
|
|
4
|
+
|
|
5
|
+
type ReplyContext = { [key in keyof Context & `reply${string}`]: Context[key] }
|
|
6
|
+
|
|
7
|
+
function makeReply<
|
|
8
|
+
C extends Context,
|
|
9
|
+
E extends { reply_parameters?: ReplyParameters },
|
|
10
|
+
>(ctx: C, extra?: E) {
|
|
11
|
+
if (ctx.msgId)
|
|
12
|
+
return {
|
|
13
|
+
// overrides in this order so user can override all properties
|
|
14
|
+
reply_parameters: {
|
|
15
|
+
message_id: ctx.msgId,
|
|
16
|
+
...extra?.reply_parameters,
|
|
17
|
+
},
|
|
18
|
+
...extra,
|
|
19
|
+
}
|
|
20
|
+
else return extra
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const replyContext: ReplyContext = {
|
|
24
|
+
replyWithChatAction: function () {
|
|
25
|
+
throw new TypeError(
|
|
26
|
+
'ctx.replyWithChatAction has been removed, use ctx.sendChatAction instead'
|
|
27
|
+
)
|
|
28
|
+
},
|
|
29
|
+
reply(this: Context, text, extra) {
|
|
30
|
+
this.assert(this.chat, 'reply')
|
|
31
|
+
return this.telegram.sendMessage(this.chat.id, text, makeReply(this, extra))
|
|
32
|
+
},
|
|
33
|
+
replyWithAnimation(this: Context, animation, extra) {
|
|
34
|
+
this.assert(this.chat, 'replyWithAnimation')
|
|
35
|
+
return this.telegram.sendAnimation(
|
|
36
|
+
this.chat.id,
|
|
37
|
+
animation,
|
|
38
|
+
makeReply(this, extra)
|
|
39
|
+
)
|
|
40
|
+
},
|
|
41
|
+
replyWithAudio(this: Context, audio, extra) {
|
|
42
|
+
this.assert(this.chat, 'replyWithAudio')
|
|
43
|
+
return this.telegram.sendAudio(this.chat.id, audio, makeReply(this, extra))
|
|
44
|
+
},
|
|
45
|
+
replyWithContact(this: Context, phoneNumber, firstName, extra) {
|
|
46
|
+
this.assert(this.chat, 'replyWithContact')
|
|
47
|
+
return this.telegram.sendContact(
|
|
48
|
+
this.chat.id,
|
|
49
|
+
phoneNumber,
|
|
50
|
+
firstName,
|
|
51
|
+
makeReply(this, extra)
|
|
52
|
+
)
|
|
53
|
+
},
|
|
54
|
+
replyWithDice(this: Context, extra) {
|
|
55
|
+
this.assert(this.chat, 'replyWithDice')
|
|
56
|
+
return this.telegram.sendDice(this.chat.id, makeReply(this, extra))
|
|
57
|
+
},
|
|
58
|
+
replyWithDocument(this: Context, document, extra) {
|
|
59
|
+
this.assert(this.chat, 'replyWithDocument')
|
|
60
|
+
return this.telegram.sendDocument(
|
|
61
|
+
this.chat.id,
|
|
62
|
+
document,
|
|
63
|
+
makeReply(this, extra)
|
|
64
|
+
)
|
|
65
|
+
},
|
|
66
|
+
replyWithGame(this: Context, gameName, extra) {
|
|
67
|
+
this.assert(this.chat, 'replyWithGame')
|
|
68
|
+
return this.telegram.sendGame(
|
|
69
|
+
this.chat.id,
|
|
70
|
+
gameName,
|
|
71
|
+
makeReply(this, extra)
|
|
72
|
+
)
|
|
73
|
+
},
|
|
74
|
+
replyWithHTML(this: Context, html, extra) {
|
|
75
|
+
this.assert(this.chat, 'replyWithHTML')
|
|
76
|
+
return this.telegram.sendMessage(this.chat.id, html, {
|
|
77
|
+
parse_mode: 'HTML',
|
|
78
|
+
...makeReply(this, extra),
|
|
79
|
+
})
|
|
80
|
+
},
|
|
81
|
+
replyWithInvoice(this: Context, invoice, extra) {
|
|
82
|
+
this.assert(this.chat, 'replyWithInvoice')
|
|
83
|
+
return this.telegram.sendInvoice(
|
|
84
|
+
this.chat.id,
|
|
85
|
+
invoice,
|
|
86
|
+
makeReply(this, extra)
|
|
87
|
+
)
|
|
88
|
+
},
|
|
89
|
+
replyWithLocation(this: Context, latitude, longitude, extra) {
|
|
90
|
+
this.assert(this.chat, 'replyWithLocation')
|
|
91
|
+
return this.telegram.sendLocation(
|
|
92
|
+
this.chat.id,
|
|
93
|
+
latitude,
|
|
94
|
+
longitude,
|
|
95
|
+
makeReply(this, extra)
|
|
96
|
+
)
|
|
97
|
+
},
|
|
98
|
+
replyWithMarkdown(this: Context, markdown, extra) {
|
|
99
|
+
this.assert(this.chat, 'replyWithMarkdown')
|
|
100
|
+
return this.telegram.sendMessage(this.chat.id, markdown, {
|
|
101
|
+
parse_mode: 'Markdown',
|
|
102
|
+
...makeReply(this, extra),
|
|
103
|
+
})
|
|
104
|
+
},
|
|
105
|
+
replyWithMarkdownV2(this: Context, markdown, extra) {
|
|
106
|
+
this.assert(this.chat, 'replyWithMarkdownV2')
|
|
107
|
+
return this.telegram.sendMessage(this.chat.id, markdown, {
|
|
108
|
+
parse_mode: 'MarkdownV2',
|
|
109
|
+
...makeReply(this, extra),
|
|
110
|
+
})
|
|
111
|
+
},
|
|
112
|
+
replyWithMediaGroup(this: Context, media, extra) {
|
|
113
|
+
this.assert(this.chat, 'replyWithMediaGroup')
|
|
114
|
+
return this.telegram.sendMediaGroup(
|
|
115
|
+
this.chat.id,
|
|
116
|
+
media,
|
|
117
|
+
makeReply(this, extra)
|
|
118
|
+
)
|
|
119
|
+
},
|
|
120
|
+
replyWithPhoto(this: Context, photo, extra) {
|
|
121
|
+
this.assert(this.chat, 'replyWithPhoto')
|
|
122
|
+
return this.telegram.sendPhoto(this.chat.id, photo, makeReply(this, extra))
|
|
123
|
+
},
|
|
124
|
+
replyWithPoll(this: Context, question, options, extra) {
|
|
125
|
+
this.assert(this.chat, 'replyWithPoll')
|
|
126
|
+
return this.telegram.sendPoll(
|
|
127
|
+
this.chat.id,
|
|
128
|
+
question,
|
|
129
|
+
options,
|
|
130
|
+
makeReply(this, extra)
|
|
131
|
+
)
|
|
132
|
+
},
|
|
133
|
+
replyWithQuiz(this: Context, question, options, extra) {
|
|
134
|
+
this.assert(this.chat, 'replyWithQuiz')
|
|
135
|
+
return this.telegram.sendQuiz(
|
|
136
|
+
this.chat.id,
|
|
137
|
+
question,
|
|
138
|
+
options,
|
|
139
|
+
makeReply(this, extra)
|
|
140
|
+
)
|
|
141
|
+
},
|
|
142
|
+
replyWithSticker(this: Context, sticker, extra) {
|
|
143
|
+
this.assert(this.chat, 'replyWithSticker')
|
|
144
|
+
return this.telegram.sendSticker(
|
|
145
|
+
this.chat.id,
|
|
146
|
+
sticker,
|
|
147
|
+
makeReply(this, extra)
|
|
148
|
+
)
|
|
149
|
+
},
|
|
150
|
+
replyWithVenue(this: Context, latitude, longitude, title, address, extra) {
|
|
151
|
+
this.assert(this.chat, 'replyWithVenue')
|
|
152
|
+
return this.telegram.sendVenue(
|
|
153
|
+
this.chat.id,
|
|
154
|
+
latitude,
|
|
155
|
+
longitude,
|
|
156
|
+
title,
|
|
157
|
+
address,
|
|
158
|
+
makeReply(this, extra)
|
|
159
|
+
)
|
|
160
|
+
},
|
|
161
|
+
replyWithVideo(this: Context, video, extra) {
|
|
162
|
+
this.assert(this.chat, 'replyWithVideo')
|
|
163
|
+
return this.telegram.sendVideo(this.chat.id, video, makeReply(this, extra))
|
|
164
|
+
},
|
|
165
|
+
replyWithVideoNote(this: Context, videoNote, extra) {
|
|
166
|
+
this.assert(this.chat, 'replyWithVideoNote')
|
|
167
|
+
return this.telegram.sendVideoNote(
|
|
168
|
+
this.chat.id,
|
|
169
|
+
videoNote,
|
|
170
|
+
makeReply(this, extra)
|
|
171
|
+
)
|
|
172
|
+
},
|
|
173
|
+
replyWithVoice(this: Context, voice, extra) {
|
|
174
|
+
this.assert(this.chat, 'replyWithVoice')
|
|
175
|
+
return this.telegram.sendVoice(this.chat.id, voice, makeReply(this, extra))
|
|
176
|
+
},
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Sets up Context to use the new reply methods.
|
|
181
|
+
* This middleware makes `ctx.reply()` and `ctx.replyWith*()` methods will actually reply to the message they are replying to.
|
|
182
|
+
* Use `ctx.sendMessage()` to send a message in chat without replying to it.
|
|
183
|
+
*
|
|
184
|
+
* If the message to reply is deleted, `reply()` will send a normal message.
|
|
185
|
+
* If the update is not a message and we are unable to reply, `reply()` will send a normal message.
|
|
186
|
+
*/
|
|
187
|
+
export function useNewReplies<C extends Context>(): Middleware<C> {
|
|
188
|
+
return (ctx, next) => {
|
|
189
|
+
ctx.reply = replyContext.reply
|
|
190
|
+
ctx.replyWithPhoto = replyContext.replyWithPhoto
|
|
191
|
+
ctx.replyWithMediaGroup = replyContext.replyWithMediaGroup
|
|
192
|
+
ctx.replyWithAudio = replyContext.replyWithAudio
|
|
193
|
+
ctx.replyWithDice = replyContext.replyWithDice
|
|
194
|
+
ctx.replyWithDocument = replyContext.replyWithDocument
|
|
195
|
+
ctx.replyWithSticker = replyContext.replyWithSticker
|
|
196
|
+
ctx.replyWithVideo = replyContext.replyWithVideo
|
|
197
|
+
ctx.replyWithAnimation = replyContext.replyWithAnimation
|
|
198
|
+
ctx.replyWithVideoNote = replyContext.replyWithVideoNote
|
|
199
|
+
ctx.replyWithInvoice = replyContext.replyWithInvoice
|
|
200
|
+
ctx.replyWithGame = replyContext.replyWithGame
|
|
201
|
+
ctx.replyWithVoice = replyContext.replyWithVoice
|
|
202
|
+
ctx.replyWithPoll = replyContext.replyWithPoll
|
|
203
|
+
ctx.replyWithQuiz = replyContext.replyWithQuiz
|
|
204
|
+
ctx.replyWithChatAction = replyContext.replyWithChatAction
|
|
205
|
+
ctx.replyWithLocation = replyContext.replyWithLocation
|
|
206
|
+
ctx.replyWithVenue = replyContext.replyWithVenue
|
|
207
|
+
ctx.replyWithContact = replyContext.replyWithContact
|
|
208
|
+
ctx.replyWithMarkdown = replyContext.replyWithMarkdown
|
|
209
|
+
ctx.replyWithMarkdownV2 = replyContext.replyWithMarkdownV2
|
|
210
|
+
ctx.replyWithHTML = replyContext.replyWithHTML
|
|
211
|
+
return next()
|
|
212
|
+
}
|
|
213
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export { Telegraf } from './telegraf'
|
|
2
|
-
export { Context, NarrowedContext } from './context'
|
|
3
|
-
export { Composer } from './composer'
|
|
4
|
-
export { Middleware, MiddlewareFn, MiddlewareObj } from './middleware'
|
|
5
|
-
export { Router } from './router'
|
|
6
|
-
export { TelegramError } from './core/network/error'
|
|
7
|
-
export { Telegram } from './telegram'
|
|
8
|
-
|
|
9
|
-
export * as Types from './telegram-types'
|
|
10
|
-
export * as Markup from './markup'
|
|
11
|
-
export * as Input from './input'
|
|
12
|
-
export * as Format from './format'
|
|
13
|
-
|
|
14
|
-
export { deunionize } from './core/helpers/deunionize'
|
|
15
|
-
export { session, MemorySessionStore, SessionStore } from './session'
|
|
16
|
-
|
|
17
|
-
export * as Scenes from './scenes'
|
|
1
|
+
export { Telegraf } from './telegraf'
|
|
2
|
+
export { Context, NarrowedContext } from './context'
|
|
3
|
+
export { Composer } from './composer'
|
|
4
|
+
export { Middleware, MiddlewareFn, MiddlewareObj } from './middleware'
|
|
5
|
+
export { Router } from './router'
|
|
6
|
+
export { TelegramError } from './core/network/error'
|
|
7
|
+
export { Telegram } from './telegram'
|
|
8
|
+
|
|
9
|
+
export * as Types from './telegram-types'
|
|
10
|
+
export * as Markup from './markup'
|
|
11
|
+
export * as Input from './input'
|
|
12
|
+
export * as Format from './format'
|
|
13
|
+
|
|
14
|
+
export { deunionize } from './core/helpers/deunionize'
|
|
15
|
+
export { session, MemorySessionStore, SessionStore } from './session'
|
|
16
|
+
|
|
17
|
+
export * as Scenes from './scenes'
|
package/src/input.ts
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import { InputFile } from './core/types/typegram'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The local file specified by path will be uploaded to Telegram using multipart/form-data.
|
|
5
|
-
*
|
|
6
|
-
* 10 MB max size for photos, 50 MB for other files.
|
|
7
|
-
*/
|
|
8
|
-
// prettier-ignore
|
|
9
|
-
export const fromLocalFile = (path: string, filename?: string): InputFile => ({ source: path, filename })
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* The buffer will be uploaded as file to Telegram using multipart/form-data.
|
|
13
|
-
*
|
|
14
|
-
* 10 MB max size for photos, 50 MB for other files.
|
|
15
|
-
*/
|
|
16
|
-
// prettier-ignore
|
|
17
|
-
export const fromBuffer = (buffer: Buffer, filename?: string): InputFile => ({ source: buffer, filename })
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Contents of the stream will be uploaded as file to Telegram using multipart/form-data.
|
|
21
|
-
*
|
|
22
|
-
* 10 MB max size for photos, 50 MB for other files.
|
|
23
|
-
*/
|
|
24
|
-
// prettier-ignore
|
|
25
|
-
export const fromReadableStream = (stream: NodeJS.ReadableStream, filename?: string): InputFile => ({ source: stream, filename })
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Contents of the URL will be streamed to Telegram.
|
|
29
|
-
*
|
|
30
|
-
* 10 MB max size for photos, 50 MB for other files.
|
|
31
|
-
*/
|
|
32
|
-
// prettier-ignore
|
|
33
|
-
export const fromURLStream = (url: string | URL, filename?: string): InputFile => ({ url: url.toString(), filename })
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Provide Telegram with an HTTP URL for the file to be sent.
|
|
37
|
-
* Telegram will download and send the file.
|
|
38
|
-
*
|
|
39
|
-
* * The target file must have the correct MIME type (e.g., audio/mpeg for `sendAudio`, etc.).
|
|
40
|
-
* * `sendDocument` with URL will currently only work for GIF, PDF and ZIP files.
|
|
41
|
-
* * To use `sendVoice`, the file must have the type audio/ogg and be no more than 1MB in size.
|
|
42
|
-
* 1-20MB voice notes will be sent as files.
|
|
43
|
-
*
|
|
44
|
-
* 5 MB max size for photos and 20 MB max for other types of content.
|
|
45
|
-
*/
|
|
46
|
-
export const fromURL = (url: string | URL): string => url.toString()
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* If the file is already stored somewhere on the Telegram servers, you don't need to reupload it:
|
|
50
|
-
* each file object has a file_id field, simply pass this file_id as a parameter instead of uploading.
|
|
51
|
-
*
|
|
52
|
-
* It is not possible to change the file type when resending by file_id.
|
|
53
|
-
*
|
|
54
|
-
* It is not possible to resend thumbnails using file_id.
|
|
55
|
-
* They have to be uploaded using one of the other Input methods.
|
|
56
|
-
*
|
|
57
|
-
* There are no limits for files sent this way.
|
|
58
|
-
*/
|
|
59
|
-
export const fromFileId = (fileId: string): string => fileId
|
|
1
|
+
import { InputFile } from './core/types/typegram'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The local file specified by path will be uploaded to Telegram using multipart/form-data.
|
|
5
|
+
*
|
|
6
|
+
* 10 MB max size for photos, 50 MB for other files.
|
|
7
|
+
*/
|
|
8
|
+
// prettier-ignore
|
|
9
|
+
export const fromLocalFile = (path: string, filename?: string): InputFile => ({ source: path, filename })
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The buffer will be uploaded as file to Telegram using multipart/form-data.
|
|
13
|
+
*
|
|
14
|
+
* 10 MB max size for photos, 50 MB for other files.
|
|
15
|
+
*/
|
|
16
|
+
// prettier-ignore
|
|
17
|
+
export const fromBuffer = (buffer: Buffer, filename?: string): InputFile => ({ source: buffer, filename })
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Contents of the stream will be uploaded as file to Telegram using multipart/form-data.
|
|
21
|
+
*
|
|
22
|
+
* 10 MB max size for photos, 50 MB for other files.
|
|
23
|
+
*/
|
|
24
|
+
// prettier-ignore
|
|
25
|
+
export const fromReadableStream = (stream: NodeJS.ReadableStream, filename?: string): InputFile => ({ source: stream, filename })
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Contents of the URL will be streamed to Telegram.
|
|
29
|
+
*
|
|
30
|
+
* 10 MB max size for photos, 50 MB for other files.
|
|
31
|
+
*/
|
|
32
|
+
// prettier-ignore
|
|
33
|
+
export const fromURLStream = (url: string | URL, filename?: string): InputFile => ({ url: url.toString(), filename })
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Provide Telegram with an HTTP URL for the file to be sent.
|
|
37
|
+
* Telegram will download and send the file.
|
|
38
|
+
*
|
|
39
|
+
* * The target file must have the correct MIME type (e.g., audio/mpeg for `sendAudio`, etc.).
|
|
40
|
+
* * `sendDocument` with URL will currently only work for GIF, PDF and ZIP files.
|
|
41
|
+
* * To use `sendVoice`, the file must have the type audio/ogg and be no more than 1MB in size.
|
|
42
|
+
* 1-20MB voice notes will be sent as files.
|
|
43
|
+
*
|
|
44
|
+
* 5 MB max size for photos and 20 MB max for other types of content.
|
|
45
|
+
*/
|
|
46
|
+
export const fromURL = (url: string | URL): string => url.toString()
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* If the file is already stored somewhere on the Telegram servers, you don't need to reupload it:
|
|
50
|
+
* each file object has a file_id field, simply pass this file_id as a parameter instead of uploading.
|
|
51
|
+
*
|
|
52
|
+
* It is not possible to change the file type when resending by file_id.
|
|
53
|
+
*
|
|
54
|
+
* It is not possible to resend thumbnails using file_id.
|
|
55
|
+
* They have to be uploaded using one of the other Input methods.
|
|
56
|
+
*
|
|
57
|
+
* There are no limits for files sent this way.
|
|
58
|
+
*/
|
|
59
|
+
export const fromFileId = (fileId: string): string => fileId
|