python + vk_api 的 Vk 聊天机器人

Vk chat bot with python + vk_api

我正在尝试做vk聊天机器人,但是有一个例外

import vk_api
import time
import json

token = 'ea8d297a7***3fd45e98fd0f2b0215954d854a0'
vk = vk_api.VkApi(token=token)
vk._auth_token() # vk.auth() doesn't work

print(  # Getting chat info
        vk.method('messages.getConversations')
        )
keyboard = {'one_time':True,
            'buttons':
            [
                [
                    {'action':
                        {'type':'text', 
                        'label':'This is keyboard!'},
                    'color':'Positive',
                    }
                ]
            ]
            }
my_id = vk.method('messages.getConversations')['items'][0]['last_message']['from_id']
# my_id - id of the last message in the chat
vk.method('messages.send', 
            {'user_id':my_id, 
            'message':'Keyboard to the studio!',
            'keyboard':str(json.dumps(keyboard))
            })

vk_api.exceptions.ApiError: [912] This is a chat bot feature, change this status in settings

vk.method('messages.send', ..... 发生了。 我想用键盘发送用户消息。我该怎么做以及为什么会出现此错误?感谢您的帮助!

您应该转到 "Community Management" - > "Messages" - > "Bot Settings" 并启用“机器人功能”