Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ctx.reply to telegram.api.message wrapper #27

Open
wants to merge 1 commit into
base: nightly
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions app/functions/api/telegram/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type { Context, RawApi } from "grammy";
import type { MasterInterface } from "@app/types/master.interfaces";
import type { SettingsInterface } from "@app/types/settings.interfaces";
import { Other } from "grammy/out/core/api";
import { Message } from "grammy/out/types.node";

const getUsername = (ctx: Context): string => {
const username = ctx?.update?.message?.from?.username;
Expand Down Expand Up @@ -140,8 +141,6 @@ const send = async (
if (group_id && text) {
let message;

logger.error(JSON.stringify(options), "message.ts:send()");

const thread_id = getThreadID(ctx);
if (thread_id !== 0) {
options.message_thread_id = thread_id;
Expand Down Expand Up @@ -225,6 +224,14 @@ const getDate = (gmt = 60): Date => {
return new Date(addMinutes(new Date(), gmt));
};

const reply = async (
ctx: Context,
messageText: string,
options: Other<RawApi, "sendMessage", "chat_id" | "text">,
): Promise<Message> => {
return await ctx.reply(messageText, options);
};

export {
getFullUser,
getUsername,
Expand All @@ -248,6 +255,7 @@ export {
removeMessageMarkup,
editMessageReplyMarkup,
getDate,
reply,
};
export default {
getFullUser,
Expand All @@ -272,4 +280,5 @@ export default {
removeMessageMarkup,
editMessageReplyMarkup,
getDate,
reply,
};