mirror of
https://gitlab.com/simple-stock-bots/simple-telegram-stock-bot.git
synced 2025-06-16 15:06:53 +00:00
added search command
This commit is contained in:
parent
fb4990c96c
commit
f90aa14f24
13
bot.py
13
bot.py
@ -113,6 +113,18 @@ def info(update, context):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def search(update, context):
|
||||||
|
message = update.message.text
|
||||||
|
chat_id = update.message.chat_id
|
||||||
|
|
||||||
|
queries = s.search_symbols(message)[:6]
|
||||||
|
if queries:
|
||||||
|
reply = "*Search Results:*\n`$ticker: Company Name`\n"
|
||||||
|
for query in queries:
|
||||||
|
reply += "`" + query[1] + "`\n"
|
||||||
|
update.message.reply_text(text=reply, parse_mode=telegram.ParseMode.MARKDOWN)
|
||||||
|
|
||||||
|
|
||||||
def inline_query(update, context):
|
def inline_query(update, context):
|
||||||
"""
|
"""
|
||||||
Handles inline query.
|
Handles inline query.
|
||||||
@ -163,6 +175,7 @@ def main():
|
|||||||
dp.add_handler(CommandHandler("div", dividend))
|
dp.add_handler(CommandHandler("div", dividend))
|
||||||
dp.add_handler(CommandHandler("news", news))
|
dp.add_handler(CommandHandler("news", news))
|
||||||
dp.add_handler(CommandHandler("info", info))
|
dp.add_handler(CommandHandler("info", info))
|
||||||
|
dp.add_handler(CommandHandler("search", search))
|
||||||
|
|
||||||
# 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