Files
tg-chat-bot/commands/ping.ts
T
2021-03-04 03:33:54 +03:00

22 lines
717 B
TypeScript

import {Command} from "./base/command";
import {MessageContext, setStartTime, startTime} from "../base/base";
import {sendMessage} from "../base/net";
export class Ping implements Command {
regexp = /^\/ping/i
title: '/ping'
description: 'задержа между получаемым сообщением и отправленным'
async execute(context: MessageContext) {
await sendMessage(context, 'pong').then(async () => {
const nowMillis = new Date().getMilliseconds()
const change = Math.abs(nowMillis - startTime)
await sendMessage(context, `ping: ${change} ms`).then(() => {
setStartTime(0)
})
})
}
}