-
Notifications
You must be signed in to change notification settings - Fork 0
/
Firstbot.py
52 lines (30 loc) · 1.06 KB
/
Firstbot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from bs4.builder import HTML
from telegram.ext import *
import stockprice as stock_price
from telegram import ParseMode
import os
from dotenv import load_dotenv
load_dotenv()
print("Bot has started")
def start_command(update, context):
update.message.reply_text(
"Type a stock's NSE SYMBOL to get related information!")
def help_command(update, context):
update.message.reply_text(
"Enter a stock's NSE SYMBOL you want information about.")
def handle_message(update, context):
text = str(update.message.text).lower()
stock_price.nsestockprice(text, update, context)
def error(update, context):
print(f"Update {update} caused error {context.error}")
def main():
TOKEN = os.getenv('API_KEY')
updater = Updater(f"{TOKEN}")
dp = updater.dispatcher
dp.add_handler(CommandHandler("start", start_command))
dp.add_handler(CommandHandler("help", help_command))
dp.add_handler(MessageHandler(Filters.text, handle_message))
dp.add_error_handler(error)
updater.start_polling()
updater.idle()
main()