From 4165498631a815ea5a5fe704d9a189a11af99cca Mon Sep 17 00:00:00 2001 From: Administrator Date: Thu, 15 Dec 2022 17:49:39 +0300 Subject: [PATCH] initial --- .deploy/deploy-dev.yaml | 16 ++++++ .deploy/deploy-prod.yaml | 16 ++++++ .gitignore | 119 +++++++++++++++++++++++++++++++++++++++ .gitlab-ci.yml | 51 +++++++++++++++++ Dockerfile | 0 main.py | 24 ++++++++ requirements.txt | 0 7 files changed, 226 insertions(+) create mode 100644 .deploy/deploy-dev.yaml create mode 100644 .deploy/deploy-prod.yaml create mode 100644 .gitignore create mode 100644 .gitlab-ci.yml create mode 100644 Dockerfile create mode 100644 main.py create mode 100644 requirements.txt diff --git a/.deploy/deploy-dev.yaml b/.deploy/deploy-dev.yaml new file mode 100644 index 0000000..6429b86 --- /dev/null +++ b/.deploy/deploy-dev.yaml @@ -0,0 +1,16 @@ +version: "3.4" + + +services: + + bot: + image: mathwave/sprint-repo:pizda-bot + environment: + TELEGRAM_TOKEN: $TELEGRAM_TOKEN_DEV + deploy: + mode: replicated + restart_policy: + condition: any + update_config: + parallelism: 1 + order: start-first diff --git a/.deploy/deploy-prod.yaml b/.deploy/deploy-prod.yaml new file mode 100644 index 0000000..2d5b519 --- /dev/null +++ b/.deploy/deploy-prod.yaml @@ -0,0 +1,16 @@ +version: "3.4" + + +services: + + bot: + image: mathwave/sprint-repo:pizda-bot + environment: + TELEGRAM_TOKEN: $TELEGRAM_TOKEN_PROD + deploy: + mode: replicated + restart_policy: + condition: any + update_config: + parallelism: 1 + order: start-first diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..92785dd --- /dev/null +++ b/.gitignore @@ -0,0 +1,119 @@ +# Django # +*.log +*.pot +*.pyc +__pycache__ +db.sqlite3 +media +data +*/__pycache__ + +# Backup files # +*.bak + +# If you are using PyCharm # +.idea +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/gradle.xml +.idea/**/libraries +*.iws /out/ + +# Python # +*.py[cod] +*$py.class + +# Distribution / packaging +.Python build/ +develop-eggs/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +.pytest_cache/ +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +postgres-data + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery +celerybeat-schedule.* + +# SageMath parsed files +*.sage.py + +# Environments +.venv +env/ +ENV/ +venv/ +env.bak/ +venv.bak/ + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +# Sublime Text # +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache +*.sublime-workspace +*.sublime-project + +# sftp configuration file +sftp-config.json + +# Package control specific files Package +Control.last-run +Control.ca-list +Control.ca-bundle +Control.system-ca-bundle +GitHub.sublime-settings + +# Visual Studio Code # +.vscode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +.history \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..15d2536 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,51 @@ +stages: + - build + - deploy-dev + - deploy-prod + +build: + stage: build + tags: + - dev + before_script: + - docker login -u mathwave -p $DOCKERHUB_PASSWORD + script: + - docker build -t mathwave/sprint-repo:pizda-bot . + +push: + stage: build + tags: + - dev + before_script: + - docker login -u mathwave -p $DOCKERHUB_PASSWORD + script: + - docker push mathwave/sprint-repo:pizda-bot + +.deploy: + before_script: + - docker login -u mathwave -p $DOCKERHUB_PASSWORD + +deploy-dev: + extends: + - .deploy + stage: deploy-dev + tags: + - dev + rules: + - if: '$CI_COMMIT_BRANCH == "master"' + when: on_success + - when: manual + script: + - docker stack deploy --with-registry-auth -c ./.deploy/deploy-dev.yaml pizda-bot + +deploy-prod: + extends: + - .deploy + stage: deploy-prod + tags: + - prod + only: + - master + when: manual + script: + - docker stack deploy --with-registry-auth -c ./.deploy/deploy-prod.yaml pizda-bot diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e69de29 diff --git a/main.py b/main.py new file mode 100644 index 0000000..a45f1ca --- /dev/null +++ b/main.py @@ -0,0 +1,24 @@ +import os +import string + +import telebot +from telebot.types import Message + + +bot = telebot.TeleBot(os.getenv("TELEGRAM_TOKEN")) + + +all_letters = "йцукенгшщзхъёфывапролджэячсмитьбюЙЦУКЕНГШЩЗХЪЁФЫВАПРОЛДЖЭЯЧСМИТЬБЮ" +answers = { + "да", "ДА", "Да", "дА" +} + + +@bot.message_handler() +def do_action(message: Message): + convert_text = ''.join([letter for letter in message.text if letter in all_letters]) + if convert_text in answers: + bot.reply_to(message, "Пизда!") + + +bot.polling() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e69de29