Download app.py from Pezh/nam: direct link, hf CLI and curl.
- Browser
- Download file 1.39 kB
-
https://huggingface.co/spaces/Pezh/nam/resolve/main/app.py
- Command line
-
hf download hf://spaces/Pezh/nam/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Pezh/nam/resolve/main/app.py
1.39 kB
| import streamlit as st | |
| import yfinance as yf | |
| import telebot | |
| import requests | |
| # Your bot's API token | |
| BOT_TOKEN = '6840454109:AAF2TuZsNgb705RzfKRPuqmdfoYUroDKM-8' | |
| # The chat ID of the user you want to send the message to | |
| CHAT_ID = '195083272' | |
| # The base URL for the Telegram API | |
| API_URL = f"https://api.telegram.org/bot{BOT_TOKEN}" | |
| def send_telegram_message(chat_id, text): | |
| # The endpoint for sending messages | |
| method_url = f"{API_URL}/sendMessage" | |
| # The data to be sent to the API | |
| payload = { | |
| 'chat_id': chat_id, | |
| 'text': text | |
| } | |
| # Send a request to the Telegram Bot API | |
| response = requests.post(method_url, data=payload) | |
| return response.json() # You can handle and parse the response as needed | |
| # Example usage: | |
| message = "Hello, this is a message from the server." | |
| #k='6840454109:AAF2TuZsNgb705RzfKRPuqmdfoYUroDKM-8' | |
| #bot=telebot.TeleBot(k, parse_mode=None) | |
| def yff(coin): | |
| bb=yf.Ticker(coin) | |
| d=bb.history(period='max') | |
| return d | |
| st.button("Reset", type="primary") | |
| if st.button('Say hello'): | |
| st.write('Why hello there') | |
| else: | |
| st.write('Goodbye') | |
| #def hey(): | |
| # @bot.message_handler(commands=['start', 'help']) | |
| # def send_welcome(message): | |
| # bot.reply_to(message, (message.text)) | |
| # bot.infinity_polling() | |
| st.button('Click me', on_click=send_telegram_message(CHAT_ID, message)) |