grammy 1.9.1 → 1.9.2
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/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center"><a href="https://grammy.dev"><img src="https://raw.githubusercontent.com/grammyjs/website/main/logos/grammY.png" alt="grammY"></a></h1></div>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<div align="right">
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
# The Telegram Bot Framework.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
</div>
|
|
8
8
|
|
|
9
9
|
<div align="center">
|
|
10
10
|
|
|
@@ -17,6 +17,8 @@ _<h2 align="center"> [:mag: Documentation](https://grammy.dev) | [:page_with_cur
|
|
|
17
17
|
|
|
18
18
|
<!-- deno-fmt-ignore-end -->
|
|
19
19
|
|
|
20
|
+
## _[docs.](https://grammy.dev) [reference.](https://doc.deno.land/https://deno.land/x/grammy/mod.ts) [chat.](https://telegram.me/grammyjs) [news.](https://telegram.me/grammyjs_news)_
|
|
21
|
+
|
|
20
22
|
</div>
|
|
21
23
|
|
|
22
24
|
**grammY makes it easy to create Telegram bots.** Both for beginners and at scale.
|
|
@@ -77,24 +79,29 @@ Here are some more resources to support you:
|
|
|
77
79
|
### [grammY Website](https://grammy.dev)
|
|
78
80
|
|
|
79
81
|
—main project website and documentation.
|
|
82
|
+
Gets you started and explains all concepts.
|
|
80
83
|
|
|
81
84
|
### [grammY API Reference](https://doc.deno.land/https://deno.land/x/grammy/mod.ts)
|
|
82
85
|
|
|
83
86
|
—reference of everything that grammY exports.
|
|
87
|
+
Useful to look up descriptions about any element of grammY.
|
|
84
88
|
|
|
85
89
|
### [grammY Example Bots](https://github.com/grammyjs/examples)
|
|
86
90
|
|
|
87
|
-
—repository full of example bots.
|
|
91
|
+
—repository full of example bots.
|
|
92
|
+
Includes a setup to easily run any of them.
|
|
88
93
|
|
|
89
94
|
### [grammY Telegram Chat](https://t.me/grammyjs)
|
|
90
95
|
|
|
91
|
-
—Telegram chat where you can ask any question about grammY or bots in general.
|
|
96
|
+
—Telegram chat where you can ask any question about grammY or bots in general.
|
|
97
|
+
We are also open for feedback, ideas, and contributions!
|
|
92
98
|
|
|
93
99
|
The Russian commnity chat can be found [here](https://t.me/grammyjs_ru).
|
|
94
100
|
|
|
95
101
|
### [grammY News Channel](https://t.me/grammyjs_news)
|
|
96
102
|
|
|
97
103
|
—Telegram channel where updates to grammY and the ecosystem are posted.
|
|
104
|
+
We are also [on Twitter](https://twitter.com/grammy_js).
|
|
98
105
|
|
|
99
106
|
### [Telegram Bot API Reference](https://core.telegram.org/bots/api)
|
|
100
107
|
|
|
@@ -130,7 +137,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
130
137
|
<table>
|
|
131
138
|
<tr>
|
|
132
139
|
<td align="center"><a href="https://github.com/KnorpelSenf"><img src="https://avatars.githubusercontent.com/u/12952387?v=4?s=100" width="100px;" alt=""/><br /><sub><b>KnorpelSenf</b></sub></a><br /><a href="#ideas-KnorpelSenf" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=KnorpelSenf" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/commits?author=KnorpelSenf" title="Documentation">📖</a> <a href="#design-KnorpelSenf" title="Design">🎨</a> <a href="#example-KnorpelSenf" title="Examples">💡</a> <a href="https://github.com/grammyjs/grammY/commits?author=KnorpelSenf" title="Tests">⚠️</a> <a href="#plugin-KnorpelSenf" title="Plugin/utility libraries">🔌</a> <a href="#platform-KnorpelSenf" title="Packaging/porting to new platform">📦</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AKnorpelSenf" title="Reviewed Pull Requests">👀</a> <a href="#mentoring-KnorpelSenf" title="Mentoring">🧑🏫</a> <a href="#projectManagement-KnorpelSenf" title="Project Management">📆</a> <a href="#infra-KnorpelSenf" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
|
|
133
|
-
<td align="center"><a href="https://github.com/
|
|
140
|
+
<td align="center"><a href="https://github.com/HeeroML"><img src="https://avatars.githubusercontent.com/u/42873000?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Heero</b></sub></a><br /><a href="#plugin-HeeroML" title="Plugin/utility libraries">🔌</a> <a href="#userTesting-HeeroML" title="User Testing">📓</a> <a href="#example-HeeroML" title="Examples">💡</a> <a href="https://github.com/grammyjs/grammY/commits?author=HeeroML" title="Documentation">📖</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AHeeroML" title="Reviewed Pull Requests">👀</a></td>
|
|
134
141
|
<td align="center"><a href="https://github.com/wojpawlik"><img src="https://avatars.githubusercontent.com/u/23058303?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Wojciech Pawlik</b></sub></a><br /><a href="#ideas-wojpawlik" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Awojpawlik" title="Reviewed Pull Requests">👀</a> <a href="#infra-wojpawlik" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#platform-wojpawlik" title="Packaging/porting to new platform">📦</a> <a href="#tool-wojpawlik" title="Tools">🔧</a></td>
|
|
135
142
|
<td align="center"><a href="https://github.com/MegaITA"><img src="https://avatars.githubusercontent.com/u/32493080?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alessandro Bertozzi</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=MegaITA" title="Documentation">📖</a></td>
|
|
136
143
|
<td align="center"><a href="https://trgwii.no/"><img src="https://avatars.githubusercontent.com/u/11262022?v=4?s=100" width="100px;" alt=""/><br /><sub><b>trgwii</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=trgwii" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Atrgwii" title="Reviewed Pull Requests">👀</a></td>
|
|
@@ -148,7 +155,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
148
155
|
</tr>
|
|
149
156
|
<tr>
|
|
150
157
|
<td align="center"><a href="https://lungers.com/"><img src="https://avatars.githubusercontent.com/u/32808683?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Andrew Lane</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3AAndrewLaneX" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AAndrewLaneX" title="Reviewed Pull Requests">👀</a></td>
|
|
151
|
-
<td align="center"><a href="https://github.com/code-withAshish"><img src="https://avatars.githubusercontent.com/u/73625149?v=4?s=100" width="100px;" alt=""/><br /><sub><b>code-withAshish</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=code-withAshish" title="Documentation">📖</a></td>
|
|
158
|
+
<td align="center"><a href="https://github.com/code-withAshish"><img src="https://avatars.githubusercontent.com/u/73625149?v=4?s=100" width="100px;" alt=""/><br /><sub><b>code-withAshish</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=code-withAshish" title="Documentation">📖</a> <a href="#question-code-withAshish" title="Answering Questions">💬</a></td>
|
|
152
159
|
<td align="center"><a href="https://beta.ku-di.com/waptik"><img src="https://avatars.githubusercontent.com/u/1687551?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stephane Mensah</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Awaptik" title="Bug reports">🐛</a> <a href="#plugin-waptik" title="Plugin/utility libraries">🔌</a></td>
|
|
153
160
|
<td align="center"><a href="https://github.com/Asaku01"><img src="https://avatars.githubusercontent.com/u/29716396?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Asaku01</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Asaku01" title="Documentation">📖</a></td>
|
|
154
161
|
<td align="center"><a href="https://github.com/ppsimn"><img src="https://avatars.githubusercontent.com/u/88509883?v=4?s=100" width="100px;" alt=""/><br /><sub><b>ppsimn</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Appsimn" title="Bug reports">🐛</a></td>
|
|
@@ -209,6 +216,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
209
216
|
<td align="center"><a href="https://github.com/Mi3liX9"><img src="https://avatars.githubusercontent.com/u/26169870?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mighty Ali</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Mi3liX9" title="Code">💻</a></td>
|
|
210
217
|
<td align="center"><a href="https://oott123.com"><img src="https://avatars.githubusercontent.com/u/905663?v=4?s=100" width="100px;" alt=""/><br /><sub><b>三三</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Aoott123" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=oott123" title="Code">💻</a></td>
|
|
211
218
|
</tr>
|
|
219
|
+
<tr>
|
|
220
|
+
<td align="center"><a href="http://roz.ninja"><img src="https://avatars.githubusercontent.com/u/3948961?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Roz</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Aroziscoding" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=roziscoding" title="Code">💻</a></td>
|
|
221
|
+
</tr>
|
|
212
222
|
</table>
|
|
213
223
|
|
|
214
224
|
<!-- markdownlint-restore -->
|
|
@@ -3,14 +3,14 @@ import { type IncomingMessage, type ServerResponse } from "http";
|
|
|
3
3
|
export declare const adapters: {
|
|
4
4
|
http: (req: IncomingMessage, res: ServerResponse) => {
|
|
5
5
|
update: Promise<any>;
|
|
6
|
-
header: string;
|
|
6
|
+
header: string | undefined;
|
|
7
7
|
end: () => ServerResponse;
|
|
8
8
|
respond: (json: string) => ServerResponse;
|
|
9
9
|
unauthorized: () => ServerResponse;
|
|
10
10
|
};
|
|
11
11
|
https: (req: IncomingMessage, res: ServerResponse) => {
|
|
12
12
|
update: Promise<any>;
|
|
13
|
-
header: string;
|
|
13
|
+
header: string | undefined;
|
|
14
14
|
end: () => ServerResponse;
|
|
15
15
|
respond: (json: string) => ServerResponse;
|
|
16
16
|
unauthorized: () => ServerResponse;
|
|
@@ -3,19 +3,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.defaultAdapter = exports.adapters = void 0;
|
|
4
4
|
const SECRET_HEADER = "X-Telegram-Bot-Api-Secret-Token";
|
|
5
5
|
/** Node.js native 'http' and 'https' modules */
|
|
6
|
-
const http = (req, res) =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
const http = (req, res) => {
|
|
7
|
+
const secretHeaderFromRequest = req.headers[SECRET_HEADER.toLowerCase()];
|
|
8
|
+
return {
|
|
9
|
+
update: new Promise((resolve, reject) => {
|
|
10
|
+
const chunks = [];
|
|
11
|
+
req.on("data", (chunk) => chunks.push(chunk))
|
|
12
|
+
.once("end", () => {
|
|
13
|
+
const raw = Buffer.concat(chunks).toString("utf-8");
|
|
14
|
+
resolve(JSON.parse(raw));
|
|
15
|
+
})
|
|
16
|
+
.once("error", reject);
|
|
17
|
+
}),
|
|
18
|
+
header: Array.isArray(secretHeaderFromRequest)
|
|
19
|
+
? secretHeaderFromRequest[0]
|
|
20
|
+
: secretHeaderFromRequest,
|
|
21
|
+
end: () => res.end(),
|
|
22
|
+
respond: (json) => res
|
|
23
|
+
.writeHead(200, { "Content-Type": "application/json" })
|
|
24
|
+
.end(json),
|
|
25
|
+
unauthorized: () => res.writeHead(401).end("secret token is wrong"),
|
|
26
|
+
};
|
|
27
|
+
};
|
|
19
28
|
/** express web framework */
|
|
20
29
|
const express = (req, res) => ({
|
|
21
30
|
update: Promise.resolve(req.body),
|
|
@@ -6,14 +6,14 @@ declare const adapters: {
|
|
|
6
6
|
callback: FrameworkAdapter;
|
|
7
7
|
http: (req: import("http").IncomingMessage, res: import("http").ServerResponse) => {
|
|
8
8
|
update: Promise<any>;
|
|
9
|
-
header: string;
|
|
9
|
+
header: string | undefined;
|
|
10
10
|
end: () => import("http").ServerResponse;
|
|
11
11
|
respond: (json: string) => import("http").ServerResponse;
|
|
12
12
|
unauthorized: () => import("http").ServerResponse;
|
|
13
13
|
};
|
|
14
14
|
https: (req: import("http").IncomingMessage, res: import("http").ServerResponse) => {
|
|
15
15
|
update: Promise<any>;
|
|
16
|
-
header: string;
|
|
16
|
+
header: string | undefined;
|
|
17
17
|
end: () => import("http").ServerResponse;
|
|
18
18
|
respond: (json: string) => import("http").ServerResponse;
|
|
19
19
|
unauthorized: () => import("http").ServerResponse;
|
|
@@ -21,7 +21,10 @@ declare const adapters: {
|
|
|
21
21
|
express: (req: any, res: any) => {
|
|
22
22
|
update: Promise<any>;
|
|
23
23
|
header: any;
|
|
24
|
-
end: () => any;
|
|
24
|
+
end: () => any; /**
|
|
25
|
+
* Ends the request immediately without body, called after every request
|
|
26
|
+
* unless a webhook reply was performed
|
|
27
|
+
*/
|
|
25
28
|
respond: (json: string) => void;
|
|
26
29
|
unauthorized: () => void;
|
|
27
30
|
};
|
|
@@ -44,6 +47,7 @@ declare const adapters: {
|
|
|
44
47
|
header: any;
|
|
45
48
|
end: () => any;
|
|
46
49
|
respond: (json: string) => any;
|
|
50
|
+
/** An optional string to compare to X-Telegram-Bot-Api-Secret-Token */
|
|
47
51
|
unauthorized: () => any;
|
|
48
52
|
};
|
|
49
53
|
"aws-lambda": (event: any, _context: any, callback: any) => {
|