Stack Overflow на русском Asked on December 9, 2021
from flask import Flask, request, json
import vk_api
import random
vk = vk_api.VkApi(token="мой токен")
app = Flask(__name__)
@app.route('/', methods = ["POST"])
def main():
data = json.loads(request.data)
if data["type"] == "confirmation":
return "код коллбек апи"
elif data["type"] == "message_new":
object = data["object"]
id = object["peer_id"]
body = object["text"]
if body.lower() == "штирлиц проверка":
vk.method("messages.send", {"peer_id": id, "message": "Alles ist sehr normal.", "random_id": random.randint(0)})
return "ok"
собственно вот мой код
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP