mirror of
https://github.com/cupcakearmy/mercatus.git
synced 2024-12-22 16:16:32 +00:00
warning for api keys
This commit is contained in:
parent
849193c451
commit
b7336b6a97
@ -69,21 +69,22 @@ Enjoy 🚀
|
|||||||
|
|
||||||
async def send_update_to_user(user: str, delta: datetime):
|
async def send_update_to_user(user: str, delta: datetime):
|
||||||
try:
|
try:
|
||||||
data = persistence.get_user_data()[user]
|
user_data = persistence.get_user_data()[user]
|
||||||
running = data.setdefault(Section.Running.value, False)
|
running = user_data.setdefault(Section.Running.value, False)
|
||||||
if Section.API_Key.value not in data:
|
if Section.API_Key.value not in user_data:
|
||||||
|
updater.bot.send_message(user, text='API Key not set ⛔️')
|
||||||
return
|
return
|
||||||
|
|
||||||
if running:
|
if running:
|
||||||
updater.bot.send_message(user, text='Already running 🏃')
|
updater.bot.send_message(user, text='Already running 🏃')
|
||||||
return
|
return
|
||||||
|
|
||||||
data[Section.Running.value] = True
|
user_data[Section.Running.value] = True
|
||||||
print('Sending updates to {}'.format(user))
|
print('Sending updates to {}'.format(user))
|
||||||
market = Market(data[Section.API_Key.value])
|
market = Market(user_data[Section.API_Key.value])
|
||||||
updater.bot.send_message(user, text='Getting updates 🌎')
|
updater.bot.send_message(user, text='Getting updates 🌎')
|
||||||
first = True
|
first = True
|
||||||
for item in data.get(Section.Watchlist.value, []):
|
for item in user_data.get(Section.Watchlist.value, []):
|
||||||
if first:
|
if first:
|
||||||
first = False
|
first = False
|
||||||
else:
|
else:
|
||||||
@ -97,11 +98,10 @@ async def send_update_to_user(user: str, delta: datetime):
|
|||||||
updater.bot.send_message(user, text='*{}*'.format(item), parse_mode=ParseMode.MARKDOWN)
|
updater.bot.send_message(user, text='*{}*'.format(item), parse_mode=ParseMode.MARKDOWN)
|
||||||
updater.bot.send_photo(user, photo=chart)
|
updater.bot.send_photo(user, photo=chart)
|
||||||
|
|
||||||
except Exception as e:
|
except:
|
||||||
print(e)
|
|
||||||
updater.bot.send_message(user, text='There was an error ⚠️')
|
updater.bot.send_message(user, text='There was an error ⚠️')
|
||||||
finally:
|
finally:
|
||||||
data[Section.Running.value] = False
|
user_data[Section.Running.value] = False
|
||||||
|
|
||||||
|
|
||||||
@interval(every=3 * 60 * 60.0, autorun=False, isolated=True)
|
@interval(every=3 * 60 * 60.0, autorun=False, isolated=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user