grammy 1.38.2 → 1.38.3

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
@@ -323,7 +323,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
323
323
  <td align="center" valign="top" width="11.11%"><a href="https://github.com/ikelax"><img src="https://avatars.githubusercontent.com/u/163678144?v=4?s=100" width="100px;" alt="ikelax"/><br /><sub><b>ikelax</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=ikelax" title="Documentation">📖</a></td>
324
324
  <td align="center" valign="top" width="11.11%"><a href="http://zeokku.com"><img src="https://avatars.githubusercontent.com/u/22231294?v=4?s=100" width="100px;" alt="Lutymane"/><br /><sub><b>Lutymane</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Lutymane" title="Code">💻</a></td>
325
325
  <td align="center" valign="top" width="11.11%"><a href="https://thadaw.com"><img src="https://avatars.githubusercontent.com/u/3647850?v=4?s=100" width="100px;" alt="Thada Wangthammang"/><br /><sub><b>Thada Wangthammang</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Amildronize" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=mildronize" title="Tests">⚠️</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Amildronize" title="Reviewed Pull Requests">👀</a></td>
326
- <td align="center" valign="top" width="11.11%"><a href="https://github.com/rtyt3000"><img src="https://avatars.githubusercontent.com/u/123096124?v=4?s=100" width="100px;" alt="Konstantin Ryshkov"/><br /><sub><b>Konstantin Ryshkov</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Artyt3000" title="Bug reports">🐛</a></td>
326
+ <td align="center" valign="top" width="11.11%"><a href="https://github.com/rtyt3000"><img src="https://avatars.githubusercontent.com/u/123096124?v=4?s=100" width="100px;" alt="Konstantin Ryshkov"/><br /><sub><b>Konstantin Ryshkov</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Artyt3000" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=rtyt3000" title="Documentation">📖</a></td>
327
327
  <td align="center" valign="top" width="11.11%"><a href="https://github.com/mishkatik"><img src="https://avatars.githubusercontent.com/u/101044644?v=4?s=100" width="100px;" alt="mish"/><br /><sub><b>mish</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Amishkatik" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=mishkatik" title="Code">💻</a></td>
328
328
  <td align="center" valign="top" width="11.11%"><a href="https://github.com/eddienubes"><img src="https://avatars.githubusercontent.com/u/53977359?v=4?s=100" width="100px;" alt="Dmytro Tiapukhin"/><br /><sub><b>Dmytro Tiapukhin</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=eddienubes" title="Documentation">📖</a></td>
329
329
  </tr>
@@ -331,6 +331,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
331
331
  <td align="center" valign="top" width="11.11%"><a href="https://github.com/Arctomachine"><img src="https://avatars.githubusercontent.com/u/29041820?v=4?s=100" width="100px;" alt="Alexander"/><br /><sub><b>Alexander</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Arctomachine" title="Documentation">📖</a></td>
332
332
  <td align="center" valign="top" width="11.11%"><a href="https://github.com/OfficialCodinary"><img src="https://avatars.githubusercontent.com/u/133005277?v=4?s=100" width="100px;" alt="Codinary"/><br /><sub><b>Codinary</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AOfficialCodinary" title="Reviewed Pull Requests">👀</a></td>
333
333
  <td align="center" valign="top" width="11.11%"><a href="https://github.com/dotvhs"><img src="https://avatars.githubusercontent.com/u/681416?v=4?s=100" width="100px;" alt=".vhs"/><br /><sub><b>.vhs</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Adotvhs" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Adotvhs" title="Reviewed Pull Requests">👀</a></td>
334
+ <td align="center" valign="top" width="11.11%"><a href="https://agou.im/"><img src="https://avatars.githubusercontent.com/u/55237525?v=4?s=100" width="100px;" alt="agoudbg"/><br /><sub><b>agoudbg</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Aagoudbg" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=agoudbg" title="Code">💻</a></td>
334
335
  </tr>
335
336
  </tbody>
336
337
  </table>
package/out/context.d.ts CHANGED
@@ -1279,7 +1279,9 @@ export declare class Context implements RenamedUpdate {
1279
1279
  */
1280
1280
  editMessageText(text: string, other?: Other<"editMessageText", "chat_id" | "message_id" | "inline_message_id" | "text">, signal?: AbortSignal): Promise<true | (Update.Edited & Message.CommonMessage & {
1281
1281
  text: string;
1282
- })>;
1282
+ } & Partial<{
1283
+ entities: MessageEntity[];
1284
+ }>)>;
1283
1285
  /**
1284
1286
  * Context-aware alias for `api.editMessageCaption`. Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
1285
1287
  *
@@ -77,11 +77,11 @@ export type CloudflareAdapter = (event: {
77
77
  }) => ReqResHandler;
78
78
  export type CloudflareModuleAdapter = (request: Request) => ReqResHandler<Response>;
79
79
  export type ElysiaAdapter = (ctx: {
80
- body: Update;
80
+ body: unknown;
81
81
  headers: Record<string, string | undefined>;
82
82
  set: {
83
- headers: Record<string, string>;
84
- status: number;
83
+ headers: Record<string, string | number>;
84
+ status?: string | number;
85
85
  };
86
86
  }) => ReqResHandler<string>;
87
87
  export type ExpressAdapter = (req: {
@@ -167,7 +167,7 @@ const fastify = (request, reply) => ({
167
167
  return request.body;
168
168
  },
169
169
  header: request.headers[SECRET_HEADER_LOWERCASE],
170
- end: () => reply.status(200).send(),
170
+ end: () => reply.send(""),
171
171
  respond: (json) => reply.headers({ "Content-Type": "application/json" }).send(json),
172
172
  unauthorized: () => reply.code(401).send(WRONG_TOKEN_ERROR),
173
173
  });
package/out/core/api.d.ts CHANGED
@@ -1134,7 +1134,9 @@ export declare class Api<R extends RawApi = RawApi> {
1134
1134
  */
1135
1135
  editMessageText(chat_id: number | string, message_id: number, text: string, other?: Other<R, "editMessageText", "chat_id" | "message_id" | "inline_message_id" | "text">, signal?: AbortSignal): Promise<true | (import("@grammyjs/types/update.js").Update.Edited & import("@grammyjs/types/message.js").Message.CommonMessage & {
1136
1136
  text: string;
1137
- })>;
1137
+ } & Partial<{
1138
+ entities: import("@grammyjs/types/message.js").MessageEntity[];
1139
+ }>)>;
1138
1140
  /**
1139
1141
  * Use this method to edit text and game inline messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
1140
1142
  *
@@ -1146,7 +1148,9 @@ export declare class Api<R extends RawApi = RawApi> {
1146
1148
  */
1147
1149
  editMessageTextInline(inline_message_id: string, text: string, other?: Other<R, "editMessageText", "chat_id" | "message_id" | "inline_message_id" | "text">, signal?: AbortSignal): Promise<true | (import("@grammyjs/types/update.js").Update.Edited & import("@grammyjs/types/message.js").Message.CommonMessage & {
1148
1150
  text: string;
1149
- })>;
1151
+ } & Partial<{
1152
+ entities: import("@grammyjs/types/message.js").MessageEntity[];
1153
+ }>)>;
1150
1154
  /**
1151
1155
  * Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.
1152
1156
  *
package/out/web.mjs CHANGED
@@ -1972,50 +1972,64 @@ function setup(env) {
1972
1972
  createDebug.namespaces = namespaces;
1973
1973
  createDebug.names = [];
1974
1974
  createDebug.skips = [];
1975
- let i;
1976
- const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/);
1977
- const len = split.length;
1978
- for(i = 0; i < len; i++){
1979
- if (!split[i]) {
1980
- continue;
1975
+ const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
1976
+ for (const ns of split){
1977
+ if (ns[0] === "-") {
1978
+ createDebug.skips.push(ns.slice(1));
1979
+ } else {
1980
+ createDebug.names.push(ns);
1981
1981
  }
1982
- namespaces = split[i].replace(/\*/g, ".*?");
1983
- if (namespaces[0] === "-") {
1984
- createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$"));
1982
+ }
1983
+ }
1984
+ function matchesTemplate(search, template) {
1985
+ let searchIndex = 0;
1986
+ let templateIndex = 0;
1987
+ let starIndex = -1;
1988
+ let matchIndex = 0;
1989
+ while(searchIndex < search.length){
1990
+ if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
1991
+ if (template[templateIndex] === "*") {
1992
+ starIndex = templateIndex;
1993
+ matchIndex = searchIndex;
1994
+ templateIndex++;
1995
+ } else {
1996
+ searchIndex++;
1997
+ templateIndex++;
1998
+ }
1999
+ } else if (starIndex !== -1) {
2000
+ templateIndex = starIndex + 1;
2001
+ matchIndex++;
2002
+ searchIndex = matchIndex;
1985
2003
  } else {
1986
- createDebug.names.push(new RegExp("^" + namespaces + "$"));
2004
+ return false;
1987
2005
  }
1988
2006
  }
2007
+ while(templateIndex < template.length && template[templateIndex] === "*"){
2008
+ templateIndex++;
2009
+ }
2010
+ return templateIndex === template.length;
1989
2011
  }
1990
2012
  function disable() {
1991
2013
  const namespaces = [
1992
- ...createDebug.names.map(toNamespace),
1993
- ...createDebug.skips.map(toNamespace).map((namespace)=>"-" + namespace)
2014
+ ...createDebug.names,
2015
+ ...createDebug.skips.map((namespace)=>"-" + namespace)
1994
2016
  ].join(",");
1995
2017
  createDebug.enable("");
1996
2018
  return namespaces;
1997
2019
  }
1998
2020
  function enabled(name) {
1999
- if (name[name.length - 1] === "*") {
2000
- return true;
2001
- }
2002
- let i;
2003
- let len;
2004
- for(i = 0, len = createDebug.skips.length; i < len; i++){
2005
- if (createDebug.skips[i].test(name)) {
2021
+ for (const skip of createDebug.skips){
2022
+ if (matchesTemplate(name, skip)) {
2006
2023
  return false;
2007
2024
  }
2008
2025
  }
2009
- for(i = 0, len = createDebug.names.length; i < len; i++){
2010
- if (createDebug.names[i].test(name)) {
2026
+ for (const ns of createDebug.names){
2027
+ if (matchesTemplate(name, ns)) {
2011
2028
  return true;
2012
2029
  }
2013
2030
  }
2014
2031
  return false;
2015
2032
  }
2016
- function toNamespace(regexp) {
2017
- return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
2018
- }
2019
2033
  function coerce(val) {
2020
2034
  if (val instanceof Error) {
2021
2035
  return val.stack || val.message;
@@ -2129,7 +2143,8 @@ var browser$1 = createCommonjsModule(function(module, exports) {
2129
2143
  if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
2130
2144
  return false;
2131
2145
  }
2132
- return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
2146
+ let m;
2147
+ return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
2133
2148
  }
2134
2149
  function formatArgs2(args) {
2135
2150
  args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
@@ -2164,7 +2179,7 @@ var browser$1 = createCommonjsModule(function(module, exports) {
2164
2179
  function load2() {
2165
2180
  let r;
2166
2181
  try {
2167
- r = exports.storage.getItem("debug");
2182
+ r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
2168
2183
  } catch (error) {}
2169
2184
  if (!r && typeof process !== "undefined" && "env" in process) {
2170
2185
  r = process.env.DEBUG;
@@ -2255,7 +2270,12 @@ function toHttpError(method, sensitiveLogs) {
2255
2270
  throw new HttpError(msg, err);
2256
2271
  };
2257
2272
  }
2258
- const isWindows = globalThis.Deno?.build.os === "windows" || globalThis.navigator?.platform?.startsWith("Win") || globalThis.process?.platform?.startsWith("win") || false;
2273
+ function checkWindows() {
2274
+ const global = globalThis;
2275
+ const os = global.Deno?.build?.os;
2276
+ return typeof os === "string" ? os === "windows" : global.navigator?.platform?.startsWith("Win") ?? global.process?.platform?.startsWith("win") ?? false;
2277
+ }
2278
+ const isWindows = checkWindows();
2259
2279
  function assertPath(path) {
2260
2280
  if (typeof path !== "string") {
2261
2281
  throw new TypeError(`Path must be a string, received "${JSON.stringify(path)}"`);
@@ -2296,6 +2316,17 @@ function assertArgs(path, suffix) {
2296
2316
  throw new TypeError(`Suffix must be a string, received "${JSON.stringify(suffix)}"`);
2297
2317
  }
2298
2318
  }
2319
+ function assertArg(url) {
2320
+ url = url instanceof URL ? url : new URL(url);
2321
+ if (url.protocol !== "file:") {
2322
+ throw new TypeError(`URL must be a file URL: received "${url.protocol}"`);
2323
+ }
2324
+ return url;
2325
+ }
2326
+ function fromFileUrl(url) {
2327
+ url = assertArg(url);
2328
+ return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g, "%25"));
2329
+ }
2299
2330
  function stripTrailingSeparators(segment, isSep) {
2300
2331
  if (segment.length <= 1) {
2301
2332
  return segment;
@@ -2314,6 +2345,9 @@ function isPosixPathSeparator(code) {
2314
2345
  return code === 47;
2315
2346
  }
2316
2347
  function basename(path, suffix = "") {
2348
+ if (path instanceof URL) {
2349
+ path = fromFileUrl(path);
2350
+ }
2317
2351
  assertArgs(path, suffix);
2318
2352
  const lastSegment = lastPathSegment(path, isPosixPathSeparator);
2319
2353
  const strippedSegment = stripTrailingSeparators(lastSegment, isPosixPathSeparator);
@@ -2325,7 +2359,18 @@ function isPathSeparator(code) {
2325
2359
  function isWindowsDeviceRoot(code) {
2326
2360
  return code >= 97 && code <= 122 || code >= 65 && code <= 90;
2327
2361
  }
2362
+ function fromFileUrl1(url) {
2363
+ url = assertArg(url);
2364
+ let path = decodeURIComponent(url.pathname.replace(/\//g, "\\").replace(/%(?![0-9A-Fa-f]{2})/g, "%25")).replace(/^\\*([A-Za-z]:)(\\|$)/, "$1\\");
2365
+ if (url.hostname !== "") {
2366
+ path = `\\\\${url.hostname}${path}`;
2367
+ }
2368
+ return path;
2369
+ }
2328
2370
  function basename1(path, suffix = "") {
2371
+ if (path instanceof URL) {
2372
+ path = fromFileUrl1(path);
2373
+ }
2329
2374
  assertArgs(path, suffix);
2330
2375
  let start = 0;
2331
2376
  if (path.length >= 2) {
@@ -5267,7 +5312,7 @@ const fastify = (request, reply)=>({
5267
5312
  return request.body;
5268
5313
  },
5269
5314
  header: request.headers[SECRET_HEADER_LOWERCASE],
5270
- end: ()=>reply.status(200).send(),
5315
+ end: ()=>reply.send(""),
5271
5316
  respond: (json)=>reply.headers({
5272
5317
  "Content-Type": "application/json"
5273
5318
  }).send(json),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "grammy",
3
3
  "description": "The Telegram Bot Framework.",
4
- "version": "1.38.2",
4
+ "version": "1.38.3",
5
5
  "author": "KnorpelSenf",
6
6
  "license": "MIT",
7
7
  "engines": {
@@ -17,16 +17,16 @@
17
17
  "backport": "deno2node tsconfig.json"
18
18
  },
19
19
  "dependencies": {
20
- "@grammyjs/types": "3.22.1",
20
+ "@grammyjs/types": "3.22.2",
21
21
  "abort-controller": "^3.0.0",
22
- "debug": "^4.3.4",
22
+ "debug": "^4.4.3",
23
23
  "node-fetch": "^2.7.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/debug": "^4.1.12",
27
27
  "@types/node": "^12.20.55",
28
28
  "@types/node-fetch": "2.6.2",
29
- "deno2node": "^1.13.0"
29
+ "deno2node": "^1.16.0"
30
30
  },
31
31
  "files": [
32
32
  "out/"