From b45ea4ebbdc3831ce6a7e95c7e582b01561825df Mon Sep 17 00:00:00 2001 From: Pavel Kirilin <win10@list.ru> Date: Wed, 8 Jul 2020 03:43:30 +0400 Subject: [PATCH] Messages for students. Description: - Added messages for students. - Fixed replies. Signed-off-by: Pavel Kirilin <win10@list.ru> --- src/actions/__init__.py | 7 ++++--- src/actions/replies.py | 4 +++- src/actions/students.py | 19 +++++++++++++++++++ static_messages/students.txt | 23 +++++++++++++++++++++++ 4 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 src/actions/students.py create mode 100644 static_messages/students.txt diff --git a/src/actions/__init__.py b/src/actions/__init__.py index b21f0d4..b91a1e0 100644 --- a/src/actions/__init__.py +++ b/src/actions/__init__.py @@ -3,11 +3,12 @@ import logging def finish(): - importlib.import_module("src.actions.basic") importlib.import_module("src.actions.fun") + importlib.import_module("src.actions.basic") importlib.import_module("src.actions.replies") + importlib.import_module("src.actions.speller") + importlib.import_module("src.actions.students") importlib.import_module("src.actions.converters") - importlib.import_module("src.actions.package_indexes") importlib.import_module("src.actions.search_engines") - importlib.import_module("src.actions.speller") + importlib.import_module("src.actions.package_indexes") logging.info("All actions loaded") diff --git a/src/actions/replies.py b/src/actions/replies.py index 165e5b1..b41907c 100644 --- a/src/actions/replies.py +++ b/src/actions/replies.py @@ -26,7 +26,9 @@ async def welcome(event: events.ChatAction.Event): @config.telegram_client.on( events.NewMessage( - pattern=re.compile(r"^[Пп]ривет\.?", re.IGNORECASE), forwards=False + pattern=re.compile(r"^[Пп]ривет\.?", re.IGNORECASE), + forwards=False, + outgoing=False, ) ) @mark_unread diff --git a/src/actions/students.py b/src/actions/students.py new file mode 100644 index 0000000..586baf2 --- /dev/null +++ b/src/actions/students.py @@ -0,0 +1,19 @@ +import logging + +from src.config import config +from src.utils.responses import mark_unread +from telethon import events + +logger = logging.getLogger(__name__) + + +@config.telegram_client.on( + events.NewMessage(pattern="^.course$", chats=["Стажировка SimbirSoft"]) +) +@mark_unread +async def course_info(event: events.NewMessage.Event): + participant = event.message.from_id + await event.message.delete() + with open("./static_messages/students.txt") as f: + contents = f.read() + await event.client.send_message(participant, contents, link_preview=False) diff --git a/static_messages/students.txt b/static_messages/students.txt new file mode 100644 index 0000000..6edf366 --- /dev/null +++ b/static_messages/students.txt @@ -0,0 +1,23 @@ +Привет! Вот Ñ‚ÐµÐºÑƒÑ‰Ð°Ñ Ð¸Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸Ñ Ð¿Ð¾ курÑу: + +Текущее задание: +- `Изучить Ñпецификацию REST`; +- `Изучить что такое Environment Varibales и как их иÑпользовать в Python`; +- `Развернуть ÐºÐ°Ñ€ÐºÐ°Ñ Ð¿Ñ€Ð¸Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ Ð½Ð° Django`; +- `УÑтановить git` +- `Создать репозиторий в гитхабе`; +- `Залить туда ÐºÐ°Ñ€ÐºÐ°Ñ Ð¿Ñ€Ð¸Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ`; +- `Добавить Ð¼ÐµÐ½Ñ Ð² мейнтейнеры репозиториÑ`. + +Полезные ÑÑылки: +- [ОпиÑание REST методов](https://assertible.com/blog/7-http-methods-every-web-developer-should-know-and-how-to-test-them); +- [Ðемного про переменные Ñреды](https://www.nylas.com/blog/making-use-of-environment-variables-in-python/); +- [Первое приложение на Django](https://docs.djangoproject.com/en/3.0/intro/tutorial01/); +- [Я в гитхабе](https://github.com/s3rius/). + +Примерный Ñрок выполнениÑ: `3 днÑ`; +Дата Ñдачи: `10.07.2020`. + +Ð”Ð¾Ð¿Ð¾Ð»Ð½Ð¸Ñ‚ÐµÐ»ÑŒÐ½Ð°Ñ Ð¸Ð½Ñ‚ÐµÑ€ÐµÑÐ½Ð°Ñ Ð¸Ð½Ñ„Ð°: +ЕÑли интереÑно поглубже разобратьÑÑ Ñ Ð²Ð¾Ð·Ð¼Ð¾Ð¶Ð½Ð¾ÑÑ‚Ñми гита можно поÑмотреть +на очень крутой интерактивный [Ñайтец](https://learngitbranching.js.org/?locale=ru_RU). -- GitLab