Skip to content

Commit

Permalink
правки
Browse files Browse the repository at this point in the history
  • Loading branch information
HamletSargsyan committed Aug 27, 2024
1 parent 2672866 commit ea1d710
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ repos:
language: system
types: [python]
pass_filenames: false
exclude: "src/*test*.py"
- id: format
name: format
entry: make format
language: system
types: [python]
pass_filenames: false
exclude: "src/*test*.py"

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Функции действий для игрока (прогулка, работа, и тд) из `base/player.py` перенесены в `base/actions.py`
- Рефакторинг файла `config.py`
- Модуль `requests` окончательно заменен на `httpx`

## [5.1.0] - 2024-08-16

Expand Down
8 changes: 4 additions & 4 deletions src/base/user_input/add_new_market_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def name_state(call: CallbackQuery):
)
return

with bot.retrieve_data(call.from_user.id, call.message.chat.id) as data:
with bot.retrieve_data(call.from_user.id, call.message.chat.id) as data: # type: ignore
data["name"] = item.name

user = database.users.get(id=call.from_user.id)
Expand Down Expand Up @@ -79,14 +79,14 @@ def invalid_int_input(message: Message):
@bot.message_handler(state=AddNewItemState.quantity, is_digit=True)
def quantity_state(message: Message):
user = database.users.get(id=from_user(message).id)
with bot.retrieve_data(from_user(message).id, message.chat.id) as data:
with bot.retrieve_data(from_user(message).id, message.chat.id) as data: # type: ignore
user_item = database.items.get(owner=user._id, name=data["name"])

if user_item.quantity < int(message.text): # type: ignore
bot.reply_to(message, "У тебя нет столько")
return

with bot.retrieve_data(from_user(message).id, message.chat.id) as data:
with bot.retrieve_data(from_user(message).id, message.chat.id) as data: # type: ignore
data["quantity"] = int(message.text) # type: ignore

call_message_id = redis_cache.get(f"{from_user(message).id}_item_add_message")
Expand All @@ -106,7 +106,7 @@ def quantity_state(message: Message):
@bot.message_handler(state=AddNewItemState.price, is_digit=True)
def price_state(message: Message):
user = database.users.get(id=from_user(message).id)
with bot.retrieve_data(from_user(message).id, message.chat.id) as data:
with bot.retrieve_data(from_user(message).id, message.chat.id) as data: # type: ignore
try:
user_item = database.items.get(owner=user._id, name=data["name"])
except NoResult:
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing_extensions import deprecated


import requests
import httpx
from semver import Version
from telebot.types import Message, ReplyParameters, InlineKeyboardButton, User
from telebot.util import antiflood, escape, split_string, quick_markup
Expand Down Expand Up @@ -210,9 +210,9 @@ def send_channel_subscribe_message(message: Message):

def check_version() -> str: # type: ignore
url = "https://api.github.com/repos/HamletSargsyan/livebot/releases/latest"
response = requests.get(url)
response = httpx.get(url)

if not response.ok:
if response.status_code != 200:
logger.error(response.text)
response.raise_for_status()

Expand Down
4 changes: 2 additions & 2 deletions tools/send_release_notification.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import os
from typing import Any, NoReturn, Union
import requests
import httpx

from telebot import TeleBot
from telebot.util import quick_markup


def get_github_release_info(version) -> Union[dict[Any, Any], NoReturn]:
url = f"https://api.github.com/repos/HamletSargsyan/livebot/releases/tags/{version}"
response = requests.get(url)
response = httpx.get(url)

response.raise_for_status()
release_info = response.json() # type: dict
Expand Down

0 comments on commit ea1d710

Please sign in to comment.