Skip to content

Commit 614043d

Browse files
committed
fix: make context.ts work
1 parent a5472bd commit 614043d

File tree

4 files changed

+9
-17
lines changed

4 files changed

+9
-17
lines changed
File renamed without changes.

bot/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ Object.defineProperty(bot.context, "botInfo", {
2525

2626
// cyclic dependency
2727
// bot/index requires context requires actions/warn requires bot/index
28-
Object.assign(bot.context, require('./context'));
28+
Object.assign(bot.context, require('./context').extn);

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"noEmit": true,
66
"noImplicitAny": false,
77
"strict": true,
8-
"target": "ES2019"
8+
"target": "ES2019",
9+
"esModuleInterop": true
910
}
1011
}

typings/context.d.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
import type {
2-
ExtraReplyMessage,
3-
Message,
4-
User,
5-
} from "telegraf/typings/telegram-types";
1+
import type { Convenience, Message, MessageId, User } from "telegraf/types";
62
import type { Context } from "telegraf";
73
import type { TgHtml } from "../utils/html";
84

95
interface DbUser {
106
status: "member" | "admin" | "banned";
117
}
128

9+
type ExtraReplyMessage = Convenience.ExtraReplyMessage;
10+
1311
export interface ContextExtensions {
1412
ban(
1513
this: ExtendedContext,
1614
options: {
1715
admin: User;
1816
reason: string;
1917
userToBan: User;
18+
msg?: Message;
2019
}
2120
): Promise<Message>;
2221
batchBan(
@@ -35,24 +34,16 @@ export interface ContextExtensions {
3534
reason: string;
3635
userToWarn: User;
3736
mode: "auto" | "manual";
37+
msg?: Message;
3838
}
3939
): Promise<Message>;
4040

4141
loggedReply(
4242
this: ExtendedContext,
4343
html: TgHtml,
44+
msg?: Message,
4445
extra?: ExtraReplyMessage
4546
): Promise<Message>;
46-
replyWithHTML(
47-
this: void,
48-
html: string | TgHtml,
49-
extra?: ExtraReplyMessage
50-
): Promise<Message>;
51-
replyWithCopy(
52-
this: ExtendedContext,
53-
content: Message,
54-
options?: ExtraReplyMessage
55-
): Promise<Message>;
5647
}
5748

5849
export type ExtendedContext = ContextExtensions &

0 commit comments

Comments
 (0)