小编Mad*_*yor的帖子

如何在 Joi 中添加自定义验证器功能?

我有 Joi 模式,想添加一个自定义验证器来验证默认 Joi 验证器无法实现的数据。

目前,我使用的是 Joi 16.1.7 版本

   const method = (value, helpers) => {
      // for example if the username value is (something) then it will throw an error with flowing message but it throws an error inside (value) object without error message. It should throw error inside the (error) object with a proper error message

      if (value === "something") {
        return new Error("something is not allowed as username");
      }

      // Return the value unchanged
      return value;
    }; …
Run Code Online (Sandbox Code Playgroud)

javascript validation node.js express joi

10
推荐指数
2
解决办法
2万
查看次数

在电报机器人中单击时如何更改内联按钮文本?

我在电报机器人创建方面还很陌生。我正在使用python-telegram-bot模块来构建电报机器人。我陷入了实现一个内联按钮的困境,该按钮在单击时会更改其文本。您能分享一些来源或方式吗?提前致谢。

简而言之,我的意思如下。例如,带有文本“1”的内联按钮,当我单击时我希望它更改为“2”。

def one(update, context):
    """Show new choice of buttons"""
    query = update.callback_query
    bot = context.bot
    keyboard = [
        [InlineKeyboardButton("3", callback_data=str(THREE)),
         InlineKeyboardButton("4", callback_data=str(FOUR))]
    ]
    keyboard[0][int(query)-1] = InlineKeyboardButton("X", callback_data=str(THREE))
    reply_markup = InlineKeyboardMarkup(keyboard)
    bot.edit_message_text(
        chat_id=query.message.chat_id,
        message_id=query.message.message_id,
        text="First CallbackQueryHandler, Choose a route",
        reply_markup=reply_markup
    )
    return FIRST
Run Code Online (Sandbox Code Playgroud)

python python-telegram-bot telegram-bot

5
推荐指数
1
解决办法
1万
查看次数

ffmpeg 中 -g 标志是什么意思?

我正在将 .mp4 文件转码为 hls 格式,并进入以下命令行。命令:ffmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -i input.mp4 -vf scale_npp=1280:720 -c:a copy -c:v h264_nvenc -b:v 8M -g 3 -hls_time 2 -hls_list_size 0 -f hls output.m3u8。我找不到-g标志的定义。这是什么意思?

ffmpeg

5
推荐指数
1
解决办法
6175
查看次数

是否可以为 Django 中的特定 url 添加权限

我默认使用 IsAuthenticated 权限,假设我不想更改默认权限。是否可以向特定URL授予AllowAny权限?

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/', include('user.urls')),
    path('api/section/', include('section.urls')),
    path('docs/', include_docs_urls(title='Great Soft Uz')) # I want this url to be public
]
Run Code Online (Sandbox Code Playgroud)

提前致谢

django django-rest-framework

4
推荐指数
1
解决办法
1864
查看次数

如何在 golang gin 中添加默认标头到响应?

如何向 Gin golang 返回的响应添加默认标头?我想添加Cache-Control: public, max-age=604800, immutable到我返回的每个回复中。

go go-gin

2
推荐指数
1
解决办法
6373
查看次数

在 Confluence kafka go 中读取来自 kafka 主题的消息时如何使用确认?

我正在开发一个推送通知,向客户端发送许多消息。消息被发布到主题中,订阅者从同一主题中读取消息。如果在从主题偏移量读取消息后立即出现错误,即使我无法发送消息,我的订阅者也需要读取下一条消息并发送它。我所说的错误是指服务器停机或出现严重问题。

如何阅读带有确认信息的消息?

producer-consumer go apache-kafka

1
推荐指数
1
解决办法
4395
查看次数