Files
tg-chat-bot/src/commands/ping.ts
T
2026-01-12 18:13:47 +03:00

17 lines
588 B
TypeScript

import {logError, oldSendMessage} from "../util/utils";
import {Message} from "typescript-telegram-bot-api";
import {ChatCommand} from "../base/chat-command";
export class Ping implements ChatCommand {
regexp = /^\/ping/i;
title = "/ping";
description = "Ping between received and sent message";
async execute(msg: Message) {
const then = Date.now();
await oldSendMessage(msg, "pong").catch(logError);
const now = Date.now();
const diff = Math.abs(now - then);
await oldSendMessage(msg, `ping: ${diff}ms`).catch(logError);
}
}