add stats
This commit is contained in:
parent
c3b189c57b
commit
0ba5ef0789
@ -5,6 +5,7 @@ services:
|
|||||||
|
|
||||||
bot:
|
bot:
|
||||||
image: mathwave/sprint-repo:pizda-bot
|
image: mathwave/sprint-repo:pizda-bot
|
||||||
|
command: bot
|
||||||
environment:
|
environment:
|
||||||
TELEGRAM_TOKEN: $TELEGRAM_TOKEN_DEV
|
TELEGRAM_TOKEN: $TELEGRAM_TOKEN_DEV
|
||||||
MONGO_HOST: "mongo.develop.sprinthub.ru"
|
MONGO_HOST: "mongo.develop.sprinthub.ru"
|
||||||
@ -18,3 +19,26 @@ services:
|
|||||||
update_config:
|
update_config:
|
||||||
parallelism: 1
|
parallelism: 1
|
||||||
order: start-first
|
order: start-first
|
||||||
|
|
||||||
|
pizda-bot-nginx:
|
||||||
|
image: mathwave/sprint-repo:pizda-bot
|
||||||
|
command: api
|
||||||
|
environment:
|
||||||
|
TELEGRAM_TOKEN: $TELEGRAM_TOKEN_DEV
|
||||||
|
MONGO_HOST: "mongo.develop.sprinthub.ru"
|
||||||
|
MONGO_PASSWORD: $MONGO_PASSWORD_DEV
|
||||||
|
PLATFORM_SECURITY_TOKEN: $PLATFORM_SECURITY_TOKEN
|
||||||
|
STAGE: "development"
|
||||||
|
networks:
|
||||||
|
- common-infra-nginx
|
||||||
|
deploy:
|
||||||
|
mode: replicated
|
||||||
|
restart_policy:
|
||||||
|
condition: any
|
||||||
|
update_config:
|
||||||
|
parallelism: 1
|
||||||
|
order: start-first
|
||||||
|
|
||||||
|
networks:
|
||||||
|
common-infra-nginx:
|
||||||
|
external: true
|
@ -5,6 +5,7 @@ services:
|
|||||||
|
|
||||||
bot:
|
bot:
|
||||||
image: mathwave/sprint-repo:pizda-bot
|
image: mathwave/sprint-repo:pizda-bot
|
||||||
|
command: bot
|
||||||
environment:
|
environment:
|
||||||
TELEGRAM_TOKEN: $TELEGRAM_TOKEN_PROD
|
TELEGRAM_TOKEN: $TELEGRAM_TOKEN_PROD
|
||||||
MONGO_HOST: "mongo.sprinthub.ru"
|
MONGO_HOST: "mongo.sprinthub.ru"
|
||||||
@ -18,3 +19,26 @@ services:
|
|||||||
update_config:
|
update_config:
|
||||||
parallelism: 1
|
parallelism: 1
|
||||||
order: start-first
|
order: start-first
|
||||||
|
|
||||||
|
pizda-bot-nginx:
|
||||||
|
image: mathwave/sprint-repo:pizda-bot
|
||||||
|
command: api
|
||||||
|
environment:
|
||||||
|
TELEGRAM_TOKEN: $TELEGRAM_TOKEN_PROD
|
||||||
|
MONGO_HOST: "mongo.sprinthub.ru"
|
||||||
|
MONGO_PASSWORD: $MONGO_PASSWORD_PROD
|
||||||
|
PLATFORM_SECURITY_TOKEN: $PLATFORM_SECURITY_TOKEN
|
||||||
|
STAGE: "production"
|
||||||
|
networks:
|
||||||
|
- common-infra-nginx
|
||||||
|
deploy:
|
||||||
|
mode: replicated
|
||||||
|
restart_policy:
|
||||||
|
condition: any
|
||||||
|
update_config:
|
||||||
|
parallelism: 1
|
||||||
|
order: start-first
|
||||||
|
|
||||||
|
networks:
|
||||||
|
common-infra-nginx:
|
||||||
|
external: true
|
16
api.py
Normal file
16
api.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
from mongo import mongo
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/stats/json', methods=['GET'])
|
||||||
|
def stats_json():
|
||||||
|
replies = 0
|
||||||
|
for doc in mongo.counter_collection.find({}):
|
||||||
|
replies += doc['count']
|
||||||
|
return {
|
||||||
|
"Всего чатов": mongo.chats_collection.count_documents({"chat_id": {"$lt": 0}}),
|
||||||
|
"Отвечено": replies
|
||||||
|
}
|
8
main.py
8
main.py
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
from random import randrange, choice
|
from random import randrange, choice
|
||||||
|
|
||||||
import telebot
|
import telebot
|
||||||
@ -178,4 +179,9 @@ def do_action(message: Message):
|
|||||||
mongo.inc(message.from_user.username, message.chat.id)
|
mongo.inc(message.from_user.username, message.chat.id)
|
||||||
|
|
||||||
|
|
||||||
bot.polling()
|
arg = sys.argv[-1]
|
||||||
|
if arg == 'bot':
|
||||||
|
bot.polling()
|
||||||
|
else:
|
||||||
|
from api import app
|
||||||
|
app.run(host="0.0.0.0", port=1238)
|
||||||
|
Loading…
Reference in New Issue
Block a user