Merge branch 'bot' of https://github.com/WebEngineering2/TelegramAktienBot into bot
This commit is contained in:
commit
925b3ead62
@ -468,13 +468,13 @@ def set_new_transaction(message):
|
||||
:rtype: none
|
||||
"""
|
||||
user_id = int(message.from_user.id)
|
||||
bot.send_message(chat_id=user_id, text='Type "<name of stock>,<isin>,<amount>,<price_per_stock_usd>" (time of transaction will be set to now):')
|
||||
bot.send_message(chat_id=user_id, text='Type "<name of stock>,<isin>,<amount>,<price_per_stock_usd>" (time of transaction will be set to now, negative amount is selling, positive is buying):')
|
||||
bot.register_next_step_handler(message, set_new_transaction_step)
|
||||
|
||||
def set_new_transaction_step(message):
|
||||
user_id = int(message.from_user.id)
|
||||
|
||||
if not re.match(r"[A-Za-z0-9]+,[A-Za-z0-9]+,[0-9]+(.[0-9]+)?,[0-9]+(.[0-9]+)?", message.text):
|
||||
if not re.match(r"[A-Za-z0-9]+,[A-Za-z0-9]+,(-)?[0-9]+(.[0-9]+)?,[0-9]+(.[0-9]+)?", message.text):
|
||||
bot.send_message(chat_id=user_id, text='Invalid format \n(e.g. Apple,US0378331005,53.2,120.4).\n Try again with /newtransaction.')
|
||||
return
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user