Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Commit

Permalink
feat: unmute on threshold change
Browse files Browse the repository at this point in the history
  • Loading branch information
etienne-napoleone committed Aug 10, 2021
1 parent c26787a commit d5fa919
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion terra_ltv_bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async def on_startup(self, dp: Dispatcher):
database=self.db,
document_models=all_models,
)
Handlers(dp, self.terra)
Handlers(dp, self.terra, self.redis)
Tasks(dp, self.bot, self.terra, self.redis)

async def on_shutdown(self, _: Dispatcher):
Expand Down
7 changes: 6 additions & 1 deletion terra_ltv_bot/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from aiogram import types
from aiogram.dispatcher import Dispatcher
from aiogram.utils.exceptions import Throttled
from aioredis import Redis
from pymongo.errors import DuplicateKeyError

from .models import Address, Subscription
Expand All @@ -13,9 +14,10 @@


class Handlers:
def __init__(self, dp: Dispatcher, terra: Terra) -> None:
def __init__(self, dp: Dispatcher, terra: Terra, redis: Redis) -> None:
self.dp = dp
self.terra = terra
self.redis = redis
dp.register_message_handler(self.start, commands=["start", "help"])
dp.register_message_handler(self.subscribe, commands=["subscribe"])
dp.register_message_handler(self.list_, commands=["list"])
Expand Down Expand Up @@ -90,6 +92,9 @@ async def subscribe(self, message: types.Message) -> None:
if subscription:
if alert_threshold != subscription.alert_threshold:
subscription.alert_threshold = alert_threshold
await self.redis.delete(
f"{account_address}:anchor:{subscription.telegram_id}"
)
else:
subscription = Subscription(
address_id=address.id,
Expand Down

0 comments on commit d5fa919

Please sign in to comment.