Compare commits

..

19 Commits

Author SHA1 Message Date
232042a523 Merge pull request 'fix' (#28) from master into dev
Reviewed-on: #28
2025-06-15 23:26:55 +03:00
eec041bb9d Merge pull request 'fix' (#27) from master into dev
Reviewed-on: #27
2025-06-15 15:02:56 +03:00
e8b5092745 Merge pull request 'fix' (#26) from master into dev
Reviewed-on: #26
2025-06-15 15:01:42 +03:00
6c1288aaab Merge pull request 'master' (#25) from master into dev
Reviewed-on: #25
2025-06-15 14:58:04 +03:00
3408364bc4 Merge pull request 'fix' (#22) from master into dev
Reviewed-on: #22
2024-11-27 16:38:24 +03:00
baa134ae26 Merge pull request 'fix' (#21) from master into dev
Reviewed-on: #21
2024-11-27 16:35:39 +03:00
fcb2713eaf Merge pull request 'master' (#20) from master into dev
Reviewed-on: #20
2024-11-27 16:31:02 +03:00
d2247054e8 Merge pull request 'queues' (#17) from queues into dev
Reviewed-on: #17
2024-11-27 02:44:39 +03:00
ce550c31f4 Merge pull request 'fix' (#14) from queues into dev
Reviewed-on: #14
2024-11-25 00:01:04 +03:00
ba2f1bb768 Merge pull request 'queues' (#13) from queues into dev
Reviewed-on: #13
2024-11-24 23:55:59 +03:00
889a20609f Merge pull request 'fix' (#12) from queues into dev
Reviewed-on: #12
2024-11-23 22:32:00 +03:00
1c3d1566e5 Merge pull request 'fix' (#11) from queues into dev
Reviewed-on: #11
2024-11-23 22:27:17 +03:00
2b88479cec Merge pull request 'fix' (#10) from queues into dev
Reviewed-on: #10
2024-11-22 01:52:48 +03:00
7238d725dd Merge pull request 'fix' (#9) from queues into dev
Reviewed-on: #9
2024-11-22 01:48:32 +03:00
4a3fa3c2ab Merge pull request 'fix' (#8) from queues into dev
Reviewed-on: #8
2024-11-17 23:08:08 +03:00
45e1c0fe8a Merge pull request 'fix' (#7) from queues into dev
Reviewed-on: #7
2024-11-17 23:03:48 +03:00
989f7026ad Merge pull request 'fix' (#6) from queues into dev
Reviewed-on: #6
2024-11-17 22:58:40 +03:00
90378be7c5 Merge pull request 'queues' (#5) from queues into dev
Reviewed-on: #5
2024-11-17 22:56:27 +03:00
95e4f5e8da Merge pull request 'deploy' (#2) from master into dev
Reviewed-on: #2
2024-10-11 07:05:29 +03:00
6 changed files with 20 additions and 17 deletions

View File

@@ -6,12 +6,12 @@ services:
worker: worker:
image: mathwave/sprint-repo:ruz-bot image: mathwave/sprint-repo:ruz-bot
environment: environment:
MONGO_HOST: "mongo.develop.sprinthub.ru"
STAGE: "development" STAGE: "development"
MONGO_PASSWORD: $MONGO_PASSWORD_DEV MONGO_PASSWORD: $MONGO_PASSWORD_DEV
networks: networks:
- queues-development - queues-development
- configurator - configurator
- mongo-development
command: worker command: worker
deploy: deploy:
mode: replicated mode: replicated
@@ -24,11 +24,12 @@ services:
fetch: fetch:
image: mathwave/sprint-repo:ruz-bot image: mathwave/sprint-repo:ruz-bot
environment: environment:
MONGO_HOST: "mongo.develop.sprinthub.ru"
STAGE: "development" STAGE: "development"
MONGO_PASSWORD: $MONGO_PASSWORD_DEV MONGO_PASSWORD: $MONGO_PASSWORD_DEV
PLATFORM_SECURITY_TOKEN: $PLATFORM_SECURITY_TOKEN
networks: networks:
- queues-development - queues-development
- mongo-development
command: fetch command: fetch
deploy: deploy:
mode: replicated mode: replicated
@@ -41,11 +42,12 @@ services:
notify: notify:
image: mathwave/sprint-repo:ruz-bot image: mathwave/sprint-repo:ruz-bot
environment: environment:
MONGO_HOST: "mongo.develop.sprinthub.ru"
STAGE: "development" STAGE: "development"
MONGO_PASSWORD: $MONGO_PASSWORD_DEV MONGO_PASSWORD: $MONGO_PASSWORD_DEV
PLATFORM_SECURITY_TOKEN: $PLATFORM_SECURITY_TOKEN
networks: networks:
- queues-development - queues-development
- mongo-development
command: notify command: notify
deploy: deploy:
mode: replicated mode: replicated
@@ -60,10 +62,11 @@ services:
networks: networks:
- common-infra-nginx-development - common-infra-nginx-development
- queues-development - queues-development
- mongo-development
environment: environment:
MONGO_HOST: "mongo.develop.sprinthub.ru"
STAGE: "development" STAGE: "development"
MONGO_PASSWORD: $MONGO_PASSWORD_DEV MONGO_PASSWORD: $MONGO_PASSWORD_DEV
PLATFORM_SECURITY_TOKEN: $PLATFORM_SECURITY_TOKEN
command: api command: api
deploy: deploy:
mode: replicated mode: replicated
@@ -80,5 +83,3 @@ networks:
external: true external: true
configurator: configurator:
external: true external: true
mongo-development:
external: true

View File

@@ -6,12 +6,12 @@ services:
worker: worker:
image: mathwave/sprint-repo:ruz-bot image: mathwave/sprint-repo:ruz-bot
environment: environment:
MONGO_HOST: "mongo.sprinthub.ru"
STAGE: "production" STAGE: "production"
MONGO_PASSWORD: $MONGO_PASSWORD_PROD MONGO_PASSWORD: $MONGO_PASSWORD_PROD
networks: networks:
- queues - queues
- configurator - configurator
- mongo
command: worker command: worker
deploy: deploy:
mode: replicated mode: replicated
@@ -24,13 +24,13 @@ services:
fetch: fetch:
image: mathwave/sprint-repo:ruz-bot image: mathwave/sprint-repo:ruz-bot
environment: environment:
MONGO_HOST: "mongo.sprinthub.ru"
STAGE: "production" STAGE: "production"
MONGO_PASSWORD: $MONGO_PASSWORD_PROD MONGO_PASSWORD: $MONGO_PASSWORD_PROD
DEBUG: "false" DEBUG: "false"
networks: networks:
- queues - queues
- configurator - configurator
- mongo
command: fetch command: fetch
deploy: deploy:
mode: replicated mode: replicated
@@ -43,13 +43,13 @@ services:
notify: notify:
image: mathwave/sprint-repo:ruz-bot image: mathwave/sprint-repo:ruz-bot
environment: environment:
MONGO_HOST: "mongo.sprinthub.ru"
STAGE: "production" STAGE: "production"
MONGO_PASSWORD: $MONGO_PASSWORD_PROD MONGO_PASSWORD: $MONGO_PASSWORD_PROD
DEBUG: "false" DEBUG: "false"
networks: networks:
- queues - queues
- configurator - configurator
- mongo
command: notify command: notify
deploy: deploy:
mode: replicated mode: replicated
@@ -64,8 +64,8 @@ services:
networks: networks:
- common-infra-nginx - common-infra-nginx
- configurator - configurator
- mongo
environment: environment:
MONGO_HOST: "mongo.sprinthub.ru"
STAGE: "production" STAGE: "production"
MONGO_PASSWORD: $MONGO_PASSWORD_PROD MONGO_PASSWORD: $MONGO_PASSWORD_PROD
DEBUG: "false" DEBUG: "false"
@@ -85,5 +85,3 @@ networks:
external: true external: true
configurator: configurator:
external: true external: true
mongo:
external: true

View File

@@ -7,7 +7,6 @@ RUN apt-get install -y locales locales-all
ENV LANGUAGE ru_RU.UTF-8 ENV LANGUAGE ru_RU.UTF-8
ENV LANG ru_RU.UTF-8 ENV LANG ru_RU.UTF-8
ENV LC_ALL ru_RU.UTF-8 ENV LC_ALL ru_RU.UTF-8
ENV PYTHONUNBUFFERED=1
COPY requirements.txt requirements.txt COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt RUN pip install -r requirements.txt
COPY . . COPY . .

View File

@@ -55,6 +55,13 @@ class Answer:
def process(self): def process(self):
user = User(self.user['chat_id']) user = User(self.user['chat_id'])
try:
bot_enabled_exp = platform.get_experiment('bot_enabled')
if not bot_enabled_exp['enabled'] or not eval(bot_enabled_exp['condition']):
return
except Exception as exc:
logging.info(exc)
return
getattr( getattr(
self, self,
"handle_state_" + self.user['state'], "handle_state_" + self.user['state'],

View File

@@ -9,7 +9,7 @@ from helpers import now
class Mongo: class Mongo:
def __init__(self): def __init__(self):
url = f"mongodb://{settings.MONGO_USER}:{settings.MONGO_PASSWORD}@mongo:27017/" url = f"mongodb://{settings.MONGO_USER}:{settings.MONGO_PASSWORD}@{settings.MONGO_HOST}:27017/"
self.client = pymongo.MongoClient(url) self.client = pymongo.MongoClient(url)
self.database = self.client.get_database("ruz-bot") self.database = self.client.get_database("ruz-bot")
self.users_collection.create_index([ self.users_collection.create_index([

View File

@@ -1,7 +1,6 @@
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
import datetime import datetime
import os import os
import traceback
import zoneinfo import zoneinfo
import requests import requests
import time import time
@@ -26,7 +25,7 @@ class TasksHandlerMixin:
def _send_metric(self, start: datetime.datetime, end: datetime.datetime, success: bool): def _send_metric(self, start: datetime.datetime, end: datetime.datetime, success: bool):
def send(): def send():
requests.post(f'{QUEUES_URL}/api/v1/metric', json={ requests.post(f'{QUEUES_URL}/api/v1/metric', json={
'service': 'ruz-bot', 'service': 'botalka',
'queue': self.queue_name, 'queue': self.queue_name,
'success': success, 'success': success,
'timestamp': start.strftime("%Y-%m-%dT%H:%M:%S") + "Z", 'timestamp': start.strftime("%Y-%m-%dT%H:%M:%S") + "Z",
@@ -56,7 +55,6 @@ class TasksHandlerMixin:
success = True success = True
except Exception as exc: except Exception as exc:
print(f'Error processing message id={task["id"]}, payload={task["payload"]}, exc={exc}') print(f'Error processing message id={task["id"]}, payload={task["payload"]}, exc={exc}')
traceback.print_exc()
success = False success = False
end = datetime.datetime.now(zoneinfo.ZoneInfo("Europe/Moscow")) end = datetime.datetime.now(zoneinfo.ZoneInfo("Europe/Moscow"))
if success: if success: