Skip to content

Commit

Permalink
fixed default reply
Browse files Browse the repository at this point in the history
  • Loading branch information
orzklv committed May 23, 2023
1 parent ceeefb2 commit 8058c96
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
16 changes: 13 additions & 3 deletions hooks/isReply.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import { Context, NextFunction } from "../deps.ts";
import { reply } from "../utils/sender.ts";
import { Context, NextFunction } from "../deps.ts";
import topics from "../topics.json" assert { type: "json" };

export default async (ctx: Context, next: NextFunction) => {
const replyMessage = ctx.message?.reply_to_message;
if (!replyMessage) {
if (!ctx.message?.is_topic_message) {
return await reply(
ctx,
`⚠️ <b>Biz topicda emasmiz bu komandani ishlatish uchun!</b>`,
);
}

if (
!ctx.message?.reply_to_message ||
Object.values(topics).includes(ctx.message!.reply_to_message!.message_id)
) {
return await reply(ctx, `↪ Reply bilan ko'rsatingchi habarni!`);
}
await next();
Expand Down
18 changes: 18 additions & 0 deletions topics.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"asosiy": 1,
"showoff": 9420,
"offtopic": 9400,
"compiler-development": 11122,
"bots": 11090,
"rustlings": 9322,
"type-theory": 9318,
"embedded": 9312,
"data-science": 9321,
"game-dev": 9323,
"web-dev": 9314,
"software-dev": 9316,
"telegram-bots": 9315,
"tauri": 9917,
"machine-learning": 9320,
"deno": 9455
}

0 comments on commit 8058c96

Please sign in to comment.