Telegram bot api not able to restrict user for 24 hours

你离开我真会死。 提交于 2021-01-29 05:58:39

问题


Looking for solution to restrict chat member with restrictChatMember() but unfortunately it still restrict the user forever not for 24 hours.

const { date:joinDate } = ctx.message;

const releaseDate = moment.unix(joinDate).add(1, 'day');
ctx.telegram.restrictChatMember(
  ctx.chat.id,
  memberID,
  releaseDate,
  false,
  false,
  false,
  false
);

Reference: https://core.telegram.org/bots/api#restrictchatmember


回答1:


You're passing a moment object back into the function, not an UNIX timestamp like the docs you quoted say:

until_date: optional integer
Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever.

Try

ctx.telegram.restrictChatMember(
  ctx.chat.id,
  memberID,
  releaseDate.unix(),
  ...


来源:https://stackoverflow.com/questions/53780790/telegram-bot-api-not-able-to-restrict-user-for-24-hours

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!