|
1 | 1 | import { Logger } from "../config/logger"; |
2 | 2 | import { SafeExecution } from "../decorators/SafeExecution"; |
3 | 3 | import { Middleware } from "./mid"; |
4 | | -const logger = new Logger({file:"ActionFilter.log",level:'info',timestampFormat:'locale'}) |
| 4 | +const logger = new Logger({ |
| 5 | + file: "ActionFilter.log", |
| 6 | + level: "info", |
| 7 | + timestampFormat: "locale", |
| 8 | +}); |
5 | 9 | export class ActionFilter extends Middleware { |
6 | 10 | @SafeExecution() |
7 | 11 | /** |
@@ -29,7 +33,7 @@ export class ActionFilter extends Middleware { |
29 | 33 | */ |
30 | 34 | async userInGroup(): Promise<void> { |
31 | 35 | const userId = this.ctx.message?.reply_to_message?.from?.id; |
32 | | - |
| 36 | + |
33 | 37 | if (!userId) { |
34 | 38 | await this.ctx.reply( |
35 | 39 | "Unable to determine the user ID. Please ensure you are replying to a valid user.", |
@@ -84,15 +88,20 @@ export class ActionFilter extends Middleware { |
84 | 88 |
|
85 | 89 | return this.nxt(); |
86 | 90 | } |
87 | | - isSupergroupOrChannel() { |
| 91 | + isValidChatType() { |
88 | 92 | const chat = this.ctx.chat; |
| 93 | + console.log("chat:", chat); |
89 | 94 |
|
90 | | - if (chat && (chat.type === "supergroup" || chat.type === "channel")) { |
91 | | - return this.nxt(); |
92 | | - } else { |
93 | | - this.ctx.reply( |
94 | | - "This command can only be used in supergroups or channels." |
95 | | - ); |
| 95 | + if (chat) { |
| 96 | + if (chat.type === "supergroup" || chat.type === "channel") { |
| 97 | + return this.nxt(); |
| 98 | + } else if (chat.type === "private") { |
| 99 | + this.ctx.reply( |
| 100 | + "This command can only be used in supergroups or channels." |
| 101 | + ); |
| 102 | + } else { |
| 103 | + this.ctx.reply("This command is not allowed in this type of chat."); |
| 104 | + } |
96 | 105 | } |
97 | 106 | } |
98 | 107 | } |
0 commit comments