Answer the question
In order to leave comments, you need to log in
Why is the bot flooding?
I wrote a bot on the callback api, and it duplicates and floods with messages. Code below, return "ok" entered!
from flask import *
import time
import vk
from cleverapi import CleverApi
session = vk.Session()
api = vk.API(session, v="5.8")
admin = "296223969"
token = "token"
app = Flask(__name__)
@app.route('/', methods = ['POST'])
def hello_world():
r = request.data
data = json.loads(r)
if 'type' not in data:
return "non vk request"
if data['type'] == 'confirmation':
return 'my code'
elif data['type'] == 'message_new':
if "geo" in data['object']:
lat = data['object']['geo']['coordinates']['latitude']
lon = data['object']['geo']['coordinates']['longitude']
api.messages.send(access_token = token, user_id = data["object"]["from_id"], message = "Жду тебя через 5 секунд по координатам: Широта: "+str(lat)+", Долгота: "+str(lon))
time.sleep(5)
api.messages.send(access_token = token, user_id = data["object"]["from_id"], message = "Тряси свой телефон прямо сейчас!")
apii = CleverApi("token")
apii.bump(lat, lon)
apii = CleverApi("token")
apii.bump(lat, lon)
apii = CleverApi("token")
apii.bump(lat, lon)
apii = CleverApi("token")
apii.bump(lat, lon)
time.sleep(5)
api.messages.send(access_token = token, user_id = data["object"]["from_id"], message = "У тебя получилось бампнуться? Напиши ДА или НЕТ")
if "text" in data["object"]:
texxt = data["object"]["text"]
errorid = data["object"]["from_id"]
if texxt == "ДА":
api.messages.send(access_token = token, user_id = data["object"]["from_id"], message = "Супер!")
if texxt =="НЕТ":
api.messages.send(access_token = token, user_id = data["object"]["from_id"], message = "Это плохо :с, я отправил это админу.")
api.messages.send(access_token = token, user_id = admin, message = "У этого бампера не получился бамп: @id"+str(errorid))
elif data['type'] == 'wall_repost':
api.messages.send(access_token = token, user_id = data["object"]["from_id"], message ="Спасибо за репост! :р")
elif data["type"] == "group_join":
api.messages.send(access_token = token, user_id = data["object"]["user_id"], message ="Спасибо за то что вступил и поддерживаешь проект! с; ")
return "ok"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question