diff --git a/.deploy/deploy-dev.yaml b/.deploy/deploy-dev.yaml index 4899bb3..efb4218 100644 --- a/.deploy/deploy-dev.yaml +++ b/.deploy/deploy-dev.yaml @@ -26,6 +26,30 @@ services: parallelism: 1 order: start-first + roulette-nginx: + image: mathwave/sprint-repo:roulette-bot + command: bot + environment: + TELEGRAM_TOKEN: $TELEGRAM_TOKEN_DEV + MONGO_HOST: "mongo.develop.sprinthub.ru" + MONGO_PASSWORD: $MONGO_PASSWORD_DEV + MINIO_HOST: "minio.develop.sprinthub.ru" + MINIO_SECRET_KEY: $MINIO_SECRET_KEY_DEV + PLATFORM_SECURITY_TOKEN: $PLATFORM_SECURITY_TOKEN + STAGE: "development" + REDIS_HOST: "redis.develop.sprinthub.ru" + REDIS_PASSWORD: $REDIS_PASSWORD_DEV + networks: + - net + - common-infra-nginx + deploy: + mode: replicated + restart_policy: + condition: any + update_config: + parallelism: 1 + order: start-first + networks: net: driver: overlay diff --git a/.deploy/deploy-prod.yaml b/.deploy/deploy-prod.yaml index e0a64e2..9128f39 100644 --- a/.deploy/deploy-prod.yaml +++ b/.deploy/deploy-prod.yaml @@ -4,6 +4,29 @@ version: "3.4" services: bot: + image: mathwave/sprint-repo:roulette-bot + command: bot + networks: + - net + environment: + TELEGRAM_TOKEN: $TELEGRAM_TOKEN_PROD + MONGO_HOST: "mongo.sprinthub.ru" + MONGO_PASSWORD: $MONGO_PASSWORD_PROD + MINIO_HOST: "minio.sprinthub.ru" + MINIO_SECRET_KEY: $MINIO_SECRET_KEY_PROD + PLATFORM_SECURITY_TOKEN: $PLATFORM_SECURITY_TOKEN + STAGE: "production" + REDIS_HOST: "redis.sprinthub.ru" + REDIS_PASSWORD: $REDIS_PASSWORD_PROD + deploy: + mode: replicated + restart_policy: + condition: any + update_config: + parallelism: 1 + order: start-first + + roulette-nginx: image: mathwave/sprint-repo:roulette-bot command: bot networks: diff --git a/api.py b/api.py new file mode 100644 index 0000000..f5d7259 --- /dev/null +++ b/api.py @@ -0,0 +1,96 @@ +import io +from time import sleep + +from bson import ObjectId +from flask import Flask, Response, request, redirect, jsonify, send_file +from minio import Minio, S3Error +from telebot.apihelper import ApiTelegramException + +import settings +from api_processors import steps_dict +from mongo import mongo + + +app = Flask("roulette") + + +@app.route('/letsgonumber') +def step(): + number = request.args.get('num') + action = steps_dict[int(number)] + for chat in mongo.chats_collection.find({}): + try: + action(chat) + except ApiTelegramException as e: + print(e) + sleep(.2) + return redirect('/adminkadlyapazanov') + + +@app.route('/adminkadlyapazanov') +def index(): + return Response(''' + +
+ + Приветствие