Bot into main #71
@ -115,7 +115,7 @@ def send_welcome(message):
|
|||||||
|
|
||||||
:rtype: none
|
:rtype: none
|
||||||
"""
|
"""
|
||||||
bot.reply_to(message, "/id or /auth get your user id\n/update get updates on your shares.\n/users see all users.\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\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/users see all users.\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.message_handler(commands=['users'])
|
@bot.message_handler(commands=['users'])
|
||||||
@ -379,7 +379,7 @@ def send_keywords(message):
|
|||||||
bot.send_message(chat_id=user_id, text=f'Your keywords are: _{keywords_str}_', parse_mode="MARKDOWN")
|
bot.send_message(chat_id=user_id, text=f'Your keywords are: _{keywords_str}_', parse_mode="MARKDOWN")
|
||||||
|
|
||||||
|
|
||||||
@bot.message_handler(commands=['portfolio'])
|
@bot.message_handler(commands=['portfolio']) #tbd
|
||||||
def send_portfolio(message):
|
def send_portfolio(message):
|
||||||
""" Send portfolio of user
|
""" Send portfolio of user
|
||||||
:type message: message object bot
|
:type message: message object bot
|
||||||
@ -402,7 +402,7 @@ def send_portfolio(message):
|
|||||||
bot.send_message(chat_id=user_id, text=f'Your portfolio is: _{portfolio_str}_', parse_mode="MARKDOWN")
|
bot.send_message(chat_id=user_id, text=f'Your portfolio is: _{portfolio_str}_', parse_mode="MARKDOWN")
|
||||||
|
|
||||||
|
|
||||||
@bot.message_handler(commands=['newtransaction'])
|
@bot.message_handler(commands=['newtransaction']) #tbd
|
||||||
def set_new_transaction(message):
|
def set_new_transaction(message):
|
||||||
""" Set new transaction for user
|
""" Set new transaction for user
|
||||||
:type message: message object bot
|
:type message: message object bot
|
||||||
@ -437,7 +437,7 @@ def set_new_transaction_step(message):
|
|||||||
bot.send_message(chat_id=user_id, text=f'Failed adding transaction. (statuscode {status})')
|
bot.send_message(chat_id=user_id, text=f'Failed adding transaction. (statuscode {status})')
|
||||||
|
|
||||||
|
|
||||||
@bot.message_handler(commands=['interval'])
|
@bot.message_handler(commands=['interval']) #tbd
|
||||||
def send_interval(message):
|
def send_interval(message):
|
||||||
""" send interval for user
|
""" send interval for user
|
||||||
:type message: message object bot
|
:type message: message object bot
|
||||||
@ -448,12 +448,12 @@ def send_interval(message):
|
|||||||
:rtype: none
|
:rtype: none
|
||||||
"""
|
"""
|
||||||
user_id = int(message.from_user.id)
|
user_id = int(message.from_user.id)
|
||||||
interval = api_handler.get_user(user_id)['cron']
|
interval = api_handler.get_user(user_id)
|
||||||
if interval == None:
|
if interval == None:
|
||||||
bot.send_message(chat_id=user_id, text='This didn\'t work. Make sure too connect your telegram id (/id) on https://gruppe1.testsites.info and set an interval with /setinterval')
|
bot.send_message(chat_id=user_id, text='This didn\'t work. Make sure too connect your telegram id (/id) on https://gruppe1.testsites.info and set an interval with /setinterval')
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
interval = str(interval)
|
interval = str(interval['cron'])
|
||||||
formatted_interval = str(interval).replace(' ', '_')
|
formatted_interval = str(interval).replace(' ', '_')
|
||||||
bot.send_message(chat_id=user_id, text=f'Your update interval: {interval} (https://crontab.guru/#{formatted_interval})', parse_mode="MARKDOWN")
|
bot.send_message(chat_id=user_id, text=f'Your update interval: {interval} (https://crontab.guru/#{formatted_interval})', parse_mode="MARKDOWN")
|
||||||
|
|
||||||
@ -469,7 +469,7 @@ def set_new_interval(message):
|
|||||||
:rtype: none
|
:rtype: none
|
||||||
"""
|
"""
|
||||||
user_id = int(message.from_user.id)
|
user_id = int(message.from_user.id)
|
||||||
bot.send_message(chat_id=user_id, text='Type interval in cron format (https://crontab.guru/):')
|
bot.send_message(chat_id=user_id, text='Type interval in cron format:\n(https://crontab.guru/)')
|
||||||
bot.register_next_step_handler(message, set_new_interval_step)
|
bot.register_next_step_handler(message, set_new_interval_step)
|
||||||
|
|
||||||
def set_new_interval_step(message):
|
def set_new_interval_step(message):
|
||||||
@ -482,7 +482,7 @@ def set_new_interval_step(message):
|
|||||||
bot.send_message(chat_id=user_id, text='Interval succesfully set.')
|
bot.send_message(chat_id=user_id, text='Interval succesfully set.')
|
||||||
return
|
return
|
||||||
|
|
||||||
if status == -1:
|
if status == -1: # only -1 when interval is invalid
|
||||||
bot.send_message(chat_id=user_id, text='Invalid interval. Try again with /setinterval.')
|
bot.send_message(chat_id=user_id, text='Invalid interval. Try again with /setinterval.')
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user