问题
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