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

Support for scheduling messages #1979

Closed
TacoV opened this issue Apr 9, 2024 · 1 comment
Closed

Support for scheduling messages #1979

TacoV opened this issue Apr 9, 2024 · 1 comment

Comments

@TacoV
Copy link

TacoV commented Apr 9, 2024

I'd like to use schedule_date as defined in the API: https://core.telegram.org/api/scheduled-messages.
It appears not to be implemented as is.

Context

I'm scheduling messages using a cron job. Ideally the cron does not run very often, eg every 30 minutes, and we can then schedule the upcoming 30 minutes worth of messages precisely using Telegram's in-built scheduling functions.

  • Telegraf.js Version: 4.16.3
  • Node.js Version: 20.11.0

Minimal Example Code Reproducing the Issue

import { Telegraf } from "telegraf";
const bot = new Telegraf( token );

bot.telegram.sendMessage(
  123456,
  "This is a test",
  {
    schedule_date: 1712662000
  }
)

Expected Behavior

This snippet will run without error and in chat 123456, at timestamp 1712662000 a message will pop up.

Current Behavior

Even before running, this results in a Typescript error (emphasis by me):

Object literal may only specify known properties, and 'schedule_date' does not exist in type 'Omit<{ chat_id: string | number; message_thread_id?: number | undefined; text: string; parse_mode?: ParseMode | undefined; entities?: MessageEntity[] | undefined; ... 4 more ...; reply_markup?: InlineKeyboardMarkup | ... 3 more ... | undefined; }, "chat_id" | "text">'.ts(2353)
(property) schedule_date: number

@TacoV
Copy link
Author

TacoV commented Apr 9, 2024

I'm afraid I looked at and linked to the incorrect reference documentation. The Bot API seems to lack this parameter, sadly.

https://core.telegram.org/bots/api#sendmessage

@TacoV TacoV closed this as completed Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant