mirror of
https://gitlab.com/simple-stock-bots/simple-stock-bot.git
synced 2025-06-16 15:17:28 +00:00
added random command
This commit is contained in:
parent
df68df5e20
commit
4cc4a2cda6
16
bot.py
16
bot.py
@ -3,6 +3,7 @@ import datetime
|
|||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import random
|
||||||
|
|
||||||
import mplfinance as mpf
|
import mplfinance as mpf
|
||||||
import telegram
|
import telegram
|
||||||
@ -198,6 +199,19 @@ def inline_query(update, context):
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def rand_pick(update, context):
|
||||||
|
|
||||||
|
choice = random.choice(list(s.symbol_list["description"]))
|
||||||
|
hold = (
|
||||||
|
datetime.date.today() + datetime.timedelta(random.randint(1, 365))
|
||||||
|
).strftime("%b %d, %Y")
|
||||||
|
|
||||||
|
update.message.reply_text(
|
||||||
|
text=f"{choice}\nBuy and hold until: {hold}",
|
||||||
|
parse_mode=telegram.ParseMode.MARKDOWN,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def error(update, context):
|
def error(update, context):
|
||||||
"""Log Errors caused by Updates."""
|
"""Log Errors caused by Updates."""
|
||||||
logger.warning('Update "%s" caused error "%s"', update, error)
|
logger.warning('Update "%s" caused error "%s"', update, error)
|
||||||
@ -221,6 +235,8 @@ def main():
|
|||||||
dp.add_handler(CommandHandler("search", search))
|
dp.add_handler(CommandHandler("search", search))
|
||||||
dp.add_handler(CommandHandler("intraday", intra))
|
dp.add_handler(CommandHandler("intraday", intra))
|
||||||
dp.add_handler(CommandHandler("intra", intra))
|
dp.add_handler(CommandHandler("intra", intra))
|
||||||
|
dp.add_handler(CommandHandler("random", rand_pick))
|
||||||
|
|
||||||
# on noncommand i.e message - echo the message on Telegram
|
# on noncommand i.e message - echo the message on Telegram
|
||||||
dp.add_handler(MessageHandler(Filters.text, symbol_detect))
|
dp.add_handler(MessageHandler(Filters.text, symbol_detect))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user