@grammyjs/commands 1.0.9 → 1.2.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.
@@ -1,7 +1,7 @@
1
- import { Context, Middleware } from "../deps.node.js";
1
+ import { ChatTypeContext, Context, Middleware } from "../deps.node.js";
2
2
  import { CommandOptions } from "../types.js";
3
3
  import { MaybeArray } from "./array.js";
4
- export declare function isAdmin(ctx: Context): Promise<boolean>;
4
+ export declare function isAdmin(ctx: ChatTypeContext<Context, "group" | "supergroup">): true | Promise<boolean>;
5
5
  export declare function isMiddleware<C extends Context = Context>(obj: unknown): obj is MaybeArray<Middleware<C>>;
6
6
  export declare function isCommandOptions(obj: unknown): obj is Partial<CommandOptions>;
7
7
  export declare function matchesPattern(value: string, pattern: string | RegExp, ignoreCase?: boolean): boolean;
@@ -6,6 +6,11 @@ exports.isCommandOptions = isCommandOptions;
6
6
  exports.matchesPattern = matchesPattern;
7
7
  const deps_node_js_1 = require("../deps.node.js");
8
8
  function isAdmin(ctx) {
9
+ var _a;
10
+ if (((_a = ctx.senderChat) === null || _a === void 0 ? void 0 : _a.id) === ctx.chat.id) {
11
+ // anonymous admin
12
+ return true;
13
+ }
9
14
  return ctx
10
15
  .getAuthor()
11
16
  .then((author) => ["administrator", "creator"].includes(author.status));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grammyjs/commands",
3
- "version": "1.0.9",
3
+ "version": "1.2.0",
4
4
  "description": "grammY Commands Plugin",
5
5
  "main": "out/mod.js",
6
6
  "scripts": {