Skip to content

Commit

Permalink
chore: finalize #230 (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
rojvv committed Jul 30, 2022
1 parent 293fb41 commit 6a2352a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions handlers/command_handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HandlerFuncParams } from "./handler.ts";
import { HandleFuncResult, HandlerFuncParams } from "./handler.ts";
import { MessageHandler } from "./message_handler.ts";
import env from "../env.ts";

Expand All @@ -12,7 +12,7 @@ export type CommandHandlerFunc<T extends object> = ({
client,
event,
...rest
}: HandlerFuncParams & T) => Promise<void>;
}: HandlerFuncParams & T) => HandleFuncResult;

export interface CommandHandlerOpts {
aliases?: string[];
Expand Down
4 changes: 3 additions & 1 deletion handlers/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { NewMessageEvent, TelegramClient } from "$grm";

export const End = Symbol();

export type HandleFuncResult = Promise<void | typeof End>;

export interface HandlerFuncParams {
client: TelegramClient;
event: NewMessageEvent;
Expand All @@ -14,5 +16,5 @@ export abstract class Handler {

abstract handle(
{ client, event }: HandlerFuncParams,
): Promise<void | typeof End>;
): HandleFuncResult;
}
4 changes: 2 additions & 2 deletions handlers/message_handler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Handler, HandlerFuncParams } from "./handler.ts";
import { HandleFuncResult, Handler, HandlerFuncParams } from "./handler.ts";

// deno-lint-ignore ban-types
export type MessageHandlerFunc<T extends object> = ({
client,
event,
...rest
}: HandlerFuncParams & T) => Promise<void>;
}: HandlerFuncParams & T) => HandleFuncResult;

// deno-lint-ignore ban-types
export class MessageHandler<T extends object> extends Handler {
Expand Down

0 comments on commit 6a2352a

Please sign in to comment.