Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STABLE VERSION #16

Merged
merged 9 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Course_1/Telegram_Bot/Buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def create_subjects_keyboard(schedule: list or set):
for item in schedule:
item: str
buttons_list.append([InlineKeyboardButton(text=item, callback_data=translit(
item, language_code='ru', reversed=True))])
item[:len(item) // 2 + 1], language_code='ru', reversed=True))])
keyboard_inline_buttons = InlineKeyboardMarkup(inline_keyboard=buttons_list)
return keyboard_inline_buttons

Expand Down
54 changes: 48 additions & 6 deletions Course_1/Telegram_Bot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@

# FA HOMEWORK BOT

* [**Используемые технологии**](#Используемые-технологии)
* [**Как пользоваться?**](#Как-пользоваться?)
* [**Как добавлять задания?**](#Как-добавлять-задания?)
* [**Используемые технологии**](#используемые-технологии)
* [**Как пользоваться?**](#как-пользоваться)
* [**Как добавлять задания?**](#как-добавлять-задания)
* [**О проекте**](#о-проекте)
* [**Deploy**](#deploy)
* [**Структура**](#структура)
* [**А что ещё есть?**](#а-что-ещё-есть)
* [**Иллюстрации**](#иллюстрации)

### Используемые технологии

* **Aiogram Framework** [<img align="left" width="22px" src="https://cdn4.iconfinder.com/data/icons/social-media-and-logos-11/32/Logo_telegram_Airplane_Air_plane_paper_airplane-22-256.png"/>][aiogram]
* **SQLite3** [<img align="left" width="22px" src="https://cdn1.iconfinder.com/data/icons/hawcons/32/700048-icon-89-document-file-sql-256.png"/>][SQLite]
* **Transliterate module** [<img align="left" width="22px" src="https://cdn2.iconfinder.com/data/icons/humano2/128x128/apps/character-set.png"/>][transliterate]

### Как пользоваться?

1) 📲 **Заходим к [боту](https://t.me/FA_Homework_bot)**
1) 🔎 **Или же находим его самостоятельно:** `@FA_Homework_bot`
2) ▶ **Нажимаем на кнопку** `/start`
Expand All @@ -30,7 +34,45 @@
4) 📅 **Выбираем необходимую дату**
5) 📝 **Вводим задание**
6) 🎉 **Радуемся!**
### О проекте
#### Deploy
* **Размещён на `Microsoft Azure | Windows (Windows 10 Pro)`**
#### Структура
* `bot.py`: **Основной файл который работает со всем хендлерами и обрабатывает основную логику бота**
* `Buttons.py`: **Файл со всеми клавиатурами и кнопками бота**
* `date.py`: **Файл для внутренней работы с датами**
* `db.py`: **Основной файл для работы с базами на данных на `SQLite`**
* `Schedule.py`: **Файл для получения расписания группы на основе API запросов к `ruz.fa.ru`**
* `create config.bat`: **Файл инициализации `config.py` с добавлением `TOKEN` и `green_list` из консоли**
* `Tests`: **Тесты на проверку инициализации баз данных**

### А что ещё есть?
* **Вы можете прикреплять к домашнему заданию файлы которые потом будут появляться в домашнем задании**
* **Вы можете изменять домашнее задание которое вы ввели**
* **Вы можете сломать бота, если введете неверную группу :)**

### Иллюстрации

![Start](md%20images/start.png)

![Gettin_hw](md%20images/gettin_hw.png)

![HW](md%20images/HW.png)

![Managing](md%20images/manage.png)

![Schedule](md%20images/Schedule.png)


### TODO
1) **Сделать удаление домашних заданий**
1) **Сделать управление вложениями**
2) **Сделать сборник полезных материалов группы**
1) **Например учебник по английскому языку который скидывали ещё в начале года**




[SQLite]: https://www.sqlite.org/docs.html
[aiogram]: https://github.com/aiogram/aiogram
[transliterate]: https://pypi.org/project/transliterate/
[transliterate]: https://pypi.org/project/transliterate/
1 change: 1 addition & 0 deletions Course_1/Telegram_Bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ async def add_homework_subject(query: types.CallbackQuery, state: FSMContext):
lambda x: tr.translit(x, language_code='ru', reversed=True), schedule))
subject = None
for pos, let in enumerate(transliterated_schedule):
print(let)
if query.data == let:
subject = schedule[pos]
if subject is None:
Expand Down
17 changes: 16 additions & 1 deletion Course_1/Telegram_Bot/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ def get_user_group(self, connection: tuple, chat_id: str) -> str:
connection.commit()
return cursor

class FilesDB(object):
@Connections.safe
def init(self, connection: tuple):
connection, cursor = connection
cursor.execute('''
create table if not exists Files
(
id INTEGER primary key,
Data TEXT,
filename TEXT,
group_name TEXT
);
''')
connection.commit()

@Connections.safe
def init(self, connection: tuple, name: str = 'Homework') -> None:
connection, cursor = connection
Expand All @@ -65,7 +80,7 @@ def init(self, connection: tuple, name: str = 'Homework') -> None:
def attach_file(self, connection: tuple, date: str, filename: str, group: str):
connection, cursor = connection

cursor.execute('''INSERT INTO Files (Data, filename, group_name) VALUES (?, ?, ?)''', (date, filename, group))
cursor.execute('''INSERT INTO Files (DATA, FILENAME, GROUP_NAME) VALUES (?, ?, ?)''', (date, filename, group))
connection.commit()

@Connections.safe
Expand Down
Binary file added Course_1/Telegram_Bot/md images/HW.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Course_1/Telegram_Bot/md images/Schedule.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Course_1/Telegram_Bot/md images/gettin_hw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Course_1/Telegram_Bot/md images/manage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Course_1/Telegram_Bot/md images/start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.