mirror of
https://github.com/Faridik/Carolyn.git
synced 2026-07-08 13:21:53 +00:00
добавляем команду about
This commit is contained in:
parent
ed0b0cad11
commit
fb66f55668
11
.github/workflows/deploy.yml
vendored
11
.github/workflows/deploy.yml
vendored
@ -1,17 +1,13 @@
|
|||||||
name: deploy-to-Yandex-Cloud
|
name: deploy-to-Yandex-Cloud
|
||||||
|
|
||||||
# Controls when the workflow will run
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
|
||||||
jobs:
|
jobs:
|
||||||
# This workflow contains a single job called "build"
|
|
||||||
deploy:
|
deploy:
|
||||||
# The type of runner that the job will run on
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
|
||||||
steps:
|
steps:
|
||||||
- name: webfactory/ssh-agent
|
- name: webfactory/ssh-agent
|
||||||
uses: webfactory/ssh-agent@v0.5.3
|
uses: webfactory/ssh-agent@v0.5.3
|
||||||
@ -23,12 +19,13 @@ jobs:
|
|||||||
echo "${{ secrets.key }}" > "$HOME/key"
|
echo "${{ secrets.key }}" > "$HOME/key"
|
||||||
chmod 600 "$HOME/key"
|
chmod 600 "$HOME/key"
|
||||||
|
|
||||||
- name: Pull repo and restart Docker containers
|
- name: Restart Bot at Yandex Cloud
|
||||||
run:
|
run:
|
||||||
ssh -i $HOME/key carolyn@${{ secrets.HOST }} -o StrictHostKeyChecking=no
|
ssh -i $HOME/key carolyn@${{ secrets.HOST }} -o StrictHostKeyChecking=no
|
||||||
'
|
'
|
||||||
cd Carolyn &&
|
cd Carolyn &&
|
||||||
git pull &&
|
git pull &&
|
||||||
|
export CAROLYN_DEPLOY_INFO=$(git describe --always)
|
||||||
docker-compose down &&
|
docker-compose down &&
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
'
|
'
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import logging
|
|||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
|
import os
|
||||||
|
|
||||||
import telegram
|
import telegram
|
||||||
from telegram import (
|
from telegram import (
|
||||||
@ -394,9 +395,15 @@ def variant(update: Update, context: CallbackContext):
|
|||||||
msg.edit_text(text=MESSAGES.Variant.get(data["student"]["number"]))
|
msg.edit_text(text=MESSAGES.Variant.get(data["student"]["number"]))
|
||||||
|
|
||||||
|
|
||||||
|
def about(update: Update, context: CallbackContext):
|
||||||
|
"""Получить инфу о развертывании бота."""
|
||||||
|
deploy_info = os.environ.get("CAROLYN_DEPLOY_INFO")
|
||||||
|
update.message.reply_html(MESSAGES.Deploy.about(deploy_info))
|
||||||
|
|
||||||
|
|
||||||
def error(update: Update, context: CallbackContext):
|
def error(update: Update, context: CallbackContext):
|
||||||
LOG.error(msg="Exception while handling an update:", exc_info=context.error)
|
LOG.error(msg="Exception while handling an update:", exc_info=context.error)
|
||||||
if context.error is not None:
|
if context.error is not None and update is not None:
|
||||||
update.message.reply_text("Ой, кажется у меня %s" % repr(context.error))
|
update.message.reply_text("Ой, кажется у меня %s" % repr(context.error))
|
||||||
update.message.reply_sticker(MESSAGES.Stickers.DEAD)
|
update.message.reply_sticker(MESSAGES.Stickers.DEAD)
|
||||||
return ConversationHandler.END
|
return ConversationHandler.END
|
||||||
@ -485,6 +492,7 @@ def main() -> None:
|
|||||||
sub_handler = CommandHandler("sub", sub)
|
sub_handler = CommandHandler("sub", sub)
|
||||||
unsub_handler = CommandHandler("unsub", unsub)
|
unsub_handler = CommandHandler("unsub", unsub)
|
||||||
variant_handler = CommandHandler("variant", variant)
|
variant_handler = CommandHandler("variant", variant)
|
||||||
|
about_handler = CommandHandler("about", about)
|
||||||
|
|
||||||
dispatcher.add_handler(start_handler)
|
dispatcher.add_handler(start_handler)
|
||||||
dispatcher.add_handler(grades_handler)
|
dispatcher.add_handler(grades_handler)
|
||||||
@ -492,6 +500,7 @@ def main() -> None:
|
|||||||
dispatcher.add_handler(sub_handler)
|
dispatcher.add_handler(sub_handler)
|
||||||
dispatcher.add_handler(unsub_handler)
|
dispatcher.add_handler(unsub_handler)
|
||||||
dispatcher.add_handler(variant_handler)
|
dispatcher.add_handler(variant_handler)
|
||||||
|
dispatcher.add_handler(about_handler)
|
||||||
dispatcher.add_error_handler(error)
|
dispatcher.add_error_handler(error)
|
||||||
|
|
||||||
# Начало работы бота
|
# Начало работы бота
|
||||||
|
|||||||
@ -29,8 +29,9 @@ class Messages:
|
|||||||
TIMEOUT = "🕛 Время запроса вышло"
|
TIMEOUT = "🕛 Время запроса вышло"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get(name: str, assignment: list, how_to_display: str,
|
def get(
|
||||||
notes: str, deadline: str):
|
name: str, assignment: list, how_to_display: str, notes: str, deadline: str
|
||||||
|
):
|
||||||
is_float, n_cols, n_rows = how_to_display.split(",")
|
is_float, n_cols, n_rows = how_to_display.split(",")
|
||||||
n_cols, n_rows = int(n_cols), int(n_rows)
|
n_cols, n_rows = int(n_cols), int(n_rows)
|
||||||
summary = f"<b>{name}</b>:\n"
|
summary = f"<b>{name}</b>:\n"
|
||||||
@ -110,6 +111,11 @@ class Messages:
|
|||||||
}
|
}
|
||||||
return cases.get(err, "😟 Возникли неполадки")
|
return cases.get(err, "😟 Возникли неполадки")
|
||||||
|
|
||||||
|
class Deploy:
|
||||||
|
@staticmethod
|
||||||
|
def about(git_info):
|
||||||
|
return f"ℹ️ Информация о сборке:\n{git_info}"
|
||||||
|
|
||||||
class Spreadsheets:
|
class Spreadsheets:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@ -7,12 +7,12 @@ services:
|
|||||||
build: ./SpreadsheetsService
|
build: ./SpreadsheetsService
|
||||||
ports:
|
ports:
|
||||||
- "5000:5000"
|
- "5000:5000"
|
||||||
environment:
|
|
||||||
SECRETKEY: "HELLO-WORLD-@21XX 15AF"
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./SpreadsheetsService:/app
|
- ./SpreadsheetsService:/app
|
||||||
telegrambot:
|
telegrambot:
|
||||||
container_name: "carolyn-telegrambot"
|
container_name: "carolyn-telegrambot"
|
||||||
|
environment:
|
||||||
|
- CAROLYN_DEPLOY_INFO
|
||||||
restart: always
|
restart: always
|
||||||
build: ./TelegramBot
|
build: ./TelegramBot
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user