Skip to content

Commit

Permalink
exchange receiving float
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigondec committed Dec 16, 2019
1 parent a376630 commit fcda567
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
16 changes: 6 additions & 10 deletions bot/commands/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,17 @@ def dcr(update: Update, context: CallbackContext):
dcr_amount = None

try:
arg_0 = context.args[0]
if arg_0.isdigit():
dcr_amount = float(arg_0)
else:
target_currency = arg_0.upper()
dcr_amount = float(context.args[0])
except ValueError:
target_currency = context.args[0].upper()
except IndexError:
dcr_amount = 1
target_currency = "USD"

try:
arg_1 = context.args[1]
if arg_1.isdigit():
dcr_amount = float(arg_1)
else:
target_currency = arg_1.upper()
dcr_amount = float(context.args[1])
except ValueError:
target_currency = context.args[1].upper()
except IndexError:
if target_currency is None:
target_currency = "USD"
Expand Down
6 changes: 4 additions & 2 deletions bot/commands/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def unsubscribe(update: Update, context: CallbackContext):
try:
observer = UserObserver.objects.get(chat_id=f"{chat.id}")
except DoesNotExist:
message.reply_text(f"Observer with chat_id {chat.id} doesn't exist!\nCall /subscribe before")
message.reply_text(f"Observer with chat_id {chat.id} doesn't exist!\n"
f"Call /subscribe before")
return

subscribed_subjects = Subject.objects(observers=observer)
Expand Down Expand Up @@ -84,7 +85,8 @@ def subscriptions(update: Update, context: CallbackContext):
try:
observer = UserObserver.objects.get(chat_id=f"{chat.id}")
except DoesNotExist:
message.reply_text(f"Observer with chat_id {chat.id} doesn't exist!\nCall /subscribe before")
message.reply_text(f"Observer with chat_id {chat.id} doesn't exist!\n"
f"Call /subscribe before")
return

subscribed_subjects = Subject.objects(observers=observer)
Expand Down
1 change: 0 additions & 1 deletion db/observer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Document,
StringField, IntField, ListField, DateTimeField,
ReferenceField, NULLIFY)
from mongoengine.errors import DoesNotExist
from telegram.error import BadRequest

from bot.core import BotTelegramCore
Expand Down

0 comments on commit fcda567

Please sign in to comment.