代码之家  ›  专栏  ›  技术社区  ›  Mo.

电报机器人api无法限制用户24小时

  •  0
  • Mo.  · 技术社区  · 7 年前

    正在寻找限制聊天成员的解决方案 restrictChatMember() 但不幸的是,它仍然永远限制用户,而不是24小时。

    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
    );
    

    参考: https://core.telegram.org/bots/api#restrictchatmember

    1 回复  |  直到 7 年前
        1
  •  2
  •   AKX Bryan Oakley    7 年前

    你通过了一个 moment 对象返回到函数中,而不是像您引用的文档所说的UNIX时间戳:

    until_date :可选整数
    取消用户限制的日期,unix时间。如果用户被限制的时间超过366天或从当前时间起少于30秒,则视为永久限制。

    尝试

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