Advertisement
DimaDevelop

Untitled

May 5th, 2023
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. from flask import Flask, request, json
  2. from settings import confirmation_token, token
  3.  
  4. import vk_api
  5. import time
  6.  
  7. app = Flask(__name__)
  8.  
  9. api = vk_api.VkApi(token=token).get_api()
  10.  
  11. @app.route('/', methods=['POST'])
  12. def processing():
  13.     data = json.loads(request.data)
  14.     if 'type' not in data.keys():
  15.         return 'not vk'
  16.     if data['type'] == 'confirmation':
  17.         return confirmation_token
  18.     elif data['type'] == 'group_join':
  19.         send_message = "Спасибо что подписались в наше сообщество."
  20.         api.messages.send(user_id=data['object']['user_id'], message=send_message, random_id=0)
  21.         return 'ok'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement