Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Скрипт был создан автором канала IT THINGS: https://www.youtube.com/c/ITTHINGS
- 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": "Привет!", "random_id": random.randint(1, 2147483647)})
- elif body.lower() == "я не подписан на канал it things":
- vk.method("messages.send", {"peer_id": id, "message": "Казнить грешника!", "random_id": random.randint(1, 2147483647)})
- else:
- vk.method("messages.send", {"peer_id": id, "message": "Не понял тебя!", "random_id": random.randint(1, 2147483647)})
- return "ok"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement