-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
подключил redis, сделал сохранение данных в redis
- Loading branch information
Павел Сарыгин
committed
Feb 5, 2024
1 parent
ceb9d23
commit 87e0826
Showing
8 changed files
with
106 additions
and
55 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
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
Binary file not shown.
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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
from aiogram.types import BotCommand | ||
|
||
|
||
TOKEN = '6787434498:AAHW5Y2gUJQLqttiQ-Vj9qulyBoTCHYYVu4' | ||
URL = 'https://short-tracker.acceleratorpracticum.ru/api/v1/' | ||
COMMANDS = [BotCommand(command='/start', description='Запуск бота') | ||
] | ||
] | ||
HEADERS = { | ||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)' | ||
' AppleWebKit/537.36 (KHTML, like Gecko)' | ||
' Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0' | ||
} |
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
17 changes: 17 additions & 0 deletions
17
short_tracker_bot/short_tracker_bot/handlers/redis_data.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,17 @@ | ||
import asyncio | ||
import logging | ||
|
||
import aioredis | ||
|
||
redis = aioredis.Redis(host='redis') | ||
|
||
|
||
async def save_data_to_redis(key, value): | ||
logging.info(f'Сохранение в redis {key, value}') | ||
await redis.sadd(key, value) | ||
|
||
|
||
async def get_data_from_redis(key): | ||
data = await redis.get(key) | ||
logging.info(f'get data {data}') | ||
return data |
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