如何在event.from方法或类似的方法中通过ID寻址特定用户?

时间:2019-05-05 06:23:27

标签: python api vk vk-sdk

我对其中有一个测验的VK机器人进行了编程,遇到了一个问题,即该机器人从一个不响应测验的人那里读取消息,并认为该人以测验模式回答了该问题,并回答了人在测验中回答不正确,即使他没有写任何东西。救命!我在互联网上搜索了该问题的解决方案,但是两天后我什么都没找到。

event.from没有此方法

if viktorina_ready == 1 and python == 1 and right_ans_py == 0 and ans_give_py == 0: #It works as a test to see if a person enters quiz mode.
    person_py = 1
    person_id_py = event.user_id
    vk_session.method('messages.send', {'user_id': person_id_py, 'message': '''question1''', 'random_id': random.randint(-2147483648, +2147483648),"keyboard": keyboards.create_keyboard_4('a', 'b', 'c','d')})
    ans_give_py = 1
    ans_give_true_py = 0
elif viktorina_ready == 1 and python == 1 and right_ans_py == 0 and (response == 'a' or response == 'a'): #It works as a test to see if a person give right answer
    right_ans_py = 1
    ans_give_true_py = 1
    ans_give_py = 0
    vk_session.method('messages.send', {'user_id': person_id_py, 'message': 'right','random_id': random.randint(-2147483648, +2147483648)})
elif viktorina_ready == 1 and python == 1 and right_ans_py == 0 and (response != 'a' or response != 'a') and ans_give_true_py == 0: #It works as a test to see if a person give wrong answer
    vk_session.method('messages.send', {'user_id': person_id_py, 'message': '''wrong''', 'random_id': random.randint(-2147483648, +2147483648)})
    viktorina = 0
    viktorina_ready = 0
    python_py = 0
    right_ans_py = 0
    ans_give_py = 0
    ans_give_true_py = 0
    person_py = 0
    person_id_py = ""

将答案提供给处于测验模式的用户,尽管他什么也没有回答。我发现这是由于缺少对发送消息的用户的ID的验证所致。

0 个答案:

没有答案