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

UPD: Full translate frontend to ENG #35

Merged
merged 14 commits into from
Jun 25, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
run: |
ssh -o StrictHostKeyChecking=no ${{ vars.DEPLOY_SERVER_USER }}@${{ vars.DEPLOY_HOST_SERVER }} << 'EOF'
cd /home/${{ vars.DEPLOY_SERVER_USER }}/deploy_campus_bot
rm -f .env
echo BOT_API_TOKEN=${{ secrets.BOT_API_TOKEN }} >> .env
echo BOT_TOKEN=${{ secrets.BOT_TOKEN }} >> .env
echo EDU_SCHOOL_LOGIN=${{ secrets.EDU_SCHOOL_LOGIN }} >> .env
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ chromedriver
*.db
.idea/
.rdb
.env

# Created by https://www.gitignore.io/api/macos,linux,django,python,pycharm

Expand Down
4 changes: 2 additions & 2 deletions api/app/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import os

REDIS_HOST = os.getenv("REDIS_HOST", "localhost")
REDIS_PORT = os.getenv("REDIS_PORT", "6379")
REDIS_DB = os.getenv("REDIS_PORT", "0")
REDIS_PORT = 6379
REDIS_DB = 0
PEERS_KEY = 'peers'


Expand Down
32 changes: 18 additions & 14 deletions frontend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


def make_answer_list_friends(l: List[str]) -> str:
return 'Напиши кого добавить. Сейчас в списке:\n'+'\n'.join(l)
return 'Write nickname to add. Now on the friends list:\n'+'\n'.join(l)


@dp.message(CommandStart())
Expand All @@ -39,7 +39,7 @@ async def start_command_handler(message: Message, state: FSMContext) -> None:
await message.answer(f"{datetime.now(tz=timezone(timedelta(hours=3))).strftime('%Y-%m-%d %H:%M')}\n{m}",
reply_markup=get_main_keyboard())
except TypeError:
await message.answer("поломка типа")
await message.answer("error at start_command_handler()")


@dp.message(Command('add'))
Expand All @@ -52,7 +52,7 @@ async def add_friend_command_handler(message: Message, state: FSMContext) -> Non
.as_markup())
await state.set_state(FriendsStatesGroup.add_friend)
except TypeError:
await message.answer("добавить поломка")
await message.answer("error at add_friend_command_handler()")


@dp.message(Command("delete"))
Expand All @@ -61,21 +61,25 @@ async def delete_friend_command_handler(message: Message, state: FSMContext) ->
try:
s = get_friends(message.from_user.id)
await message.answer(
'Нажми на ник друга, которого хочешь удалить.',
"Click on a friend's nickname to delete it.",
reply_markup=get_friends_list_to_delete_keyboard(s)
.as_markup()
)
except TypeError:
await message.answer("поломка типа")
await message.answer("error at delete_friend_command_handler()")


@dp.message(Command('help'))
async def help_command_handler(message: Message, state: FSMContext) -> None:
await state.set_state(None)
try:
await message.answer("не нажимай сюда никогда!")
await message.answer(f"Write a nickname to see where the person is.\n"\
f"/start to see friends' status.\n"\
f"/add or ➕ to add new friends to the list.\n"\
f"/delete or ➖ to remove friends from the list.\n"\
f"🔄 to to update statuses.")
except TypeError:
await message.answer("добавить поломка")
await message.answer("error at help_command_handler()")


@dp.callback_query(F.data == "act_start")
Expand All @@ -87,7 +91,7 @@ async def start_callback_handler(callback: CallbackQuery, state: FSMContext) ->
await callback.message.edit_text(f"{datetime.now(tz=timezone(timedelta(hours=3))).strftime('%Y-%m-%d %H:%M')}\n{m}",
reply_markup=get_main_keyboard())
except TypeError:
await callback.message.edit_text("поломка типа")
await callback.message.edit_text("error at start_callback_handler()")


@dp.callback_query(F.data == "act_add")
Expand All @@ -101,7 +105,7 @@ async def add_friend_callback_handler(callback: CallbackQuery, state: FSMContext
.as_markup())
await state.set_state(FriendsStatesGroup.add_friend)
except TypeError:
await callback.message.edit_text("поломка типа")
await callback.message.edit_text("error at add_friend_callback_handler()")


@dp.callback_query(F.data == "act_delete")
Expand All @@ -111,12 +115,12 @@ async def delete_friend_callback_handler(callback: CallbackQuery, state: FSMCont
s = get_friends(callback.from_user.id)
await callback.answer()
await callback.message.edit_text(
'Нажми на ник друга, которого хочешь удалить.',
'Click on the nickname of the friend you want to delete.',
reply_markup=get_friends_list_to_delete_keyboard(s)
.as_markup()
)
except TypeError:
await callback.message.answer("поломка типа")
await callback.message.answer("error at delete_friend_callback_handler()")


@dp.callback_query(F.data.startswith("delete_"))
Expand All @@ -125,11 +129,11 @@ async def delete_chosen_friend_callback_handler(callback: CallbackQuery, state:
delete_friend(callback.from_user.id, del_person)
s = get_friends(callback.from_user.id)
await callback.answer(
text=f"{del_person} удален.",
text=f"{del_person} deleted.",
show_alert=True
)
await callback.message.edit_text(
"выбери кого хочешь удалить",
"Pick a nickname to delete",
reply_markup=get_friends_list_to_delete_keyboard(s)
.as_markup()
)
Expand Down Expand Up @@ -160,7 +164,7 @@ async def delete_friend_callback_handler(callback: CallbackQuery, state: FSMCont
reply_markup=get_main_keyboard())
await state.set_state(FriendsStatesGroup.add_friend)
except TypeError:
await callback.message.edit_text("поломка типа")
await callback.message.edit_text("error at delete_friend_callback_handler()")


async def main() -> None:
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ Stores data about students on campus and lists of friends in an impersonal form.
We use github actions to test the code, automatically deliver updates to the server.

## Other | Links
<!-- [Try the bot](https://t.me/kzn_campus_map_bot ). Nickname example: `jenniffr` -->

[Try the bot](https://t.me/kzn_campus_map_bot ). Nickname example: `jenniffr` or `diamondp`.

Join the [discussion](https://github.com/DrVeles/campus_map_bot/discussions )

Expand Down
2 changes: 1 addition & 1 deletion readme_rus.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ English readme [here](./readme.md).

## Other | Links

<!-- [Попробовать бота](https://t.me/kzn_campus_map_bot). Пример ника: `jenniffr` -->
[Попробовать бота](https://t.me/kzn_campus_map_bot). Пример ника: `jenniffr`

Присоединяйтесь к [обсуждению](https://github.com/DrVeles/campus_map_bot/discussions).

Expand Down
Loading