@grammyjs/commands 1.1.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/out/command-group.js +7 -2
- package/out/command.js +1 -1
- package/out/utils/checks.d.ts +2 -2
- package/out/utils/checks.js +5 -0
- package/package.json +1 -1
package/out/command-group.js
CHANGED
|
@@ -43,8 +43,13 @@ class CommandGroup {
|
|
|
43
43
|
this._languages.clear();
|
|
44
44
|
this._scopes.clear();
|
|
45
45
|
this._commands.forEach((command) => {
|
|
46
|
-
|
|
47
|
-
this._addCommandToScope(
|
|
46
|
+
if (command.scopes.length === 0) {
|
|
47
|
+
this._addCommandToScope({ type: "default" }, command);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
for (const scope of command.scopes) {
|
|
51
|
+
this._addCommandToScope(scope, command);
|
|
52
|
+
}
|
|
48
53
|
}
|
|
49
54
|
for (const language of command.languages.keys()) {
|
|
50
55
|
this._languages.add(language);
|
package/out/command.js
CHANGED
|
@@ -38,7 +38,7 @@ class Command {
|
|
|
38
38
|
if (((_a = this._options.prefix) === null || _a === void 0 ? void 0 : _a.trim()) === "")
|
|
39
39
|
this._options.prefix = "/";
|
|
40
40
|
this._languages.set("default", { name: name, description });
|
|
41
|
-
if (
|
|
41
|
+
if (this._hasHandler) {
|
|
42
42
|
this.addToScope({ type: "default" }, handler);
|
|
43
43
|
}
|
|
44
44
|
return this;
|
package/out/utils/checks.d.ts
CHANGED
|
@@ -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;
|
package/out/utils/checks.js
CHANGED
|
@@ -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));
|