implemented /transactions and added /shares
This commit is contained in:
parent
8a08f9a26e
commit
b63744d08a
@ -83,7 +83,7 @@ def send_help(message):
|
|||||||
|
|
||||||
:rtype: none
|
:rtype: none
|
||||||
"""
|
"""
|
||||||
bot.reply_to(message, "/id or /auth get your user id\n/update get updates on your shares.\n/setAdmin set admin rights of user (ADMIN)\n/users see all users. (ADMIN)\n/me get my user info\n/news get top article for each keyword.\n/allnews get all news (last 7 days)\n/keywords get all your keywords\n/addkeyword add a keyword\n/removekeyword remove a keyword\n/share get price of specific share\n/portfolio see own portfolio\n/newtransaction add new transaction\n/interval get update interval\n/setinterval set update interval\n_For further details see https://gruppe1.testsites.info _", parse_mode='MARKDOWN')
|
bot.reply_to(message, "/id or /auth get your user id\n/update get updates on your shares.\n/shares get update on interesting shares\n/setAdmin set admin rights of user (ADMIN)\n/users see all users. (ADMIN)\n/me get my user info\n/news get top article for each keyword.\n/allnews get all news (last 7 days)\n/keywords get all your keywords\n/addkeyword add a keyword\n/removekeyword remove a keyword\n/transactions get all transactions\n/share get price of specific share\n/portfolio see own portfolio\n/removeshare removes share from portfolio\n/interval get update interval\n/setinterval set update interval\n_For further details see https://gruppe1.testsites.info _", parse_mode='MARKDOWN')
|
||||||
|
|
||||||
|
|
||||||
@bot.message_handler(commands=['users', 'Users']) # /users -> sending all users
|
@bot.message_handler(commands=['users', 'Users']) # /users -> sending all users
|
||||||
@ -546,6 +546,54 @@ def send_interval(message):
|
|||||||
bot.send_message(chat_id=user_id, text=f'Your update interval: {interval} (https://crontab.guru/#{formatted_interval})')
|
bot.send_message(chat_id=user_id, text=f'Your update interval: {interval} (https://crontab.guru/#{formatted_interval})')
|
||||||
|
|
||||||
|
|
||||||
|
@bot.message_handler(commands=['transactions', 'Transactions'])
|
||||||
|
def send_transactions(message):
|
||||||
|
""" send transactions for user
|
||||||
|
:type message: message object bot
|
||||||
|
:param message: message that was reacted to, in this case always '/transactions'
|
||||||
|
|
||||||
|
:raises: none
|
||||||
|
|
||||||
|
:rtype: none
|
||||||
|
"""
|
||||||
|
user_id = int(message.from_user.id)
|
||||||
|
transactions = api_handler.get_user_transactions(user_id) # get transactions of user
|
||||||
|
|
||||||
|
if transactions == None: # true if user does not exist
|
||||||
|
bot.send_message(chat_id=user_id, text='This didn\'t work. Make sure to connect your telegram id (/id) on https://gruppe1.testsites.info')
|
||||||
|
return
|
||||||
|
|
||||||
|
if not transactions: # true if user has no transactions
|
||||||
|
bot.send_message(chat_id=user_id, text='You do not have any transactions.')
|
||||||
|
return
|
||||||
|
|
||||||
|
else:
|
||||||
|
for transaction in transactions:
|
||||||
|
bot.send_message(chat_id=user_id, text=f'_{transaction["comment"]}_\n{transaction["isin"]}\namount: {transaction["count"]}\nprice: {transaction["price"]}\ntime: {transaction["time"]}', parse_mode="MARKDOWN")
|
||||||
|
|
||||||
|
|
||||||
|
@bot.message_handler(commands=['shares', 'Shares'])
|
||||||
|
def send_shares(message):
|
||||||
|
""" send shares for user
|
||||||
|
:type message: message object bot
|
||||||
|
:param message: message that was reacted to, in this case always '/shares'
|
||||||
|
|
||||||
|
:raises: none
|
||||||
|
|
||||||
|
:rtype: none
|
||||||
|
"""
|
||||||
|
user_id = int(message.from_user.id)
|
||||||
|
shares = api_handler.get_user_shares(user_id) # get shares of user
|
||||||
|
|
||||||
|
if shares == None: # true if user does not exist
|
||||||
|
bot.send_message(chat_id=user_id, text='This didn\'t work. Make sure to connect your telegram id (/id) on https://gruppe1.testsites.info')
|
||||||
|
|
||||||
|
if not shares: # true if user has no shares
|
||||||
|
bot.send_message(chat_id=user_id, text='You do not have any shares. Add shares on https://gruppe1.testsites.info')
|
||||||
|
|
||||||
|
# tbd (flo)
|
||||||
|
|
||||||
|
|
||||||
@bot.message_handler(commands=['setinterval', 'Setinterval'])
|
@bot.message_handler(commands=['setinterval', 'Setinterval'])
|
||||||
def set_new_interval(message):
|
def set_new_interval(message):
|
||||||
""" Set new interval for user
|
""" Set new interval for user
|
||||||
|
Loading…
Reference in New Issue
Block a user