You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Viberbot 1.0.12中InputFieldState不生效,如何隐藏输入框?

Viberbot 1.0.12中InputFieldState设为hidden无效的解决办法

在Viberbot 1.0.12版本中,将键盘的InputFieldState设置为"hidden"后,输入框和键盘并未按预期消失,相关代码如下:

def handle_message(sender_id):
    message = KeyboardMessage(keyboard=create_menu())
    viber_api.send_messages(sender_id, [message])
def create_menu():
    keyboard = {
        "Type": "keyboard",
        "InputFieldState": "hidden",
        "Buttons": [
            {
                "Columns": 2,
                "Rows": 1,
                "BgColor": "#e6f5ff",
                "Text": "<b>Button 1</b>",
                "TextSize": "large",
                "TextVAlign": "middle",
                "TextHAlign": "center",
                "ActionType": "reply",
                "ActionBody": "button1",
                "Silent": True
            },
        ],
    }

    return keyboard

可能的解决方向:

  • 替换参数值:部分Viber客户端版本对"hidden"支持不完善,尝试将InputFieldState改为"minimized",虽然无法完全隐藏,但能最小化输入区域和键盘。
  • 检查客户端版本:用户使用的Viber客户端版本过低可能导致参数不生效,建议测试最新版客户端。
  • 升级Viberbot库:旧版本的Viberbot库可能存在参数解析bug,升级到最新版本大概率能解决问题。
  • 验证键盘格式:确保键盘的Type字段拼写正确,Buttons数组格式合规,格式错误会导致参数不被解析。

修改后的代码示例(替换为minimized):

def create_menu():
    keyboard = {
        "Type": "keyboard",
        "InputFieldState": "minimized",
        "Buttons": [
            {
                "Columns": 2,
                "Rows": 1,
                "BgColor": "#e6f5ff",
                "Text": "<b>Button 1</b>",
                "TextSize": "large",
                "TextVAlign": "middle",
                "TextHAlign": "center",
                "ActionType": "reply",
                "ActionBody": "button1",
                "Silent": True
            },
        ],
    }

    return keyboard

内容的提问来源于stack exchange,提问作者Vitaliy Velichyshi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 12:15:06