-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc7505e
commit 4022c04
Showing
13 changed files
with
286 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: ci | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- | ||
name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
push: true | ||
tags: aleksglebov/licensure:bot_sup | ||
|
||
- name: Trigger deployment | ||
run: | | ||
curl -v -m 30 -X POST https://licensure.tech/webhook-bot_sup?token=${{ secrets.WEBHOOK_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Используем официальный образ Python 3.9 в качестве базового | ||
FROM python:3.9-slim | ||
|
||
# Устанавливаем рабочую директорию внутри контейнера | ||
WORKDIR /app | ||
|
||
# Копируем файл requirements.txt в рабочую директорию | ||
COPY requirements.txt . | ||
|
||
# Устанавливаем зависимости Python из requirements.txt | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
# Копируем остальные файлы бота в рабочую директорию | ||
COPY . . | ||
|
||
# Определяем переменную окружения для запуска бота | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
# Указываем команду для запуска бота | ||
CMD ["python", "main.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
This is a modified version of the Business Source License 1.1, customized for Licensure. The original text of the license can be found at https://mariadb.com/bsl11/ | ||
License text copyright © 2023 Licensure, All Rights Reserved. “Business Source License” is a trademark of Licensure. | ||
|
||
Terms | ||
The Licensor hereby grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work. | ||
|
||
Effective on the 04/20/2025, or the fourth anniversary of the first publicly available distribution of a specific version of the Licensed Work under this License, whichever comes first, the Licensor hereby grants you rights under the terms of the GNU GPLv3, and the rights granted in the paragraph above terminate. | ||
|
||
If your use of the Licensed Work does not comply with the requirements currently in effect as described in this License, you must purchase a commercial license from the Licensor, its affiliated entities, or authorized resellers, or you must refrain from using the Licensed Work. | ||
|
||
All copies of the original and modified Licensed Work, and derivative works of the Licensed Work, are subject to this License. This License applies separately for each version of the Licensed Work and the 04/20/2025 may vary for each version of the Licensed Work released by Licensor. | ||
|
||
You must conspicuously display this License on each original or modified copy of the Licensed Work. If you receive the Licensed Work in original or modified form from a third party, the terms and conditions set forth in this License apply to your use of that work. | ||
|
||
Any use of the Licensed Work in violation of this License will automatically terminate your rights under this License for the current and all other versions of the Licensed Work. | ||
|
||
This License does not grant you any right in any trademark or logo of Licensor or its affiliates (provided that you may use a trademark or logo of Licensor as expressly required by this License).TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE. MariaDB hereby grants you permission to use this License’s text to license your works, and to refer to it using the trademark “Business Source License”, as long as you comply with the Covenants of Licensor below. | ||
|
||
Covenants of Licensor | ||
In consideration of the right to use this License’s text and the “Business Source License” name and trademark, Licensor covenants to MariaDB, and to all other recipients of the licensed work to be provided by Licensor: | ||
|
||
To specify as the GNU GPLv3 the GPL Version 2.0 or any later version, or a license that is compatible with GPL Version 2.0 or a later version, where “compatible” means that software provided under the GNU GPLv3 can be included in a program with software provided under GPL Version 2.0 or a later version. Licensor may specify additional GNU GPLv3s without limitation. | ||
|
||
Notice | ||
The Business Source License (this document, or the “License”) is not an Open Source license. However, the Licensed Work will eventually be made available under an Open Source License, as stated in this License. | ||
|
||
For more information on the use of the Business Source License for MariaDB products, please visit the MariaDB Business Source License FAQ. For more information on the use of the Business Source License generally, please visit the Adopting and Developing Business Source License FAQ. | ||
|
||
Projects using BSL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Licensure | ||
|
||
Licensure is a [brief description of your project]. It aims to [state the main objectives or features of your project]. | ||
|
||
## Features | ||
|
||
- [Feature 1] | ||
- [Feature 2] | ||
- [Feature 3] | ||
|
||
## Installation | ||
|
||
[Provide instructions on how to install and set up your project] | ||
|
||
## Usage | ||
|
||
[Provide examples and instructions on how to use your project] | ||
|
||
## Contributing | ||
|
||
[Specify guidelines for contributing to your project] | ||
|
||
## License | ||
|
||
Licensure is licensed under a modified version of the Business Source License 1.1 (BSL 1.1). Here are the key points: | ||
|
||
- You are free to use, modify, and distribute the code for non-production purposes. | ||
- For commercial use of the code before 04/20/2025, you must obtain a commercial license from Licensure. | ||
- On 04/20/2025, the code will be released under the GNU GPLv3 license and will be free to use for any purpose. | ||
|
||
For more details, please see the [LICENSE](./LICENSE) file. | ||
|
||
## Contact | ||
|
||
If you have any questions, feel free to reach out: | ||
|
||
- Email: [your email address] | ||
- Twitter: [@yourtwitterhandle](https://twitter.com/yourtwitterhandle) | ||
- Web: [yourwebsite.com](https://www.yourwebsite.com) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"start_message": { | ||
"english": "Welcome to Licensure Support!" | ||
}, | ||
|
||
"test": { | ||
"english": "Test OK!" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
# Остановить и удалить старый контейнер, если он существует | ||
docker stop bot_sup || true | ||
docker rm bot_sup || true | ||
|
||
# Удалить старый образ | ||
docker rmi aleksglebov/licensure:bot_sup || true | ||
|
||
# Получить последнюю версию образа из Docker Hub | ||
docker pull aleksglebov/licensure:bot_sup | ||
|
||
# Запустить новый контейнер | ||
docker run -d --name bot_sup -e TOKEN_SUP="$TOKEN_SUP" aleksglebov/licensure:bot_sup | ||
|
||
echo "Deployment completed successfully." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
echo -e "HTTP/1.1 200 OK\r" | ||
echo -e "Content-Type: text/plain\r" | ||
echo -e "Connection: close\r" | ||
echo -e "\r" | ||
echo -e "Received request" | ||
|
||
bash /home/defendershow/bot/deploy/webhook.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
socat TCP-LISTEN:8892,reuseaddr,fork EXEC:./request_handler.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
# Путь к скрипту deploy.sh | ||
DEPLOY_SCRIPT=/home/defendershow/bot/deploy/deploy.sh | ||
|
||
# Запустить скрипт развертывания | ||
$DEPLOY_SCRIPT | ||
|
||
# Вернуть ответ веб-хуку | ||
echo "Deployment triggered successfully." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import json | ||
import logging | ||
from telegram import Update, ReplyKeyboardMarkup | ||
from telegram.ext import CallbackContext, ConversationHandler | ||
from pathlib import Path | ||
import os | ||
|
||
# Logging | ||
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', | ||
level=logging.INFO) | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
# Open assets | ||
current_dir = os.path.dirname(os.path.abspath(__file__)) | ||
text_path = Path(os.path.join(current_dir, "assets/texts/texts.json")) | ||
|
||
with text_path.open("r", encoding="utf-8") as file: | ||
texts = json.load(file) | ||
|
||
# Const for states | ||
START = range(1) | ||
|
||
# Func for start messages and for keyboard | ||
def start(update: Update, context: CallbackContext) -> int: | ||
logger.info("start called") | ||
|
||
update.message.reply_text(texts['start_message']['english'], parse_mode="Markdown") | ||
|
||
menu_generator(update, context) | ||
|
||
return START | ||
|
||
def menu_generator(update: Update, context: CallbackContext): | ||
logger.info('menu_generator called') | ||
|
||
keyboard = [['📖Test']] | ||
reply_markup = ReplyKeyboardMarkup(keyboard, resize_keyboard=True, one_time_keyboard=False) | ||
text = texts['for_menu']['english'] | ||
|
||
if update.callback_query: | ||
update.callback_query.message.reply_text(text, reply_markup=reply_markup) | ||
return START | ||
elif update.message: | ||
update.message.reply_text(text, reply_markup=reply_markup) | ||
return START | ||
else: | ||
logger.warning("menu_generator called outside of a message or callback query context") | ||
return START | ||
|
||
def menu_buttons(update: Update, context: CallbackContext): | ||
logger.info("menu_buttons called") | ||
text = update.message.text | ||
|
||
if text == "📖Test": | ||
return read_rules(update, context) | ||
else: | ||
logger.warning(f"Unknown button text: {text}") | ||
return None | ||
|
||
# Func for stop conversation with bot | ||
def cancel(update: Update, context: CallbackContext): | ||
logger.info("cancel called") | ||
|
||
context.user_data.clear() | ||
|
||
update.message.reply_text(texts['stop']['english'], parse_mode="Markdown") | ||
|
||
return ConversationHandler.END | ||
|
||
def read_rules(update: Update, context: CallbackContext): | ||
logger.info("read_rules called") | ||
|
||
update.message.reply_text(texts['test']['english'], parse_mode="Markdown") | ||
|
||
return START |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from telegram.ext import ( | ||
Updater, | ||
CommandHandler, | ||
ConversationHandler, | ||
MessageHandler, | ||
Filters | ||
) | ||
import os | ||
from handlers import ( | ||
START, | ||
start, | ||
menu_buttons, | ||
cancel | ||
) | ||
|
||
def load_token_from_config(): | ||
return os.environ.get('TOKEN_SUP') | ||
|
||
def main(): | ||
TOKEN = load_token_from_config() | ||
updater = Updater(TOKEN) | ||
dp = updater.dispatcher | ||
|
||
start_handler = ConversationHandler( | ||
entry_points = [CommandHandler('start', start)], | ||
states = { | ||
START: [MessageHandler(Filters.text & ~Filters.command, menu_buttons)] | ||
}, | ||
fallbacks = [CommandHandler('cancel', cancel)] | ||
) | ||
|
||
dp.add_handler(start_handler) | ||
|
||
updater.start_polling() | ||
updater.idle() | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python-telegram-bot==13.7 |